improved session check, fixes #18