Use `window` instead of `self`

Fixes #631.