Start of JS refactor