The foam structure will decrease slightly or collapse in order to form a solid foam of less volume. This occurs while the cake is still baking, not when it is cooling. The combination of protein denaturation and starch gelatinization determines whether the cake will set or collapse. When proteins denature, they are not in a stable state. In order to stabilize, the denatured proteins will aggregate around air bubbles and within the continuous phase of the batter. The aggregation and overlapping of the proteins forms a very stable network.