Add flake8 testing and more fixes