Improved error handling during login, closes #21