Fix a bunch of pep8 errors and style issues.
Improve consistency around variable names.