Recursive template cleanup.