Canonicalization

For reviewing this code
Why is min_dist 2 dimensional?