Fix pep8 and pyflakes warnings