Cleaned up the python code.