I think this fixes the queries bug.  I was using a hash table and expecting structural equality.  Switched to a set (albeit with a dumb comparator atm).