Finish porting to C codes.