optimizations for clustering