[DF-536] Added clamping of distances