Moving more C++ code from the old branch into the main trunk.
Authored by: debug 2009-07-03
Parent: [r5452]
Child: [r5454]