fix saving of related entities