Remove window references and handle global

Fixes #4