WIP, more refactoring, working registration and sending emails