Use shared_ptr's to prevent scope loss from closing db results