Refactor core JS bits into NX.* namespace