Changes contributed by @cristizmf! Thank you so much!
Minimize diff, keep task root check