Added support for customzing downsampling as well.