ec2.py: Cleanup (pep8 and pyflakes)

Cleanup of the code according to PEP8 and recommendations by pyFlakes.