   uint64_t w=0;
   uint64_t b=0;
   uint8_t *curr;
-
-  for(;i<min((int64_t)input_len-partition_off,partition_size);)
+  /*
+  printf("thread ID: %ld, last idx: %ld\n", global_idx + 100000, min((int64_t)(input_len-partition_off),(int64_t)partition_size));
+  return;
+  */
+  for(;i<min((int64_t)(input_len-partition_off),(int64_t)partition_size) && partition_size > 0;)
   {
     curr = input + i;
 
     printf("OFFSET %5i\n",partition_off + i + 100000);
 
     uint64_t window_offset = min(partition_off + i,WINDOW);
-    window_match(curr, window_offset, (uint16_t) input_len-partition_off-i, &match);
+    window_match(curr, window_offset, min((uint16_t) input_len-partition_off-i, (uint16_t) partition_size-i), &match);
     if( match.l < MIN_MATCH )
     {
       /* add 0 bit and the byte */

#include <cuda.h>

#include "common.h"
#include "lzss_help.h"

#define DISP_BITS 11
#define LEN_BITS 4

  {
    cudaMemcpy(dst + cmp_size.w , gpu_dst + i * PARTITION_SIZE, sizes[i].w, cudaMemcpyDeviceToHost);
    cudaMemcpy(flag_buf + cmp_size.b , gpu_flags + i * PARTITION_SIZE, sizes[i].b, cudaMemcpyDeviceToHost);
    fprintf(stdout,"bsize[%3.3d] = %3.3d, wsize[%3.3d] = %3.3d\n",i,sizes[i].b,i,sizes[i].w);
    cmp_size.b += sizes[i].b;
    cmp_size.w += sizes[i].w;
  }
