Improve the initial directories creation

I tried it with nested non-existing directories, and came across a couple of issues.