Finished refactor away from C++ to C