Revised subsampling code.