                      primaryResult->mapq = computeMAPQ(probabilityOfAllCandidates, probabilityOfBestCandidate, bestScore, popularSeedsSkipped);
                      if (primaryResult->mapq >= MAPQ_LIMIT_FOR_SINGLE_HIT) {
                          primaryResult->status = SingleHit;
+@@ -1042,6 +1057,7 @@ Return Value:
+                     }
+ 
+                     bestScore = score;
++					probabilityOfSecondBestCandidate = probabilityOfBestCandidate;
+                     probabilityOfBestCandidate = matchProbability;
+                     _ASSERT(probabilityOfBestCandidate <= probabilityOfAllCandidates);
+                     bestScoreGenomeLocation = genomeLocation;
+@@ -1059,6 +1075,9 @@ Return Value:
+                         secondBestScoreGenomeLocation = genomeLocation;
+                         secondBestScoreDirection = elementToScore->direction;
+                     }
++					if(matchProbability > probabilityOfSecondBestCandidate) {
++						probabilityOfSecondBestCandidate = matchProbability;
++					}
+ 
+                     //
+                     // If this is close enough, record it as a secondary alignment.
 diff -rupN -x Xcode -x .git tmp/snap/SNAPLib/BaseAligner.h snap/SNAPLib/BaseAligner.h
 --- tmp/snap/SNAPLib/BaseAligner.h	2016-01-18 14:51:10.000000000 -0500
-+++ snap/SNAPLib/BaseAligner.h	2015-08-05 11:12:27.000000000 -0400
++++ snap/SNAPLib/BaseAligner.h	2016-08-22 16:50:49.000000000 -0400
 @@ -136,6 +136,9 @@ private:
      _int64 nReadsIgnoredBecauseOfTooManyNs;
      _int64 nIndelsMerged;

 
 	bool fromAlignTogether;                     // Was this alignment created by aligning both reads together, rather than from some combination of single-end aligners?
 	bool alignedAsPair;                         // Were the reads aligned as a pair, or separately?
@@ -90,4 +147,4 @@ struct PairedAlignmentResult {
 
     static int compareByContigAndScore(const void *first, const void *second);      // qsort()-style compare routine
     static int compareByScore(const void *first, const void *second);               // qsort()-style compare routine

+		secondBestScorePair = _secondBestScorePair;
+		probabilityOfAllCandidates = _probabilityOfAllCandidates;
+		probabilityOfBestCandidate = _probabilityOfBestCandidate;
+		probabilityOfSecondBestCandidate = _probabilityOfSecondBestCandidate;
+		popularSeedsSkipped = _popularSeedsSkipped;
+		popularSeedsSkippedPair = _popularSeedsSkippedPair;
+		countOfHashTableLookups = _countOfHashTableLookups;
