Optimized serialization.