Some of the code get raw pointer and then delete, we should switch to std::unique_ptr to avoid memory leak