Performance improvements and new method: segmented_all_samples