Pep8 formatting and python3 fixing of the code