Fix some serious bugs. Add function to check if reset token is valid.