Functions connected to set extraction - moved to mainline.