Code formatting changes

This change modifies the code style, but not the code itself. Mostly this was to bring line lengths back into the ~80 character range and make the code easier to read. I am using PyCharm so used its indent facility, then manually changed things from there.

I hope this is useful.