tidy of cgp.c and cgp.h