Issue #2350149 by eshta: Improve batch and session initialization.