Small clean-ups and leak fixes in the OPENDIR mechanism.

Should declare end here.