Fixes some bugs during directory creation