Fix a bug in CG.