pep8 and pyflakes

cleaned up code, conformed to pep8 standards and checked with pyflakes.