Refactor information gain code.