Cleaned python script so that it runs without errors