Fix and improve reset password function.