Track obj -> id map separately to improve performance.

This hugely speeds up the ics writing, from 60s in id_assign to <<1s.
Memory shouldn't be a problem, as only id(obj) is stored.
Merge branch 'improvment/id_assign_speed' into wip