Pull the registrar handling code out into a separate module and try clean it up nicely