Replaced the imperfect solution for the missing ID problem introduced in
9cc48f99dff42871237051b90cdabab90c13bd30 with a better approach.