Refactoring and disecting the functionality of CG.
Refactoring and disecting the functionality of CG.

Grokking the specifics of the operation and making some minor changes.
 * don't repeat tests unnecessarily
 * lots of whitespace changes
 * renaming some variables
 * pulling out some expressions into variables.

NProfileAnalysisComputationalTool/npact,victor-lin/npact,victor-lin/npact,victor-lin/npact,victor-lin/npact,NProfileAnalysisComputationalTool/npact,NProfileAnalysisComputationalTool/npact,NProfileAnalysisComputationalTool/npact,NProfileAnalysisComputationalTool/npact,victor-lin/npact