Added GetFirstNonUsedDistIndex fcn.