Move registration code into its own file