Refactor from get-clusters.
Changes for speed, clarity and use simplification.