Rewrite the handling of program internals.

This is a bit less special-cased, using the same refcounting system as
everything else, and lets us attach string literals to the program
rather than the instance.