An intern pool implementation, and associated serialization formats.

Feel free to pull this one instead of #910.