Various fixes to resampling.