Support multiple roots and maintain root ref automatically.