Fixed bug in serialization