Fix inverse relationships and delete rules