Fix bug in emitFoldM