Convert more code to C