Fix bug: unnecessary directories were created