Tidied up a bit

Hi, 

I took the liberty of tidying up the source code, almost all of it is pep8 compliant now, I removed all of the debug print statements and commented code.

I also found a few small logic errors, and some mutable function args which I have sorted out.

Hope you like it!