use mutex only when necessary;fix documentation