reordered goals in variable lookup code, with significant speedup