Index: trunk/psLib/src/math/psMinimizeLMM.c
===================================================================
--- trunk/psLib/src/math/psMinimizeLMM.c	(revision 9640)
+++ trunk/psLib/src/math/psMinimizeLMM.c	(revision 9730)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-14 00:15:47 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -163,7 +163,5 @@
     psImage  *Alpha  = psImageAlloc (params->n, params->n, PS_TYPE_F64);
     psVector *beta   = psVectorAlloc(params->n, PS_TYPE_F64);
-    beta->n = beta->nalloc;
     psVector *Params = psVectorAlloc(params->n, PS_TYPE_F64);
-    Params->n = Params->nalloc;
     psVector *dy     = NULL;
     psBool rc = true;
@@ -175,5 +173,4 @@
     } else {
         dy = psVectorAlloc(y->n, PS_TYPE_F32);
-        dy->n = dy->nalloc;
         psVectorInit(dy, 1.0);
     }
@@ -246,5 +243,4 @@
     psF64 ymodel;
     psVector *deriv = psVectorAlloc(params->n, PS_TYPE_F32);
-    deriv->n = deriv->nalloc;
 
     // zero alpha and beta for summing below
@@ -380,9 +376,6 @@
     psImage *Alpha   = psImageAlloc(params->n, params->n, PS_TYPE_F64);
     psVector *beta   = psVectorAlloc(params->n, PS_TYPE_F64);
-    beta->n = beta->nalloc;
     psVector *Beta   = psVectorAlloc(params->n, PS_TYPE_F64);
-    beta->n = beta->nalloc;
     psVector *Params = psVectorAlloc(params->n, PS_TYPE_F32);
-    Params->n = Params->nalloc;
     psVector *dy     = NULL;
     psF64 Chisq = 0.0;
@@ -398,5 +391,4 @@
     } else {
         dy = psVectorAlloc(y->n, PS_TYPE_F32);
-        dy->n = dy->nalloc;
         psVectorInit(dy, 1.0);
     }
Index: trunk/psLib/src/math/psMinimizePolyFit.c
===================================================================
--- trunk/psLib/src/math/psMinimizePolyFit.c	(revision 9640)
+++ trunk/psLib/src/math/psMinimizePolyFit.c	(revision 9730)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-19 02:57:18 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -46,5 +46,4 @@
 #define PS_VECTOR_GEN_CHEBY_INDEX(VEC, SIZE, TYPE) \
 VEC = psVectorAlloc(SIZE, TYPE); \
-VEC->n = VEC->nalloc; \
 if (TYPE == PS_TYPE_F64) { \
     for (psS32 i = 0 ; i < SIZE ; i++) { \
@@ -93,8 +92,7 @@
     if (sums == NULL) {
         sums = psVectorAlloc(nSum, PS_TYPE_F64);
-        sums->n = sums->nalloc;
     } else if (nSum > sums->n) {
         sums = psVectorRealloc(sums, nSum);
-        sums->n = sums->nalloc;
+        sums->n = nSum;
     }
 
@@ -333,5 +331,4 @@
     psImage *A = psImageAlloc(numTerms, numTerms, PS_TYPE_F64); // Least-squares matrix
     psVector *B = psVectorAlloc(numTerms, PS_TYPE_F64); // Least-squares vector
-    B->n = numTerms;
     psImageInit(A, 0.0);
     psVectorInit(B, 0.0);
@@ -509,5 +506,4 @@
     psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
     psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
-    B->n = B->nalloc;
 
     // Initialize data structures.
@@ -805,5 +801,4 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
-    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -976,5 +971,4 @@
     psImage *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
     psVector *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
-    B->n = B->nalloc;
 
     // Initialize data structures.
@@ -1256,5 +1250,4 @@
     }
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
-    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -1434,5 +1427,4 @@
     psImage    *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
     psVector   *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
-    B->n = B->nalloc;
 
     // Initialize data structures.
@@ -1790,5 +1782,4 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
-    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
@@ -1967,5 +1958,4 @@
     psImage    *A = psImageAlloc(nTerm, nTerm, PS_TYPE_F64); // Least-squares matrix
     psVector   *B = psVectorAlloc(nTerm, PS_TYPE_F64); // Least-squares vector
-    B->n = B->nalloc;
 
     // Initialize data structures.
@@ -2368,5 +2358,4 @@
     psVector *fit   = NULL;
     psVector *resid = psVectorAlloc(f->n, PS_TYPE_F64);
-    resid->n = resid->nalloc;
 
     // eventual expansion: user supplies one of various stats option pairs,
Index: trunk/psLib/src/math/psMinimizePowell.c
===================================================================
--- trunk/psLib/src/math/psMinimizePowell.c	(revision 9640)
+++ trunk/psLib/src/math/psMinimizePowell.c	(revision 9730)
@@ -11,6 +11,6 @@
  *  NOTE: XXX: The SDR is silent about data types.  F32 is implemented here.
  *
- *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:04:58 $
+ *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -549,7 +549,5 @@
                 ((psVector *) (v->data[i]))->data.F32[j] = 0.0;
             }
