python code cleanup