Make the message walk function altogether cleverer.

It used to always run the entire message list, which is fine if a backend
is holding a hundred messages, but not so much if it's holding a hundred
thousand.  Now it starts with a binary search, and is a generator that
indexes into self.messages itself (which might cause problems because of
its index being invalidated, but we can examine that later...)