Refactor to OO JS.