Optimizations to folding.