Nearly

Lots of hard-coded values but it's almost there.  Some problems with
index ordering.