Clean up a bunch of PEP-8/pyflakes problems.

This change fixes up a bunch of relatively straightforward errors. Most of
these have to do with particulars of whitespace and indentation.

Testing done:
Ran unit tests.

Reviewed at https://reviews.reviewboard.org/r/6284/