convert to C. Fix several compiler warnings.