Fix to work with Python 3.
Fixes to work with Python 3.
Fixes to work with Python 3.
Fixes to work with Python 3.
Fixes to work with Python 3.
Fixes to work with Python 3.
Tidy up indentation.