Compilation fix
Ported to C++ (somehow)