Cleanup merge #2

I am still cleaning up your code. It is very Pythonic. I am sure I could cut 100 lines more.