Improve root detection