PEP8 whitespace changes, remove unused imports

While browsing the code I noticed some white space inconsistencies that make it a tad more difficult to tell, at a glance, whether a definition is in a global scope or in a class, etc. This PR fixes the white space.

Additionally if a contributor has a PEP8 plugin enabled then this PR will clean up the numerous warnings.

I also removed a few unused imports.

Are these kind of PRs welcome? If so, I'd like to continue the work in other files.