@Cosmidark c.f. similar recent post
replace “completely clearing curdoc” with “adding roots dynamically” above.