Restructured and including robust functions.