Change how environment detection is done: use existence of 'window' to check we're in a browser.