Fix signed-unsigned comparison errors likely causing bad starting-distance values