Fixed all pep8 warnings, and made the code work

In the process of cleaning up the code, I made the debug messages less
horrible to look at, but there is room for more improvement