Fixes #2
Fixes #3, also some cleanup
Session timeout