Clean up usage of shared_ptr