Refactoring session handling