The bug came from trying to shallow-copy a mutable structure.
If you modify that, you'll modify all the shallow copies of the header that points to it.