Initial import of pairwise code.