Fully comply with pep8 and pyflakes best practices

The repository as it stands in the flake8 branch passes flake8 with no warnings or errors. Also, the build will error if code is committed that generates warnings or errors when run against flake8.