Attempt to increase consistency in code and fixing several pep8 violatio...

...ns

There are quite a few inconsistencies in the code in terms of spacing and indentation. There are also numerous pep8 violations. This doesn't fix all of them but it is a start.