More work towards the C++ port
Further work on C++ port