Optimal window size finding.