Improved session management

Added some new functions to the session management system.