Fix calculation of min/max in presence of missing data