more thread safety on directory creation