Fix a bunch of pyflakes warnings.

Fix up things that have snuck in over the past few months. Trivial changes.

Testing done: Ran unit tests.

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