Incorporated shared_pointer to perform object cleanup