Gain and entropy implemented.