Refactor for_each_td() to catch inappropriate td ptr reuse