function WP = get_small_in_window(XP,big,ii,RW)
  # Fill window array {WP} with up to {2*RW+1}
  # non-big window elements around {ii}.
  
  assert(size(XP,2)==1)
  assert(size(big,2)==1)
  assert(size(XP,1)==size(big,1))
  NP = size(XP,1);
  
  NW = 2*RW + 1;
  WP = zeros(NW,1);
  nw = 0; # Number of elements added to window.
  for idir = 0:1
    dir = 2*idir - 1;
    if dir == -1
      jj = ii; mwmax = RW + 1;
    else
      jj = ii+1; mwmax = RW;
    end;
    mw = 0;
    while (jj >= 1) && (jj <= NP) && (mw < mwmax)
      if ! big(jj,1)
        v2 = XP(jj,1);
        if (jj == 1) || (jj == NP)
          v2 = 2*v2; # Correction for freq 0 and max.
        end
        nw = nw + 1;
        assert(nw <= NW)
        WP(nw,1) = v2;
        mw = mw + 1;
      end
      jj = jj + dir;
    end
  end
  assert(nw > 0);
  WP = WP(1:nw,1);