Compiling as C++
C++ conversion tested
Clean up command loop