Tweak algorithms for speed a bit.