Bug fix

this.document cannot be used in strict mode, so explicitly use
window.document (quick fix) for now.
Minor comments