Fix out-of-bounds bug even when precondition holds.
Put query commands into main mode.
Correctly shutdown linked/monitored actors.
Naming nits (OCD).
Change query result state.

We now keep track of the following bitstream:

    - hits (the non-decreasing stream of results)
    - processed (hits that have already been converted to events)
    - unprocessed (hits - processed)

Each result update also triggers a recomputation of the above quantities. An
update will also set the query seek position to the first unprocessed hit.
Similarly, applying a function over the events in a segment adjust the internal
position to the first unprocessed hit.