cleanup cg code
restructure header files