A lot of cleanup and fixes. Query file now has a bunch of useful examples. More on the way.