Serialize internal structure.