Fix serialize and deserialize