The molecular structure of eggs helps explain their valuable properties in cooking. The raw egg contains complex molecules of protein that lie in coils. When the coils are agitated, for example when the eggs are beaten, they unravel into long strands; these form a network of bubbles that stabilize as foam. Whole eggs can be beaten for a long time, but if egg whites are overwhipped, the protein coagulates so much that the whites start to separate.
When an egg is heated, its protein converts into a network of strands that stiffen during cooking. If overcooked, the strands of protein shrink, making the egg tough. In custards, where eggs are mixed with milk or cream, the same principle applies: at the right temperature, the egg cooks, thickening creamily if the custard is whisked, or firmly if it is left unstirred. However, if custard gets too hot, the egg protein starts to shrink, making the custard curdle. Egg whites start to coagulate at temperatures of 145°F/62°C and egg yolks at 155°F/70°C, or slightly higher when diluted with liquid. However, starch interferes with the shrinking action of protein, making it possible to boil custard containing even a small amount of flour or cornstarch.