Modified to work with python 2.X.

Quick mod tested and working with python 2.7. Few minor changes/improvements. Many tab-indents were fixed and replaced with spaces.