Rework to use IDs and lazy set init.