Add support for removing empty lists of samples in an MT-safe way.