lots of duplicate code here.  I would think there should be a single function that takes the directory and returns the full object.  Then you just do the merge at the end