cleanup code
replace while by for loop where appropriate
change type of operand_types to enum