Fix --disable-stats support.

Fix numerous regressions that were exposed by --disable-stats, both in
the core library and in the tests.
5 files changed