Fixes for thread safety

In the framework, fix some non-const statics.
If one is never modified, declare it const.
If one is modified, and is of a built  in type, make it std::atomic.
In one case, an integer counter was changed to a bool because it was only checked for zero or non-zero.
In some cases, 0 was changed to nullptr.
Also, some minor formatting changes for consistency.
Thested with checkdeps -a and the relval matrix.