Track obj -> id map separately to improve performance.

This hugely speeds up the ics writing, from 60s in id_assign to <<1s.