Add some code to the tree walking to better handle file descriptors.