 
     int Am = (side == CUBLAS_SIDE_LEFT) ? m : n;
     //if B is not already in, copy in B block
-    if(!Bin)
-      check_error( status = cublasSetMatrixAsync( m, n, sizeof(T), Bc, incB, Bd, incB, strIn ), status);
+    if(!BIsIn)
+      check_error( status = cublasSetMatrixAsync( m, n, sizeof(T), h_B, incB, d_B, incB, strIn ), status);
     //copy in A block
-    check_error( status = cublasSetMatrixAsync( Am, Am, sizeof(T), Ac, incA, Ad, incA, strIn ), status);
+    check_error( status = cublasSetMatrixAsync( Am, Am, sizeof(T), h_A, incA, d_A, incA, strIn ), status);
     //wait for data to arrive
-    check_error( cudaEventRecord(eAin, strIn), CUBLAS_STATUS_INTERNAL_ERROR);
-    check_error( cudaStreamWaitEvent(strComp, eAin, 0), CUBLAS_STATUS_INTERNAL_ERROR);
+    check_error( cudaEventRecord(eDataIn, strIn), CUBLAS_STATUS_INTERNAL_ERROR);
+    check_error( cudaStreamWaitEvent(strComp, eDataIn, 0), CUBLAS_STATUS_INTERNAL_ERROR);
   
     if( (status = Xtrmm( handle,
                          side, uplo, trans, diag,
                          m, n,
-                         alpha, Ad, incA,
-                                Bd, incB ) ) != CUBLAS_STATUS_SUCCESS ) return status;
-
-    //if stream is done computing and Bout, copy B back.
-    if(Bout){
+                         alpha, d_A, incA,
+                                d_B, incB ) ) != CUBLAS_STATUS_SUCCESS ) return status;
+
+    //if stream is done computing and getBOut, copy B back.
+    if(getBOut){
       check_error( cudaEventRecord(eComp, strComp), CUBLAS_STATUS_INTERNAL_ERROR);
       check_error( cudaStreamWaitEvent(strOut, eComp, 0), CUBLAS_STATUS_INTERNAL_ERROR);
-      check_error( status = cublasGetMatrixAsync( m, n, sizeof(T), Bd, incB, Bc, incB, strOut), status);
+      check_error( status = cublasGetMatrixAsync( m, n, sizeof(T), d_B, incB, h_B, incB, strOut), status);
     }
   }else
   if(side == CUBLAS_SIDE_LEFT){

  int AsyncEngineCount, devID;
  check_error( cudaGetDevice(&devID), CUBLAS_STATUS_EXECUTION_FAILED);
  check_error( cudaDeviceGetAttribute(&AsyncEngineCount, cudaDevAttrAsyncEngineCount, devID), CUBLAS_STATUS_EXECUTION_FAILED);
  bool DO_INLINE_BOUT = AsyncEngineCount > 1;
  
  check_error( cudaMalloc( (void**)&Ad, (Am*An)*sizeof(T) ), CUBLAS_STATUS_EXECUTION_FAILED);
  check_error( cudaMalloc( (void**)&Bd, (Bm*Bn)*sizeof(T) ), CUBLAS_STATUS_EXECUTION_FAILED);

  //setup streams
  cudaStream_t inStream, outStream;

                          cublasOperation_t trans, cublasDiagType_t diag,
                          int m, int n,
                          const T *alpha,
                          const T *h_A, int incA, T* d_A, 
                                T *h_B, int incB, T* d_B, bool BIsIn, bool getBOut)
{
  T one = make_one<T>();
  cublasStatus_t status;
  cudaEvent_t eDataIn, eComp;
  check_error( cudaEventCreateWithFlags(&eDataIn, cudaEventDisableTiming), CUBLAS_STATUS_EXECUTION_FAILED);
  check_error( cudaEventCreateWithFlags(&eComp, cudaEventDisableTiming), CUBLAS_STATUS_EXECUTION_FAILED);
  cudaStream_t strComp;
  check_error( cublasGetStream_v2(handle, &strComp), CUBLAS_STATUS_INTERNAL_ERROR);
