Bugfix in ensureDirExists