Work in progress.

Compiles.  Still in need of testing, using, neatening up, documenting
and, most important of all, approval by Alex.