Some fixes for folding