Speed ups and minor tweaks to sliding window