Added environment detection.