More refactoring of session creation