Make UniqueId lookups asynchronous.
Factor out a bit of UniqueId code.
Coding style fixes.

Rename some variables to be consistent with the rest of the code base.
No actual code change.
Refactor the UID assignment process to be fully asynchronous.

This concludes the migration of the UniqueId code to provide
a completely non-blocking interface.