C++: Some code cleanup