Fixes for ENTESB-1929: Lets be more careful about when we set the DOMAIN env vars.