Refactor the relationship parsing.