Various pep-8/style/Python 3 compatibility fixes