Multiple SSO script fixes
Merge branch 'script-improvements' into mine