diff --git a/drivers/iohb.c b/drivers/iohb.c
index bc0cb95bbefe46ad1667d51974fd66d3da70b428..e4afcb9f9b41a2fc82fab9423834707131180c81 100644
--- a/drivers/iohb.c
+++ b/drivers/iohb.c
@@ -1344,7 +1344,7 @@ int writeHB_mat_char(const char* filename, int M, int N,
     int Ptrperline, Ptrwidth, Indperline, Indwidth;
     int Rhsperline, Rhswidth, Rhsprec;
     char Rhsflag;
-    int Valperline, Valwidth, Valprec;
+    int Valperline=0, Valwidth, Valprec;
     char Valflag;           /* Indicates 'E','D', or 'F' float format */
     char pformat[16],iformat[16],vformat[19],rformat[19];
 
diff --git a/spm.c b/spm.c
index 8614efacaba957bb68b873e9f273baf12916e411..bc015845f214018fcab286f1b0bf8c7151933ea2 100644
--- a/spm.c
+++ b/spm.c
@@ -845,13 +845,13 @@ spmPrintInfo( const pastix_spm_t* spm, FILE *stream )
             mtxtypestr[mtxtype],
             flttypestr[flttype],
             fmttypestr[fmttype],
-            spm->gN, spm->gnnz );
+            (long)spm->gN, (long)spm->gnnz );
 
     if ( spm->dof != 1 ) {
         if ( spm->dof > 1 ) {
             fprintf(stream,
                     "  Dof:          %ld\n",
-                    spm->dof );
+                    (long)spm->dof );
         }
         else {
             fprintf(stream,
@@ -861,7 +861,7 @@ spmPrintInfo( const pastix_spm_t* spm, FILE *stream )
         fprintf(stream,
                 "  N expanded:   %ld\n"
                 "  NNZ expanded: %ld\n",
-                spm->gNexp, spm->gnnzexp );
+                (long)spm->gNexp, (long)spm->gnnzexp );
     }
 }
 
