Pep8 and a little code cleanup.

This was written years ago, and needs an incredible refactor.