Pep8 fixes

This fixes most of the warnings and errors that Flake8 generates.