Further simplify query traits

It is not necessary to deal with the accumulation of values in the query
implementations. It is simpler to pass some callback that handles state changes
by closing over its environment.