--- a/blockproc/blockframeaccel.m
+++ b/blockproc/blockframeaccel.m
@@ -36,36 +36,77 @@
    Fo = frameaccel(F,2*Lb);
    Fo.sliwin = kv.sliwin;
 elseif flags.do_segola
-   Fo = frameaccel(F,Lb);
+   % Determine window length without calling frameaccel
+   % Fo = frameaccel(F,Lb);
+   winLen = framefirlen(F);
 
-   if ~isfield(Fo,'winLen')
-      error(['%s: Segment overlap cannot be used with this analysis frame.,'...
+   if winLen==-1
+      error(['%s: Segment overlap cannot be used with this frame.,'...
              ' It does not have FIR windows.'],upper(mfilename));
    end
     
-   switch(Fo.type) 
+   switch(F.type) 
       case {'dgt','dgtreal'}
-         Fo = frameaccel(F,Lb+Fo.winLen-1+Fo.a);
-         assert(Fo.a <= Lb ,['%s: Time step is bigger than the',...
-      ' block length.'],mfilename);
+         Fo = frameaccel(F,Lb+winLen-1+F.a);
       case {'filterbank','filterbankreal','ufilterbank','ufilterbankreal'}
-         Fo = frameaccel(F,Lb+Fo.winLen-1+max(Fo.a(:,1)));
+         lcma =  filterbanklength(1,F.a(:,1));
+         Fo = frameaccel(F,Lb+winLen-1+lcma);
          assert(all(Fo.a(:,2)==1), '%s: Fractional subsampling is not supported',upper(mfilename) );
-         assert(max(Fo.a(:,1)) <= Lb ,['%s: Time step is bigger than the',...
-      ' block length.'],upper(mfilename));
-         Fo.lcma =  filterbanklength(1,F.a);
+         Fo.lcma =  lcma;
       case {'dwilt'}
-         Fo = frameaccel(F,Lb+Fao.winLen-1+2*Fo.M);
+         Fo = frameaccel(F,Lb+winLen-1+2*F.M);
          Fo.a = 2*Fo.M;
       case {'wmdct'}
-         Fo = frameaccel(F,Lb+Fao.winLen-1+Fo.M);
+         Fo = frameaccel(F,Lb+winLen-1+F.M);
          Fo.a = Fo.M;
+      otherwise
+	 error('%s: Unsupported frame for segola.',upper(mfilename));
    end
    
+   % This is important otherwise we would get 0 coefficients for some
+   % blocks.
+   assert(max(Fo.a(:,1)) <= Lb ,['%s: Time step %i is bigger than the',...
+      ' block length %i.'],upper(mfilename),Fo.a,Lb);
+   
+   Fo.winLen = winLen;
 
 
 elseif flags.do_naive
    Fo = frameaccel(F,Lb);
 end
 
-Fo.blockalg = flags.blockalg;+Fo.blockalg = flags.blockalg;
+
+function winLen = framefirlen(F)
+%FRAMEFIRLEN Frame window/filter length
+%
+%   Function returns length of the longest FIR window/filter. The function
+%   returns -1 if the frame does not have FIR windows.
+
+winLen = -1;
+info = [];
+switch(F.type)
+      case {'dgt','dgtreal'}
+        [~, info] =  gabwin(F.g,F.a,F.M,[],F.kv.lt);
+      case {'dwilt','wmdct'}
+        [~, info] = wilwin(F.g,F.M,[],upper(mfilename));
+      case {'filterbank','ufilterbank'}
+        [~, info]  = filterbankwin(F.g,F.a);
+      case {'filterbankreal','ufilterbankreal'}
+        [~, info]  = filterbankwin(F.g,F.a,'real');
+      case 'fwt' 
+        winLen = (F.g.a(1)^F.J-1)/(F.g.a(1)-1)*(numel(F.g.g{1}.h)-1)+1; 
+end;
+
+  
+if ~isempty(info) && isfield(info,'isfir') && info.isfir
+   if isfield(info,'longestfilter')
+      winLen = info.longestfilter;
+   else
+      winLen = max(info.gl);
+   end
+end
+
+
+
+