C++ support changes (+misc fixes) from Paul K.