Fix bug in ID replacement.