Removed unused code.
Improvements in handling failed logins and error messaging.