fixed bugs in serialization