Fix issues with the sequence code when using sessions - refs BT#7288