Small cleanup.py refactoring