Code cleanup: refactor the switch statements in the generation of reduction variables...