Updated the cost_distance function to make use of _squared_distance (which is not private, by the way).