Fixed a bug when inferring IDs.
Possible fix for sync deadlock.