An intern pool implementation, and associated serialization formats.

There are detailed explanations in the comments.