flake8 and bugfixes