Refactor opcode rewrites into an isRoot opcode argument