cpp and minor fixes