PEP 8, refactoring, and squashing bugs