Collect temporary register code. Also made coregister loading code generic.