-            ((psVector *)(v->data[i]))->n++;
-        }
-        v->n++;
+        }
     }
 
Index: trunk/psLib/src/math/psPolynomial.c
===================================================================
--- trunk/psLib/src/math/psPolynomial.c	(revision 9640)
+++ trunk/psLib/src/math/psPolynomial.c	(revision 9730)
@@ -7,6 +7,6 @@
 *  polynomials.  It also contains a Gaussian functions.
 *
-*  @version $Revision: 1.151 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-13 22:04:58 $
+*  @version $Revision: 1.152 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -266,5 +266,4 @@
         // General case where the Chebyshev poly has 2 or more terms.
         d = psVectorAlloc(nTerms, PS_TYPE_F64);
-        d->n = d->nalloc;
         if(poly->mask[nTerms-1] == 0) {
             d->data.F64[nTerms-1] = poly->coeff[nTerms-1];
@@ -571,32 +570,4 @@
     psTrace("psLib.math", 4, "---- %s() end ----\n", __func__);
     return(tmp * exp(-((x - mean) * (x - mean)) / (2.0 * sigma * sigma)));
-}
-
-/*****************************************************************************
-    p_psGaussianDev()
- This private routine (formerly a psLib API routine) creates a psVector of the
- specified size and type F32 and fills it with a random Gaussian distribution
- of numbers with the specified mean and sigma.
- 
-XXX: It's possible to have a different seed everytime.  However, for now,
-for testability, we use a common seed.
- *****************************************************************************/
-#define PS_XXX_GAUSSIAN_SEED 1995
-psVector* p_psGaussianDev(psF32 mean,
-                          psF32 sigma,
-                          unsigned int Npts)
-{
-    PS_ASSERT_INT_NONNEGATIVE(Npts, NULL);
-
-    //    psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, p_psRandomGetSystemSeed());
-    psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, PS_XXX_GAUSSIAN_SEED);
-    psVector* gauss = psVectorAlloc(Npts, PS_TYPE_F32);
-    for (unsigned int i = 0; i < Npts; i++) {
-        gauss->data.F32[i] = mean + p_psRandomGaussian(r, sigma);
-        gauss->n++;
-    }
-    psFree(r);
-
-    return(gauss);
 }
 
@@ -808,5 +779,4 @@
         for (unsigned int i=0;i<x->n;i++) {
             tmp->data.F64[i] = psPolynomial1DEval(poly, x->data.F64[i]);
-            tmp->n++;
         }
         break;
@@ -815,5 +785,4 @@
         for (unsigned int i=0;i<x->n;i++) {
             tmp->data.F32[i] = psPolynomial1DEval(poly, x->data.F32[i]);
-            tmp->n++;
         }
         break;
@@ -877,5 +846,4 @@
         for (unsigned int i=0; i<vecLen; i++) {
             tmp->data.F32[i] = psPolynomial2DEval(poly,x->data.F32[i],y->data.F32[i]);
-            tmp->n++;
         }
         break;
@@ -892,5 +860,4 @@
         for (unsigned int i=0; i<vecLen; i++) {
             tmp->data.F64[i] = psPolynomial2DEval(poly,x->data.F64[i],y->data.F64[i]);
-            tmp->n++;
         }
         break;
@@ -959,5 +926,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
@@ -966,5 +932,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -973,5 +938,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -980,5 +944,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -987,5 +950,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -994,5 +956,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1001,5 +962,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1008,5 +968,4 @@
             tmp->data.F64[i] = psPolynomial3DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F64[i]);
-            tmp->n++;
         }
     }
