Fix min-heap and cosine similarity bug