Add optimizer opcodes, fix bugs