Add support for serialization of primitives and structs