fixes and improvements to sso stuff