fix pyflakes and pep8 errors