fixed some bugs in text.serialize