Changed implementation of directory creation