Move the addition of the cached messages inside block so we don't waste time coping messages that will never be transmitted
Correct the useage of the locks
Make sure reachable_entities uses fully qualified names