refactor session management, refactor timeout management