Fixes #5402 fixes session wrapping