Add better error checking for failed logins and other minor tweaks