Query planner cleanups.

Including short-circuiting to query terms.