Corrects the directory creation and permisions