Bulk up the library functions

Types are now registered. They're indexed by name although that's
precarious because of the risk of name clashes. We're also recording a
mapping of streamId to name so that locally referenced Ids can be
resolved.