Optimized folding, ref #82