Optimized serialize