refactors session initialization.