Fixes for query planner.

Weird things used to happen when we optimize all of the terms out.
Query plan prints out a bit more detail.
We optimize TermFilters a bit more.