remove unnecessary window references and move to ES5