Killed the double-free with a shared-ptr