Session uuid fixes (rebased onto develop)



This is the same as gh-1478 but rebased onto develop.

----

Various fixes for session uuid issues. See @manics' local scripts for testing.