Cleaned up code

Didn't add any functionality, just converted everything to python style guidelines and make it easier to read.