Gave the code a lil' shave.
Refactoring into C with C++ wrapper.