Cell balancing implementation from NXP Semiconductors. Link here (PDF)
Batteries made of multiple cells connected in series are often used as a power source for common electronic devices. In multicell battery chains, small differences between the cells (due to production tolerances or operating conditions) tend to be magnified with each charge or discharge cycle. In these situations, weaker cells are overstressed during charging, causing them to become even weaker, until they eventually fail and cause a premature failure of the whole battery. Cell balancing is a way of compensating for these weaker cells by equalizing the charge on all the cells in the chain, thus extending the battery life.