Added in code to build relations between loaded entities.