Similarity search code cleanup.