Fixed overriding of window and document