PEP8 and PyFlakes fixes

Attempts to follow python standards as close as possible while
maintaining compatability.