Fixed hacking, pep8 and pyflakes errors.