put back root_factory API and add a directive for adding a reference root