max distance return Inf instead of Nil; changed types to Num from Int; max_distance for ld hackish fix