Lots of small pyflakes and PEP-8 cleanups & some simplifications.

These are all pretty minor, to make the code 100% clean under both PEP-8 and pyflakes. There are also a few simplifications that I hope wont break anything :-)