Merging changes from Kirk.

I know some things look very, very wrong. But this is just for
archiving.