Expose serialization function.