Fix indexing error in the hierarchical clustering.
Add logical NOT function