Serialization modified to work also with arrays