Refactor JS to remove as more as possible global identifiers.