minor improvements to id lookup organization
save known IDs to reduce needed queries