Bugfix and pep8 fixes.