first ccode impl
merged from the master