Apply the cut set minimization optimization from the previous algorithm.

The code from the previous algorithm is used to minimize generated cut
sets. This provides a bit of performance improvement.