Clean up code in app_authenticate.