Setup Js2 and refactor modes