Improved serialization