                                cudaclaw_cuda_rpn2_t rpn2,
                                cudaclaw_cuda_rpt2_t rpt2,
                                cudaclaw_cuda_b4step2_t b4step2,
-                               int* order, int* mthlim,
+                               int *order_in, int *mthlim_in,
                                double t,double dt)
 {
     typedef cub::BlockReduce<double,FC2D_CUDACLAW_BLOCK_SIZE> BlockReduce;
 
     __shared__ typename BlockReduce::TempStorage temp_storage;
 
+    __shared__ int mthlim[MWAVES];
+    __shared__ int order[2];
+
     extern __shared__ double shared_mem[];
 
     double* start  = shared_mem + mwork*threadIdx.x;
 
-    double* ql     = start;             //meqn
-    double* qr     = ql+meqn;           //meqn
-    double* qd     = qr+meqn;           //meqn
-    double* auxl   = qd+meqn;           //maux
-    double* auxr   = auxl+maux;         //maux
-    double* auxd   = auxr+maux;         //maux
-    double* s      = auxd+maux;         //mwaves
-    double* wave   = s+mwaves;          //meqn*mwaves
-    double* amdq   = wave+meqn*mwaves;  //meqn
-    double* apdq   = amdq+meqn;         //meqn
-    double* bmdq   = apdq+meqn;         //meqn
-    double* bpdq   = bmdq+meqn;         //meqn
-    double* aux1   = bpdq+meqn;         //2*maux
-    double* aux2   = aux1+2*maux;       //2*maux
-    double* aux3   = aux2+2*maux;       //2*maux
-    double* bmasdq = aux3+2*maux;       //meqn
-    double* bpasdq = bmasdq+meqn;       //meqn
+    double* ql     = start;                 /* meqn        */
+    double* qr     = ql     + meqn;         /* meqn        */
+    double* qd     = qr     + meqn;         /* meqn        */
+    double* auxl   = qd     + meqn;         /* maux        */
+    double* auxr   = auxl   + maux;         /* maux        */
+    double* auxd   = auxr   + maux;         /* maux        */
+    double* s      = auxd   + maux;         /* mwaves      */
+    double* wave   = s      + mwaves;       /* meqn*mwaves */
+    double* amdq   = wave   + meqn*mwaves;  /* meqn        */
+    double* apdq   = amdq   + meqn;         /* meqn        */
+    double* bmdq   = apdq   + meqn;         /* meqn        */
+    double* bpdq   = bmdq   + meqn;         /* meqn        */
+    double* aux1   = bpdq   + meqn;         /* 2*maux      */
+    double* aux2   = aux1   + 2*maux;       /* 2*maux      */
+    double* aux3   = aux2   + 2*maux;       /* 2*maux      */
+    double* bmasdq = aux3   + 2*maux;       /* meqn        */
+    double* bpasdq = bmasdq + meqn;         /* meqn        */
 
     int mq, mw, m, k;
     int xs, ys, zs;


        I = (ix + mbc)*xs + (iy + mbc)*ys;

        if (ix < mx && iy < my)   /* Is this needed? */
        {
            for(mq = 0; mq < meqn; mq++)
            {

                    {
                        I_q = I + mq*zs;
                        cqyy = fabs(s[mw])*(1.0 - fabs(s[mw])*dtdy)*wave[mq];

                        gm[I_q] += 0.5*cqyy;   
                        gp[I_q] += 0.5*cqyy;  
                        if (order[1] > 0)
                        {                            
                            bmdq_trans[I_q] += cqyy;     
                            bpdq_trans[I_q] -= cqyy;      
