Planarians and other flatworms lack organs specialized for gas exchange and circulation. The flat shape of the body places all cells close to the surrounding water, and fine branching of the gastrovascular cavity distributes food throughtout the animal. Nitrogenous waste in the form of ammonia diffuses directly from the cells into the surrounding water. Flatworms also have relatively simple excretory apparatus that function mainly to maintain osmotic balance between the animal and its surroundings. This system consists of ciliated cells called flame cells that waft fluid through branched ducts opening to outside (see FIGURE 40.6). The evolution of osmoregulatory structures was a major factor in allowing some turbellarians to invade freshwater and even moist terrestrial environments.