Fix threads and pointers deletion