Minor change in rpairs(). It was assuming that the pair codes (pc) were also valid indices in the data frame of kPairs. Now we are matching any pair codes to the pc column of kPairs