remove temporal dir when finishing, free the mallocs
working in a lot of stuff