Fix memory leaks in History::findRootPath