Added better handling of login failures.