Fixed bugs in user registration