Bug fix to SimilarityMatrix