Python: Code cleanup (in progress)