added lexicon and external ref functions, and tested