@@ -1079,5 +1038,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F32[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
@@ -1086,5 +1044,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F32[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
@@ -1093,5 +1050,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F64[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F32)
@@ -1100,5 +1056,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F32[i], z->data.F64[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -1107,5 +1062,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F32[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -1114,5 +1068,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F32[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -1121,5 +1074,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F64[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F32) && (y->type.type == PS_TYPE_F64)
@@ -1128,5 +1080,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F32[i],
                                                   y->data.F64[i], z->data.F64[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -1135,5 +1086,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F32[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -1142,5 +1092,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F32[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -1149,5 +1098,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F64[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F32)
@@ -1156,5 +1104,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F32[i], z->data.F64[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1163,5 +1110,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F32[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1170,5 +1116,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F32[i], t->data.F64[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1177,5 +1122,4 @@
             tmp->data.F64[i] = psPolynomial4DEval(poly, x->data.F64[i],
                                                   y->data.F64[i], z->data.F64[i], t->data.F32[i]);
-            tmp->n++;
         }
     } else if ((x->type.type == PS_TYPE_F64) && (y->type.type == PS_TYPE_F64)
@@ -1185,5 +1129,4 @@
                                                   y->data.F64[i], z->data.F64[i],
                                                   t->data.F64[i]);
-            tmp->n++;
         }
     }
Index: trunk/psLib/src/math/psPolynomial.h
===================================================================
--- trunk/psLib/src/math/psPolynomial.h	(revision 9640)
+++ trunk/psLib/src/math/psPolynomial.h	(revision 9730)
@@ -11,6 +11,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-06-30 02:20:06 $
+ *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -45,16 +45,4 @@
     float sigma,                       ///< Standard deviation for the Gaussian
     bool normal                        ///< Indicates whether result should be normalized
-);
-
-/** Produce a vector of random numbers from a Gaussian distribution with
- *  the specified mean and sigma
- *
- *  @return psVector*    vector of random numbers
- *
- */
-psVector* p_psGaussianDev(
-    psF32 mean,                        ///< The mean of the Gaussian
-    psF32 sigma,                       ///< The sigma of the Gaussian
-    unsigned int Npts                  ///< The size of the vector
 );
 
Index: trunk/psLib/src/math/psSparse.c
===================================================================
--- trunk/psLib/src/math/psSparse.c	(revision 9640)
+++ trunk/psLib/src/math/psSparse.c	(revision 9730)
@@ -35,17 +35,12 @@
     psMemSetDeallocator(sparse, (psFreeFunc)sparseFree);
 
-    sparse->Aij = psVectorAlloc(Nelem, PS_DATA_F32);
-    sparse->Si  = psVectorAlloc(Nelem, PS_DATA_S32);
-    sparse->Sj  = psVectorAlloc(Nelem, PS_DATA_S32);
-
-    sparse->Aij->n = 0;
-    sparse->Si->n  = 0;
-    sparse->Sj->n  = 0;
+    sparse->Aij = psVectorAllocEmpty(Nelem, PS_DATA_F32);
+    sparse->Si  = psVectorAllocEmpty(Nelem, PS_DATA_S32);
+    sparse->Sj  = psVectorAllocEmpty(Nelem, PS_DATA_S32);
+
     sparse->Nelem = 0;
 
     sparse->Bfj = psVectorAlloc(Nrows, PS_DATA_F32);
     sparse->Qii = psVectorAlloc(Nrows, PS_DATA_F32);
-    sparse->Bfj->n = Nrows;
-    sparse->Qii->n = Nrows;
 
     sparse->Nrows = Nrows;
@@ -157,5 +152,4 @@
     // temporary storage for intermediate results
     psVector *dQ = psVectorAlloc(output->n, PS_DATA_F32);
-    dQ->n = output->n;
 
     for (int j = 0; j < Niter; j++) {
@@ -197,5 +191,4 @@
     psVector *tSi  = psVectorAlloc(Nelem, PS_DATA_S32);
     psVector *tSj  = psVectorAlloc(Nelem, PS_DATA_S32);
-    tAij->n = tSi->n = tSj->n = Nelem;
 
     for (int i = 0; i < Nelem; i++) {
Index: trunk/psLib/src/math/psSpline.c
===================================================================
--- trunk/psLib/src/math/psSpline.c	(revision 9640)
+++ trunk/psLib/src/math/psSpline.c	(revision 9730)
@@ -6,6 +6,6 @@
 *  This file contains the routines that allocate, free, and evaluate splines.
 *
-*  @version $Revision: 1.155 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-10-13 22:04:58 $
+*  @version $Revision: 1.156 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-10-24 22:52:56 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -239,10 +239,8 @@
             for (psS32 i = 0 ; i < x->n ; i++) {
                 spline->knots->data.F32[i] = x->data.F32[i];
-                spline->knots->n++;
             }
         } else if (x->type.type == PS_TYPE_F64) {
             for (psS32 i = 0 ; i < x->n ; i++) {
                 spline->knots->data.F32[i] = (psF32) x->data.F64[i];
-                spline->knots->n++;
             }
         }
@@ -250,5 +248,4 @@
         for (psS32 i = 0 ; i < y->n ; i++) {
             spline->knots->data.F32[i] = (psF32) i;
-            spline->knots->n++;
         }
     }
@@ -415,10 +412,8 @@
         for (psS32 i=0;i<x->n;i++) {
             tmpVector->data.F32[i] = psSpline1DEval(spline, x->data.F32[i]);
-            tmpVector->n++;
         }
     } else if (x->type.type == PS_TYPE_F64) {
         for (psS32 i=0;i<x->n;i++) {
             tmpVector->data.F32[i] = psSpline1DEval(spline, (psF32) x->data.F64[i]);
-            tmpVector->n++;
         }
     }
Index: trunk/psLib/src/math/psStats.c
===================================================================
--- trunk/psLib/src/math/psStats.c	(revision 9640)
+++ trunk/psLib/src/math/psStats.c	(revision 9730)
@@ -16,6 +16,6 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.187 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:04:58 $
+ *  @version $Revision: 1.188 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-10-24 22:52:56 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -388,5 +388,5 @@
 
     // Allocate temporary vectors for the data.
-    psVector* vector = psVectorAlloc(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values
+    psVector* vector = psVectorAllocEmpty(myVector->n, PS_TYPE_F32); // Vector containing the unmasked values
     long count = 0;                     // Number of valid entries
 
@@ -486,5 +486,4 @@
     long numBins = histogram->nums->n;  // Number of histogram bins
     psVector *smooth = psVectorAlloc(numBins, PS_TYPE_F32); // Smoothed version of histogram bins
-    smooth->n = smooth->nalloc;
     const psVector *bounds = histogram->bounds; // The bounds for the histogram bins
 
@@ -723,5 +722,4 @@
     // We copy the mask vector, to preserve the original
     psVector *tmpMask = psVectorAlloc(myVector->n, PS_TYPE_U8);
-    tmpMask->n = tmpMask->nalloc;
     psVectorInit(tmpMask, 0);
     if (maskVector) {
@@ -901,6 +899,4 @@
     psVector *x = psVectorAlloc(3, PS_TYPE_F64);
     psVector *y = psVectorAlloc(3, PS_TYPE_F64);
-    x->n = 3;
-    y->n = 3;
     psF32 tmpFloat = 0.0f;
 
@@ -1066,5 +1062,4 @@
 
     psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_MASK); // The actual mask we will use
-    mask->n = myVector->n;
     psVectorInit(mask, 0);
     if (maskVector) {
@@ -1487,10 +1482,7 @@
         psVector *y = psVectorAlloc((1 + (binMax - binMin)), PS_TYPE_F32); // Vector of coordinates
         psArray *x = psArrayAlloc((1 + (binMax - binMin))); // Array of ordinates
-        y->n = y->nalloc;
-        x->n = x->nalloc;
         for (long i = binMin, j = 0; i <= binMax ; i++, j++) {
             y->data.F32[j] = smoothed->data.F32[i];
             psVector *ordinate = psVectorAlloc(1, PS_TYPE_F32); // The ordinate value
-            ordinate->n = 1;
             ordinate->data.F32[0] = PS_BIN_MIDPOINT(histogram, i);
             x->data[j] = ordinate;
@@ -1521,5 +1513,4 @@
         psMinimization *minimizer = psMinimizationAlloc(100, 0.01); // The minimizer information
         psVector *params = psVectorAlloc(2, PS_TYPE_F32); // Parameters for the Gaussian
-        params->n = params->nalloc;
         // Initial guess for the mean (index 0) and standard dev (index 1).
         params->data.F32[0] = stats->robustMedian;
@@ -1654,5 +1645,4 @@
     psVector* newBounds = psVectorAlloc(n + 1, PS_TYPE_F32);
     newHist->bounds = newBounds;
-    newBounds->n = newHist->bounds->nalloc;
 
     // Calculate the bounds for each bin.
@@ -1666,8 +1656,5 @@
     // Allocate the bins, and initialize them to zero.
     newHist->nums = psVectorAlloc(n, PS_TYPE_F32);
-    for (long i = 0; i < newHist->nums->nalloc; i++) {
-        newHist->nums->data.F32[i] = 0.0;
-        newHist->nums->n++;
-    }
+    psVectorInit(newHist->nums, 0.0);
 
     // Initialize the other members.
@@ -1699,18 +1686,11 @@
     psHistogram *newHist = (psHistogram* ) psAlloc(sizeof(psHistogram)); // The new histogram structure
     psMemSetDeallocator(newHist, (psFreeFunc) histogramFree);
-    psVector* newBounds = psVectorAlloc(bounds->n, PS_TYPE_F32);
+    psVector* newBounds = psVectorCopy(NULL, bounds, PS_TYPE_F32);
     newHist->bounds = newBounds;
-    newBounds->n = newHist->bounds->nalloc;
-    for (long i = 0; i < bounds->n; i++) {
-        newBounds->data.F32[i] = bounds->data.F32[i];
-    }
 
     // Allocate the bins, and initialize them to zero.  If there are N bounds,
     // then there are N-1 bins.
     newHist->nums = psVectorAlloc((bounds->n) - 1, PS_TYPE_F32);
-    for (long i = 0; i < newHist->nums->nalloc; i++) {
-        newHist->nums->data.F32[i] = 0.0;
-        newHist->nums->n++;
-    }
+    psVectorInit(newHist->nums, 0.0);
 
     // Initialize the other members.
