Random helper code, mostly C++.