cleanup cg code
fix prototypes