Added better error handling in authentication code