implement GetRelatedById for types.
added some comments.