fix typo and logic error
pep8 cleanup
(mostly whitespace warnings)