release model; fix memory allocation; fix remove directory