Malpighian tubule system
The Malpighian tubule system is a type of excretory and osmoregulatory system found in some insects, myriapods, arachnids and tardigrades. The system consists of branching tubules extending from the alimentary canal that absorbs solutes, water, and wastes from the surrounding hemolymph. The wastes then are released from the organism in the form of solid nitrogenous compounds and calcium oxalate. The system is named after Marcello Malpighi, a seventeenth-century anatomist. Structure. Malpighian tubules are slender tubes normally found in the posterior regions of arthropod alimentary canals. Each tubule consists of a single layer of cells that is  closed off at the distal end with the proximal end joining the alimentary canal at the junction between the midgut and hindgut. Most tubules are normally highly convoluted. The number of tubules varies between species although most occur in multiples of two. Tubules are usually bathed in hemolymph and are in proximity to fat body tissue. They contain actin for structural support and microvilli for propulsion of substances along the tubules. Malpighian tubules in most insects also contain accessory musculature associated with the tubules which may function to mix the contents of the tubules or expose the tubules to more  hemolymph. The insect orders, Dermaptera and Thysanoptera do not possess these muscles and Collembola and Hemiptera:Aphididae completely lack a Malpighian tubule system. General mode of action. Pre-urine is formed in the tubules, when nitrogenous waste and electrolytes are transported through the tubule walls. Wastes such as urea and amino acids are thought to diffuse through the walls, while ions such as sodium and potassium are transported by active pump mechanisms. Water follows thereafter. The pre-urine, along with digested food, merge in the hindgut. At this time, uric acid precipitates out, and sodium and potassium ions are actively  absorbed by the rectum, along with water via osmosis. Uric acid is left to mix with feces, which are then excreted. Alternative modes of action. Complex cycling systems of Malpighian tubules have been described in other insect orders. Hemipteran insects use tubules that permit movement of solutes into the distal portion of the tubules while reabsorption of water and essential ions directly to the hemolymph occurs in the proximal portion and the rectum. Both Coleoptera and Lepidoptera use a cryptonephridial arrangement where the distal end of the tubules are embedded in fat tissue surrounding the rectum. Such an arrangement may  serve to increase the efficiency of solute processing in the Malpighian tubules. Other uses. Although primarily involved in excretion and osmoregulation, Malpighian tubules have been modified in some insects to serve accessory functions. Larvae of all species in genus Arachnocampa use modified and swollen Malpighian tubules to produce a blue-green light attracting prey towards mucus-coated trap lines. In insects which feed on plant material containing noxious allelochemicals, Malpighian tubules also serve to rapidly excrete such compounds from the hemolymph.