Remove function and use std::shared_ptr