Revert "replace all std::min/std::max with just min/max"

This reverts commit 28d967cccea6d3b9b639740f41478338b22cecdb.