Improvements to authentication handling.