Cleanup and opcode handling mechanism rewrite