Made auth module more defensive so less likely to throw uncaught exceptions. Issue: #1