fix #25823 removal of ties

Added removal of ties that do not have an end element when pasted.

Not sure if I remove the tie in the correct way.