Reworked the reverse lookup to be O(1), and fixed a bug with the ID calculation if every variable is undefined.