serialize() functions should always return a copy of state objects

[#43328491]

It's would be reasonable to stick to this pattern to avoid possible
problems and confusion in the future.