backport collapsing from nextgen