Additional thread safety fixes.

See also cms-sw/root#34.