Backported session fix to 1.1.x