Pep8 and bug fixes