Cleanup code to make PEP8 compliant (as much as possible)

@TingPing,

I did the PEP8 cleanup again. Mind having a look?