Fix a bug in the pairing code