Added checks for bad primary IDs