 #endif */
 
 // memory layout: index * 2 + 1
-__global__ void calculatePrimeSingle(char *isPrime) 
+__global__ void calculatePrimeSingle(int *isPrime) 
 {
 	int x = threadIdx.x;
 	int y = blockIdx.x;
 	int i = blockDim.x * y + x;
 	int numToCheck = i * 2 + 1;
-	SET_BIT_CHAR_ARRAY(isPrime, i);
-	for (int j = 3; j < (numToCheck / 2) && READ_BIT_CHAR_ARRAY(isPrime, i); j += 2) {
+	SET_BIT_INT_ARRAY(isPrime, i);
+	for (int j = 3; j < numToCheck / 2; j += 2) {
 		if ((numToCheck % j) == 0) {
-			CLEAR_BIT_CHAR_ARRAY(isPrime, i);
+			CLEAR_BIT_INT_ARRAY(isPrime, i);
+			return;
 		}
 	}
 }
 
-__global__ void clearAll(char *isPrime)
+__global__ void clearAll(int *isPrime)
 {
 	int x = threadIdx.x;
 	int y = blockIdx.x;
 	int i = blockDim.x * y + x;
-	CLEAR_BIT_CHAR_ARRAY(isPrime, i);
+	CLEAR_BIT_INT_ARRAY(isPrime, i);
 }
 
-__global__ void setAll(char *isPrime)
+__global__ void setAll(int *isPrime)
 {
 	int x = threadIdx.x;
 	int y = blockIdx.x;
 	int i = blockDim.x * y + x;
-	SET_BIT_CHAR_ARRAY(isPrime, i);
+	atomicOr(&isPrime[GET_ARRAY_ELEMENT(x)], GET_BITMASK_INT(x));	
 }
 
 
 // Helper function for using CUDA to add vectors in parallel.
-cudaError_t calculatePrimeCuda(char *isPrime)
+cudaError_t calculatePrimeCuda(int *isPrime)
 {
-    char *dev_isPrime = 0;
+    int *dev_isPrime = 0;
     cudaError_t cudaStatus;
 
 



    // Launch a kernel on the GPU with one thread for each element.
	//calculatePrimeSingle <<<cNumBlocks, cMaxThreads >> >(dev_isPrime);

	clearAll << <cNumBlocks, cMaxThreads >> >(dev_isPrime);
	//setAll << <cNumBlocks, cMaxThreads >> >(dev_isPrime);

    // Check for any errors launching the kernel


	int numPrimeNumbers = 0;
	for (int i = 0; i < cResults; i++) {
		if (READ_BIT_INT_ARRAY(cIsPrime, i)) {
			printf("%i, ", i * 2 + 1);
			numPrimeNumbers++;
		}
