Changed lookup to take into account external definitions.