Reworked the xref functions.