Fixing issue #291 (WIP)

Don't use `window`, has to be `global`