Added serializing function.