Fix previous merge! Refactor code.

1. Fix previous merge!
2. Refactor code.
3. Change email field from text to email.