cleanup cg code