PEP8 cleanup
Various changes for py3 compatibility