cleaner error handling / console debugging; fix detection of authenticated