Fixing NPE on creating a Registration and some code cleanup