merged duplicated code and also use the link provided in the relationship object (if it exists) before constructing it. fixes #123