Fix bug where subdirs were not created if parent dir did not exist