Refactor root text and element opcodes