Session uuid fixes

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