Added a simple C interface and did some minor fixing