Reorganize and add a C interface.