Cleaned up authentication code. Better login error messages. Fixes #34