moved an max/min macros to using templated functions instead