improve the schema to save references correctly on patch