More work on the model - and some refactoring, and some stuff that I no
longer remember :(