bugfix in serialize and serialize_all