Fixed issues found with pyflakes, pep8 and pylint. No changes in the logic.