By making sure that we always first increment the refcount of the new value before we destroy the old one.