Moved some stuff for the C implementation around