Revised according to PEP8 and pyflakes

Coped with a lot of errors and warnings pep8 reports.
In addition, removed unused variables according to pyflakes
Revised according to PEP8