Understanding the causes of foaming