gitignore
don't calculate instances_by_id in every , loop.
include lookup by instance ID.
instances_by_id is never used.