speed up sampling, reduce memory use in CIMean