Put stuff in order and fix some C++ code