Fix error when saving relations