c code major update.  Hopefully its not too broken...