Ported more stuff to C
ported more stuff to C