Fix #10120: Don't put tags more than once into XMP

This includes some rewrites of helper functions