Fix reference counting for lookup_ID() usages.

That function refs the ID before returning it, but callers were never
assuming responsibility for that reference.