Fix boundary computation for distance metrics.