Cleanups and error fixes suggested by flake8 (pep8 + pyflakes)