Add key_by, update _instances_with_id_as_key