added error infrastructure and beefed up login system