Partial implementation of mincaverage.