refactoring to remove shared_ptr due to cyclic references - fixed subsequent memory leaks