Hi Bruce,
In quickly reviewing this post, I did a quick search ("OnElementModify AND replace") where this thread "[V8i C++] OnElementModify() and adding Linkage using mdlLinkage_appendUsingDescr()" provides a recommended sequence of modification actions.
HTH,
Bob