Tidying up.

Completely untested code.