Python code clean-up