Code update for -Weffc++
Most code is now -Weffc++ compatible
use a global mutex to ensure bridge environment is correct