Bugfix C codegen

Tried to refactor but messed up generator state.