Excretory system of gastropods

The excretory system of gastropods removes nitrogenous waste and maintains the internal water balance of these creatures, commonly referred to as snails and slugs. The primary organ of excretion is a nephridium.
Structure.
The most primitive gastropods retain two nephridia, but in the great majority of species, the right nephridium has been lost, leaving a single excretory organ, located in the anterior part of the visceral mass. The nephridium projects into the main venous sinus in the animal's foot. The circulatory fluid of gastropods, known as haemolymph directly bathes the tissues, where it supplies them with oxygen and absorbs carbon dioxide and nitrogenous waste, a necessary waste product of metabolism. From the arterial sinuses bathing the tissues, it drains into the venous sinus, and thus flows past the nephridium.
The main body cavity of most aquatic gastropods also includes pericardial glands, often located above the heart. These secrete waste into the haemolymph, prior to further filtration in the nephridium. Pulmonates lack these glands, so that the nephridium is the only major organ of excretion.
In some gastropods, the nephridium opens directly into the sinus, but more usually, there is a small duct, referred to as the renopericardial canal. In aquatic gastropods, the nephridium is drained by a ureter that opens near the rear of the mantle cavity. This allows the flow of water through the cavity to flush out the excreta. Terrestrial pulmonates instead have a much longer ureter, that opens near the anus. 
In addition to the pericardial glands and nephridum, excretory cells are also present in the digestive glands opening into the stomach. These glands have a metabolic function, somewhat similar to that of the vertebrate liver, and excrete waste products directly into the digestive system, where it is voided with the faeces.
Water balance.
In aquatic gastropods, the waste product is invariably ammonia, which rapidly dissolves in the surrounding water. In the case of freshwater species, the nephridium also resorbs a significant amount of salt in order to prevent its loss through osmosis into the surrounding water.
Terrestrial species instead excrete insoluble uric acid, which allows them to maintain their internal water balance. Even so, most species require a somewhat humid environment, and secrete a considerable amount of water in their slime trail. Those few species that dwell in arid environments typically hibernate or aestivate during dry periods to preserve moisture.