minor code clean-up and pep8 fixes