tidy up debug messages
use two mutex locks