some C++ cleanup

Recreated from pull request #12