 #endif
 }
 
-inline void memcpy2D_out(double* dst, const int pitch_dst, const double* src, const int pitch_src, 
+inline void memcpy2D_out(double* dst, const int pitch_dst, double const * src, const int pitch_src,
 									  const int offset, const size_t width, const int height) {
 	for (int i = 0; i < height; ++i)
 	{
-		memcpy(&dst[i * pitch_dst + offset], &src[i * pitch_src], width);
-	}
-}
-
-inline void memcpy2D_in(double* dst, const int pitch_dst, const double* src, const int pitch_src, 
+		memcpy(&dst[offset], src, width);
+		dst += pitch_dst;
+		src += pitch_src;
+	}
+}
+
+inline void memcpy2D_in(double* dst, const int pitch_dst, double const * src, const int pitch_src,
 									 const int offset, const size_t width, const int height) {
 	for (int i = 0; i < height; ++i)
 	{
-		memcpy(&dst[i * pitch_dst], &src[i * pitch_src + offset], width);
+		memcpy(dst, &src[offset], width);
+		dst += pitch_dst;
+		src += pitch_src;
 	}
 }
 

		//special handling for kernels that would require too much memory

		grid_num = (int)ceil(((double)num_per_kernel) / ((double)TARGET_BLOCK_SIZE));
		int pitch_host_real = num * sizeof(double);
		//first we need temporary copies on the host memory for memory transfer
		double* pres_temp = (double*)malloc(pitch_device);
		double* mass_temp = (double*)malloc(NSP * pitch_device);

			double* pres_mod, double* spec_rates, double* dy, double* jac,
			bool eval_rates)
{
	int grid_num = -1;
	mechanism_memory * d_mem = 0;
	mechanism_memory * h_mem = (mechanism_memory*)malloc(sizeof(mechanism_memory));
	double* dMass = 0;
