Fix generic relations

This patch fixes generic relation lookups and autocomplete