Ports to C. Bugs remain.

Code compiles, but has segmentation faults.