Reorder directory tree creation so that dependencies are removed