code cleanups and flake8 ready