Add custom serializer for better handling of constraints