Clean up PyFlakes warnings and errors.

We've let the cruft build for a while. This cleans it up. PyFlakes is
much happier now, and it's easier to spot issues with newer changes.