Clean up the python a little.
(Make it pep8-compliant, 4-spaces for indents, print errors to stderr, make lines less than 80 characters, merge some if/elses…)