@@ -1076,12 +1076,12 @@ spmMatVec(const pastix_trans_t trans,
  *
  *******************************************************************************/
 int
-spmGenRHS( int type, int nrhs,
+spmGenRHS( pastix_rhstype_t type, int nrhs,
            const pastix_spm_t  *spm,
            void                *x, int ldx,
            void                *b, int ldb )
 {
-    static int (*ptrfunc[4])(int, int,
+    static int (*ptrfunc[4])(pastix_rhstype_t, int,
                              const pastix_spm_t *,
                              void *, int, void *, int) =
         {
diff --git a/spm.h b/spm.h
index c3d059ca7ca777264206e0603f5efd8075202dad..2f1111835bda43d16fe64bff6f0aeb13a5c158da 100644
--- a/spm.h
+++ b/spm.h
@@ -53,6 +53,16 @@ typedef enum pastix_driver_e {
     /* PastixDriverBRGMD,      /\**< Not supported yet *\/ */
 } pastix_driver_t;
 
+/**
+ * @brief How to generate RHS
+ */
+typedef enum pastix_rhstype_e {
+    PastixRhsOne,
+    PastixRhsI,
+    PastixRhsRndX,
+    PastixRhsRndB
+} pastix_rhstype_t;
+
 /**
  *
  * @brief The sparse matrix data structure
@@ -87,7 +97,7 @@ typedef struct pastix_spm_s {
                                     otherwise, irregular degree of freedom (refer to dofs)         */
     pastix_int_t     *dofs;    /**< Array of the first column of each element in the
                                     expanded matrix [+baseval]                                     */
-    pastix_order_t    layout;  /**< PastixColMajor, or PastixRowMajor                              */
+    pastix_layout_t   layout;  /**< PastixColMajor, or PastixRowMajor                              */
 
     pastix_int_t     *colptr;  /**< List of indirections to rows for each vertex [+baseval]        */
     pastix_int_t     *rowptr;  /**< List of edges for each vertex [+baseval]                       */
@@ -131,7 +141,7 @@ pastix_spm_t *spmCheckAndCorrect( pastix_spm_t *spm );
  * @name SPM subroutines to check factorization/solve
  * @{
  */
-int           spmGenRHS( int type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
+int           spmGenRHS( pastix_rhstype_t type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
 int           spmCheckAxb( int nrhs, const pastix_spm_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx );
 
 /**
diff --git a/spm_read_driver.c b/spm_read_driver.c
index 5233420eb82a9f165f913110515db820429d86a6..7eba99631461423e0a5b4d01a9b94815ed04e87a 100644
--- a/spm_read_driver.c
+++ b/spm_read_driver.c
@@ -152,13 +152,9 @@ spmReadDriver( pastix_driver_t  driver,
 
     if ( mpiinit )
     {
-        pastix_int_t nnz;
+        pastix_int_t nnz = spm->nnz;
 
-        if (mpirank == 0) {
-            nnz = spm->nnz;
-        }
-
-        MPI_Bcast( spm, 2*sizeof(int)+3*sizeof(pastix_int_t), MPI_CHAR, 0, comm );
+        MPI_Bcast( spm, sizeof(pastix_spm_t), MPI_CHAR, 0, comm );
         MPI_Bcast( &nnz, 1, PASTIX_MPI_INT, 0, comm );
 
         fprintf(stderr, "%d: mtxtype=%d, flttype=%d, nnz=%ld, gN=%ld\n",
diff --git a/z_spm.h b/z_spm.h
index caa7cf9a5fd3229ee37911ad5e21a2a7a96e320a..53c67c36f68377cf93b397652c99e839e921837f 100644
--- a/z_spm.h
+++ b/z_spm.h
@@ -57,7 +57,7 @@ void         z_spmSort( pastix_spm_t *spm );
 pastix_int_t z_spmMergeDuplicate( pastix_spm_t *spm );
 pastix_int_t z_spmSymmetrize( pastix_spm_t *spm );
 
-int z_spmGenRHS(int type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
+int z_spmGenRHS(pastix_rhstype_t type, int nrhs, const pastix_spm_t *spm, void *x, int ldx, void *b, int ldb );
 int z_spmCheckAxb( int nrhs, const pastix_spm_t *spm, void *x0, int ldx0, void *b, int ldb, const void *x, int ldx );
 
 /**
diff --git a/z_spm_expand.c b/z_spm_expand.c
index 9e62c153c52af01eb664dffd44c286be755658c4..ecbcb8498832682111e982aeeb134712ebe37562 100644
--- a/z_spm_expand.c
+++ b/z_spm_expand.c
@@ -414,7 +414,7 @@ z_spmIJVExpand(const pastix_spm_t *spm)
     pastix_spm_t       *newspm;
     pastix_int_t        i, j, k, ii, jj, dofi, dofj, col, row, baseval;
     pastix_int_t       *newcol, *newrow, *oldcol, *oldrow, *dofs;
-    pastix_complex64_t *newval, *oldval;
+    pastix_complex64_t *newval, *oldval=NULL;
 
     assert( spm->fmttype == PastixIJV );
     assert( spm->flttype == PastixComplex64 );
diff --git a/z_spm_genrhs.c b/z_spm_genrhs.c
index 248a01eef6ecad13de25b5caa146a5531624d70c..0876c435c6633856c3a682d77f4f63713679190e 100644
--- a/z_spm_genrhs.c
+++ b/z_spm_genrhs.c
@@ -193,7 +193,7 @@ z_spmRndVect( double scale, int m, int n, pastix_complex64_t *A, int lda,
  *
  *******************************************************************************/
 int
-z_spmGenRHS( int type, int nrhs,
+z_spmGenRHS( pastix_rhstype_t type, int nrhs,
              const pastix_spm_t  *spm,
              void                *x, int ldx,
              void                *b, int ldb )