minor fixes to make C semantics work more correctly

@andreistefanescu @yilongli please review