This begins a programme of code reorganisation at the end of which I'd like to end up with something almost legible :-)