fixed problems in up/downsampling.