Disregard my previous comment about the deeply nested directories - it's easy to fix and I've added a patch that does that so now there's at most 1 directory open during traversal.
Anyway, the second patch is just a bonus - it's not something that could cause that many fd's are open after the project is loaded and not the cause of the original problem.