Improve bad login handling.
Merge branch 'master' into refactoring