Optimized manual serialization.