Generic changes.

Standardised the code layout. Removed unnecessary "global" statements.
Used doc strings for classes and methods.
Merge branch 'FurtherCleanups' into develop