respecting branching limit and writing clusters to the right place