added reference discovery mechanism, which includes REF_CACHE and
REF_PATH env variables.