Mainly pep8 and some python 3 compatibility