Clean up python code