Implemented optional pruning.