C backend: Fix many bugs with records and values