Some space optimizations.

There is definitely room for improvement, but this is much more space efficient
than previous.

I also cleaned up the interface for discovery so that there is no longer a need
to merge two libraries, you can discover on top of an old one.

I also fixed a bug with multi gadget predicates clobbering each other.