Add folding from @javipolo's fork