Improved the windowing algorithm.