fix flakes and pep8 errors