Refactors to pass jslint