[relate] refactor relate helpers.

Remove unused, commented-out code.
Improve the names.