Refactor session handling
Merge pull request #3 from wagnert/master

Refactor session handling