Refactored thread local session factory and provider