refactored context session stuff