C++ missing parenthensis and fixed memory leaks