Basic smoothing algorithm.