speed up registration

The result of a day's profiling code to work out how to get registration to be
sped up by about an order of magnitude.