added support for serializing messages