Fix ReferenceErrors since we can't qualify with `window`

btw, this is the worst language. Fixes #287
Merge branch 'master' into dist
Dist build.