Implemented a smarter handling of directory creation, removal and renaming.