Switched to smarter literal trail data structure

Now about twice as fast and uses 75% of the memory of the previous
version.  However, this version is proportionally less memory
efficient, spending around 30% of its time in garbage collection.