Working version of the registration component.

After more research it turned out that things can be a lot simpler. Will revert some code now.