Ported Core from C++ to C