Improved session management. Closes #5