Refactors registration module and adds error-handling to login.