Stack patterns for boundaries, contributions, histograms, and greedy removal.