Added checks in the unlikely case that all elevations are equal to avoid a division by zero error.