Session refactoring