Remove unused import, fix whitespace, indentation, and comments
Almost entirely fixing print statements, but also a couple importing changes, wrapped in try/excepts, and one case where dict.keys() not being a list would be a problem. Also reverts e41139a397 The real fix for #1907
e41139a397