Implementation draft with shared_ptr. Avoiding copies.