Typos, indentations and import fixes

Nothing ground-breaking here, but I was looking at the code.
It now passes pep8, pyflakes and co