cleanup task tree code a bit