Use 'global' instead of 'window' for web worker compatibility

Fixes #2