Clean up a number of pep8 and pyflakes warnings and errors.

The bulk of this are line length and spacing issues. Nothing here is
really fixing any bugs. There are no undefined variables. It does clean
things up a bit though.