Implemented mkdir -p and cleaning up superfluous directories.