c++ code improvements