let  len         = (tfvec_len . Var.varType) inVec
    let  genlabel       = mkVHDLExtId ("foldlVector" ++ (varToString inVec))
    let  blockLabel  = mkVHDLExtId ("foldlVector" ++ (varToString startVal))
 -  let  nPar        = AST.unsafeVHDLBasicId "n"
    let  range       = AST.ToRange (AST.PrimLit "0") (AST.PrimLit $ show (len-1))
 -  let  genScheme   = AST.ForGn nPar range
 +  let  genScheme   = AST.ForGn (AST.unsafeVHDLBasicId "n") range
    -- Make the intermediate vector
    let  tmpVec      = AST.BDISD $ AST.SigDec (mkVHDLExtId "tmp") vecType Nothing
 -    -- Return the generate functions
 -  let genSm       = AST.GenerateSm genlabel genScheme []  [ AST.CSGSm (genFirstCell entity [startVal, inVec, resVal])
 -                                                          , AST.CSGSm (genOtherCell entity [startVal, inVec, resVal])
 -                                                          , AST.CSGSm (genLastCell entity [startVal, inVec, resVal])
 -                                                          ]
 -  return [AST.CSBSm $ AST.BlockSm blockLabel [] (AST.PMapAspect []) [tmpVec] [AST.CSGSm genSm]]
 +  -- Get the entity name and port names
 +  let entity_id   = ent_id entity
 +  let argports    = map (Monad.liftM fst) (ent_args entity)
 +  let resport     = (Monad.liftM fst) (ent_res entity)
-     -- Return the generate functions
++  -- Return the generate functions
 +  let genSm       = AST.GenerateSm genlabel genScheme [] 
 +                      [ AST.CSGSm (genFirstCell (entity_id, argports, resport) 
 +                                    [startVal, inVec, resVal])
 +                      , AST.CSGSm (genOtherCell (entity_id, argports, resport) 
 +                                    [startVal, inVec, resVal])
 +                      , AST.CSGSm (genLastCell (entity_id, argports, resport) 
 +                                    [startVal, inVec, resVal])
 +                      ]
-   return $ AST.CSBSm $ AST.BlockSm blockLabel [] (AST.PMapAspect []) [tmpVec] [AST.CSGSm genSm]
++  return $ [AST.CSBSm $ AST.BlockSm blockLabel [] (AST.PMapAspect []) [tmpVec] [AST.CSGSm genSm]]
    where
 -    genFirstCell :: Entity -> [CoreSyn.CoreBndr] -> AST.GenerateSm 
 -    genFirstCell entity [startVal, inVec, resVal] = cellGn
 +    genFirstCell (entity_id, argports, resport) [startVal, inVec, resVal] = cellGn
        where
          cellLabel    = mkVHDLExtId "firstcell"
          cellGenScheme = AST.IfGn ((AST.PrimName $ AST.NSimple nPar)  AST.:=: (AST.PrimLit "0"))