Implement basic serialization logic.