Fix errors in C code and add a cache version.  It passes the tests and works.