Code cleanup and pep8 formatting.