first attempts at refactoring this code to make it more readable; mostly changing to dictionaries for format strings svn:r450