Counting bugfix and configurability enhancement for buffers

Two separate pieces of work here, apologies for the combined PR. The first fixes an edge case counting bug - the patch has been sitting around in FogBugz for several months so I took the opportunity to pull it in.

The second one changes the method we use to decide when to drop a message on the floor. Previously we'd keep buffering until the VM memory exceeded a fixed value. This patch changes the condition to a per-process limit on the _number_ of messages buffered. It also adds the ability to clear the buffer manually. We knowfrom production experience with large clusters that the buffering system can overload a node that rejoins after an absence, so keeping a smaller buffer is likely a smart thing to do here.
Oops indeed, thanks for fixing it up.