tidy some things prior to py3 update
run flake8, tidy code
tidy code, py3 fixes