Improve union serialization