minor changes to C++ version in prep for optimizations
minor touchups