PEP-8 clean

With the help of some minor refactoring.