Better local environment detection