Some C++ changes

I've begun the process of getting the C++ layer sorted.  It may well be worth doing before and after tests with these changes; they've been fairly intrusive.  Do you have any convenient tests, or is this a forlorn hope.  It compiles, anyway. :smile:

This is probably just a start...