Fix NPE in handling IDs.