Fixed some bugs on register and on email sending.