Add reference discovery logic.