Moved relationship fixup code to a separate class