Clean up message ID management and interfaces.
Improve performance of generating message IDs.