Ok, hmm.. That's a bit awkward since the codec cannot really try to dig out the same duplicate master objects on decode. I guess the right way is to make the encoder identify the master object(s) in a better way, so the decoder then always use the same one.
But the first step would be to find out why there are duplicate masters, and if possible avoid it. E.g. dumping the backtrace from create() should be useful to see where the second one is created.