Revert part of "refactoring, removed shared_ptr" that was erroneous.

This reverts commit 757c23e8916af51017b3c59d2e2a05357edb71f9.