Delete unused C code and move some code to Ruby