gracefully handle invalid sessions
Merge pull request #177 from goshakkk/invalid-sessions

Gracefully handle invalid sessions (WIP 306)