Adds pruning & sorting