fixed bugs with division by zero while computing path length.