Improving resampling.
Improved resampling code.