Did some tidying up. More to be done soon.
Needs more documentation.