Fix pep8/flake8 errors, remove unrelated code