Added support for changing the downsampling factor.