Simplify usage of shared_ptr