Optimize project root lookup and caching