Completed the switch from ugly MACROs to a function template in CRS-planner2.