Bug fixes in authentication API