Make max and min more generic.