pep8 and compatibility fixes