Improved handling of login failures