Add reset password functionality and fix some bugs.