Use `window` instead of `self`

Closes #631.