Don't use window to access global object

In order to support contexts that don't use modules but aren't the browser.