diff --git a/w2v-server.pl b/w2v-server.pl
index d7ec900..cc17cf3 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -178,10 +178,16 @@
 void *connection_handler(void *);
 
 typedef struct {
-	long long *index;
-	float *dist;
-	float *norm;
-  long long *pos;
+	long long wordi;
+	long position;
+	float activation;
+	float activation_sum;
+	float probability_sum;
+	float probability;
+} collocator;
+
+typedef struct {
+	collocator *best;
 	int length;
 } knn;
   
@@ -414,26 +420,22 @@
   long window_layer_size = size * window * 2;
 	long a, b, c, d, e, window_offset, target, max_target=0, maxmax_target;
 	float f, max_f, maxmax_f;
-	float *target_sums, *bestf, *bestn, worstbest, wpos_sum;
-	long long *besti, *bestp;
+	float *target_sums, worstbest, wpos_sum;
+	collocator *best;
 
   if(M2 == NULL || cc == -1)
     return NULL;
 
 	a = posix_memalign((void **) &target_sums, 128, pars->cutoff * sizeof(float));
-	besti = malloc(N * sizeof(long long));
-	bestp = malloc(N * sizeof(long long));
-	bestf = malloc(N * sizeof(float));
-	bestn = malloc(N * sizeof(float));
-
+	best = malloc(N * sizeof(collocator));
   worstbest = MIN_RESP;
 
   for (b = 0; b < pars->cutoff; b++)
 			target_sums[b]=0;
   for (b = 0; b < N; b++) {
-      besti[b] = -1;
-      bestn[b] = 1;
-      bestf[b] = worstbest;
+      best[b].wordi = -1;
+      best[b].probability = 1;
+      best[b].activation = worstbest;
   }
 
   d = cc;
@@ -468,18 +470,16 @@
         target_sums[target] += f;
         if(f > worstbest) {
           for (b = 0; b < N; b++) {
-            if (f > bestf[b]) {
-							memmove(bestf + b + 1, bestf + b, (N - b -1) * sizeof(float));
-							memmove(besti + b + 1, besti + b, (N - b -1) * sizeof(long long));
-							memmove(bestp + b + 1, bestp + b, (N - b -1) * sizeof(long long));
-							bestf[b] = f;
-							besti[b] = target;
-							bestp[b] = window-a;
+            if (f > best[b].activation) {
+							memmove(best + b + 1, best + b, (N - b -1) * sizeof(collocator));
+							best[b].activation = f;
+							best[b].wordi = target;
+							best[b].position = window-a;
 							break;
             }
           }
           if(b == N - 1)
-            worstbest = bestf[N-1];
+            worstbest = best[N-1].activation;
         }
       }
       printf("%d %.2f\n", max_target, max_f);
@@ -489,8 +489,8 @@
         maxmax_target = max_target;
       }
       for (b = 0; b < N; b++)
-        if(bestp[b] == window-a)
-          bestn[b] = bestf[b] / wpos_sum;
+        if(best[b].position == window-a)
+          best[b].probability = best[b].activation / wpos_sum;
     } else {
       printf("\x1b[1m%s\x1b[0m ", &vocab[d*max_w]);
     }
@@ -499,14 +499,11 @@
   for (b = 0; b < pars->cutoff; b++)
       pars->target_sums[b] += (target_sums[b] / wpos_sum ) / (window * 2);
   free(target_sums);
-  for(b=0; b<N && besti[b] >= 0; b++);; // THIS LOOP IS NEEDED (b...)
-//		printf("%d: best syn: %s %.2f %.5f\n", b, &vocab[besti[b]*max_w], bestf[b], bestn[b]);
+  for(b=0; b<N && best[b].wordi >= 0; b++);; // THIS LOOP IS NEEDED (b...)
+//		printf("%d: best syn: %s %.2f %.5f\n", b, &vocab[best[b].wordi*max_w], best[b].activation, best[b].probability);
 //	printf("\n");
   nbs = malloc(sizeof(knn));
-	nbs->index = besti;
-	nbs->dist = bestf;
-	nbs->norm = bestn;
-	nbs->pos = bestp;
+	nbs->best = best;
 	nbs->length = b-1;
   pthread_exit(nbs);
 }
@@ -557,18 +554,17 @@
 	long from = pars -> from;
 	unsigned long upto = pars -> upto;
 	char file_name[max_size], st[100][max_size], *sep;
-	float dist, len, *bestd, vec[max_size];
-	long long a, b, c, d, cn, *bi, *besti;
+	float dist, len, vec[max_size];
+	long long a, b, c, d, cn, *bi;
 	char ch;
 	knn *nbs = NULL;
   wordlist *wl = pars->wl;
   
-	besti = malloc(N * sizeof(long long));
-	bestd = malloc(N * sizeof(float));
+	collocator *best = malloc(N * sizeof(collocator));
 
 	float worstbest=-1;
 
-	for (a = 0; a < N; a++) bestd[a] = 0;
+	for (a = 0; a < N; a++) best[a].activation = 0;
 	a = 0;
   bi = wl->wordi;
 	cn = wl->length;
@@ -591,7 +587,7 @@
 	for (a = 0; a < size; a++) len += vec[a] * vec[a];
 	len = sqrt(len);
 	for (a = 0; a < size; a++) vec[a] /= len;
-	for (a = 0; a < N; a++) bestd[a] = -1;
+	for (a = 0; a < N; a++) best[a].activation = -1;
 	for (c = from; c < upto; c++) {
     if(garbage && garbage[c]) continue;
 		a = 0;
@@ -602,21 +598,19 @@
 		for (a = 0; a < size; a++) dist += vec[a] * M[a + c * size];
 		if(dist > worstbest) {
 			for (a = 0; a < N; a++) {
-				if (dist > bestd[a]) {
-					memmove(bestd + a + 1, bestd + a, (N - a -1) * sizeof(float));
-					memmove(besti + a + 1, besti + a, (N - a -1) * sizeof(long long));
-					bestd[a] = dist;
-					besti[a] = c;
+				if (dist > best[a].activation) {
+					memmove(best + a + 1, best + a, (N - a -1) * sizeof(collocator));
+					best[a].activation = dist;
+					best[a].wordi = c;
 					break;
 				}
 			}
-			worstbest = bestd[N-1];
+			worstbest = best[N-1].activation;
 		}
 	}
 
 	nbs = malloc(sizeof(knn));
-	nbs->index = besti;
-	nbs->dist = bestd;
+	nbs->best = best;
 	nbs->length = N;
 end:
 	pthread_exit(nbs);
@@ -625,9 +619,9 @@
 
 SV *get_neighbours(char *st1, int N, int sort_by, int search_backw, long cutoff, int dedupe) {
   HV *result = newHV();
-	float *target_sums, bestd[MAX_NEIGHBOURS], bestn[MAX_NEIGHBOURS], bests[MAX_NEIGHBOURS], vec[max_size];
+	float *target_sums, vec[max_size];
 	long long old_words;
-	long besti[MAX_NEIGHBOURS], bestp[MAX_NEIGHBOURS], a, b, c, d, slice;
+	long a, b, c, d, slice;
 	knn *para_nbs[MAX_THREADS];
 	knn *syn_nbs[MAX_THREADS];
 	knnpars pars[MAX_THREADS];
@@ -635,7 +629,9 @@
   wordlist *wl;
   int syn_threads = (M2? window * 2 : 0);
   int para_threads = num_threads - syn_threads;
-  
+
+  collocator *best = malloc(MAX_NEIGHBOURS * sizeof(collocator));
+
   if(N>MAX_NEIGHBOURS) N=MAX_NEIGHBOURS;
 	
   if(cutoff < 1)
@@ -687,20 +683,18 @@
 	/* 	goto end; */
 
 	for(b=0; b < N; b++) {
-		besti[b] = para_nbs[0]->index[b];
-		bestd[b] = para_nbs[0]->dist[b];
+		best[b].wordi = para_nbs[0]->best[b].wordi;
+		best[b].activation = para_nbs[0]->best[b].activation;
 	}
 
 	for(a=1; a < para_threads; a++) {
-		for(b=0; b < para_nbs[a]->length && para_nbs[a]->index[b] >= 0; b++) {
+		for(b=0; b < para_nbs[a]->length && para_nbs[a]->best[b].wordi >= 0; b++) {
 			for(c=0; c < N * para_threads; c++) {
-				if(para_nbs[a]->dist[b] > bestd[c]) {
+				if(para_nbs[a]->best[b].activation > best[c].activation) {
 					for(d=N-1; d>c; d--) {
-						bestd[d] = bestd[d-1];
-						besti[d] = besti[d-1];
+            memmove(best + d, best + d - 1, sizeof(collocator));
 					}
-					besti[c] = para_nbs[a]->index[b];
-					bestd[c] = para_nbs[a]->dist[b];
+				  memcpy(best + c, &para_nbs[a]->best[b], sizeof(collocator));
 					break;
 				}
 			}
@@ -713,7 +707,7 @@
   int l1_words=0, l2_words=0;
   for (a = 0, i = 0; i < N && a < 600; a++) {
     int filtered=0;
-    long long c = besti[a];
+    long long c = best[a].wordi;
     if (dedupe && i > 0) {
       for (j=0; j<i; j++)
         if (strcasestr(&vocab[c * max_w], chosen[j]) ||
@@ -746,11 +740,11 @@
     if(latin_enc == 0) SvUTF8_on(word);
     fflush(stdout);
     hv_store(hash, "word", strlen("word"), word , 0);
-    hv_store(hash, "dist", strlen("dist"), newSVnv(bestd[a]), 0);
-    hv_store(hash, "rank", strlen("rank"), newSVuv(besti[a]), 0);
+    hv_store(hash, "dist", strlen("dist"), newSVnv(best[a].activation), 0);
+    hv_store(hash, "rank", strlen("rank"), newSVuv(best[a].wordi), 0);
     AV *vector = newAV();
     for (b = 0; b < size; b++) {
-      av_push(vector, newSVnv(M[b + besti[a] * size]));
+      av_push(vector, newSVnv(M[b + best[a].wordi * size]));
     }
     hv_store(hash, "vector", strlen("vector"), newRV_noinc((SV*)vector), 0);
     av_push(array, newRV_noinc((SV*)hash));
@@ -759,11 +753,11 @@
   hv_store(result, "paradigmatic", strlen("paradigmatic"), newRV_noinc((SV*)array), 0);
   
   for(b=0; b < MAX_NEIGHBOURS; b++) {
-    besti[b] = -1L;
-    bestd[b] = 0;
-    bestn[b] = 0;
-    bestp[b] = 0;
-    bests[b] = 0;
+    best[b].wordi = -1L;
+    best[b].activation = 0;
+    best[b].probability = 0;
+    best[b].position = 0;
+    best[b].activation_sum = 0;
   }
 
   if (M2) {
@@ -775,11 +769,9 @@
     fflush(stdout);
 
     for(b=0; b < syn_nbs[0]->length; b++) {
-      besti[b] = syn_nbs[0]->index[b];
-      bestd[b] = syn_nbs[0]->dist[b];
-      bestn[b] = syn_nbs[0]->norm[b];
-      bestp[b] = -1; //  syn_nbs[0]->pos[b];
-      bests[b] = target_sums[syn_nbs[0]->index[b]];
+			memcpy(best + b, &syn_nbs[0]->best[b], sizeof(collocator));
+      best[b].position = -1; //  syn_nbs[0]->pos[b];
+      best[b].activation_sum = target_sums[syn_nbs[0]->best[b].wordi];
     }
 		
 		float best_window_sum[MAX_NEIGHBOURS];
@@ -788,10 +780,10 @@
       for(a=0; a < syn_threads; a++) {
         for(b=0; b < syn_nbs[a]->length; b++) {
 					for(i=0; i < found_index; i++)
-						if(besti[i] == syn_nbs[a]->index[b])
+						if(best[i].wordi == syn_nbs[a]->best[b].wordi)
 							break;
 					if(i >= found_index) {
-						besti[found_index++] = syn_nbs[a]->index[b];
+						best[found_index++].wordi = syn_nbs[a]->best[b].wordi;
 //						printf("found: %s\n", &vocab[syn_nbs[a]->index[b] * max_w]);
 					}
 				}
@@ -799,7 +791,7 @@
 			printf("window: %d  -  syn_threads: %d, %d\n", window, syn_threads, (1 << syn_threads) -1);
 			int wpos;
 			for(i=0; i < found_index; i++) {
-				bestd[i] = 0; bestn[i] = 0;
+				best[i].activation = 0; best[i].probability = 0;
 				for(w=1; w <  (1 << syn_threads); w++) { // loop through all possible windows
 					float word_window_sum = 0, word_activation_sum = 0, total_window_sum = 0;
 					int bits_set = 0;
@@ -815,13 +807,13 @@
 							wpos = (a >= window? a+1 : a);
  						  bits_set++;
 						  for(b=0; b < syn_nbs[a]->length; b++)
-							  if(besti[i] == syn_nbs[a]->index[b]) {
+							  if(best[i].wordi == syn_nbs[a]->best[b].wordi) {
 //                  word_window_sum += syn_nbs[a]->dist[b] *  syn_nbs[a]->norm[b]; // / window_sums[wpos];  // syn_nbs[a]->norm[b];
 //                    word_window_sum += syn_nbs[a]->dist[b]; // / window_sums[wpos];  // syn_nbs[a]->norm[b];
 //                    word_window_sum += syn_nbs[a]->norm[b]; // / window_sums[wpos];  // syn_nbs[a]->norm[b];
 //                  word_window_sum = (word_window_sum + syn_nbs[a]->norm[b]) - (word_window_sum * syn_nbs[a]->norm[b]);  // syn_nbs[a]->norm[b];
-                  word_window_sum += syn_nbs[a]->dist[b] - word_window_sum * syn_nbs[a]->dist[b];  // conormalied activation sum
-									word_activation_sum += syn_nbs[a]->dist[b];
+                  word_window_sum += syn_nbs[a]->best[b].activation - word_window_sum * syn_nbs[a]->best[b].activation;  // conormalied activation sum
+									word_activation_sum += syn_nbs[a]->best[b].activation;
 								}
 						}
 					}
@@ -831,50 +823,38 @@
 //          }
 //          word_window_sum /= total_window_sum;
 
-          if(word_window_sum > bestn[i]) {
-						bestn[i] = word_window_sum;
-						bestd[i] = word_activation_sum;
-						bestp[i] = w;
+          if(word_window_sum > best[i].probability) {
+						best[i].probability = word_window_sum;
+						best[i].activation = word_activation_sum;
+						best[i].position = w;
 					}
 			  }
 			}
+			collocator *tmp = malloc(sizeof(collocator));
       for(i=0; i<found_index;i++) {
         for(j=0;j<found_index-1;j++) {
-          if(bestn[j]<bestn[j+1]) {
-            float tempd=bestn[j];
-            bestn[j]=bestn[j+1];
-            bestn[j+1]=tempd;
-            tempd=bestd[j];
-            bestd[j]=bestd[j+1];
-            bestd[j+1]=tempd;
-            int tempi=besti[j];
-            besti[j]=besti[j+1];
-            besti[j+1]=tempi;
-            int tempp=bestp[j];
-            bestp[j]=bestp[j+1];
-            bestp[j+1]=tempp;
+          if(best[j].probability < best[j+1].probability) {
+						memmove(tmp, best + j, sizeof(collocator));
+						memmove(best + j, best + j + 1, sizeof(collocator));
+						memmove(best + j + 1, tmp, sizeof(collocator));
           }
         }
       }
+			free(tmp);
 //      for(i=0; i < found_index; i++) {
-//				printf("found: %s - sum: %f - window: %d\n", &vocab[besti[i] * max_w], bestd[i], bestp[i]);
+//				printf("found: %s - sum: %f - window: %d\n", &vocab[best[i].wordi * max_w], best[i].activation, best[i].position);
 //			}
 
     } else if(sort_by ==1) { // single window position
        for(a=1; a < syn_threads; a++) {
         for(b=0; b < syn_nbs[a]->length; b++) {
           for(c=0; c < MAX_NEIGHBOURS; c++) {
-            if(syn_nbs[a]->dist[b] > bestd[c]) {
+            if(syn_nbs[a]->best[b].activation > best[c].activation) {
               for(d=MAX_NEIGHBOURS-1; d>c; d--) {
-                bestd[d] = bestd[d-1];
-                besti[d] = besti[d-1];
-                bestn[d] = bestn[d-1];
-                bestp[d] = bestp[d-1];
+								memmove(best + d, best + d - 1, sizeof(collocator));
               }
-              besti[c] = syn_nbs[a]->index[b];
-              bestd[c] = syn_nbs[a]->dist[b];
-              bestn[c] = syn_nbs[a]->norm[b];
-              bestp[c] = 1 << (-syn_nbs[a]->pos[b]+window - (syn_nbs[a]->pos[b] < 0 ? 1:0));
+              memcpy(best + c, &syn_nbs[a]->best[b], sizeof(collocator));
+              best[c].position = 1 << (-syn_nbs[a]->best[b].position+window - (syn_nbs[a]->best[b].position < 0 ? 1:0));
               break;
             }
           }
@@ -884,19 +864,13 @@
       for(a=1; a < syn_threads; a++) {
         for(b=0; b < syn_nbs[a]->length; b++) {
           for(c=0; c < MAX_NEIGHBOURS; c++) {
-            if(target_sums[syn_nbs[a]->index[b]] > bests[c]) {
+            if(target_sums[syn_nbs[a]->best[b].wordi] > best[c].activation_sum) {
               for(d=MAX_NEIGHBOURS-1; d>c; d--) {
-                bestd[d] = bestd[d-1];
-                besti[d] = besti[d-1];
-                bestn[d] = bestn[d-1];
-                bestp[d] = bestp[d-1];
-                bests[d] = bests[d-1];
+								memmove(best + d, best + d - 1, sizeof(collocator));
               }
-              besti[c] = syn_nbs[a]->index[b];
-              bestd[c] = syn_nbs[a]->dist[b];
-              bestn[c] = syn_nbs[a]->norm[b];
-              bestp[c] = (1 << 2*window) - 1; // syn_nbs[a]->pos[b];
-              bests[c] = target_sums[syn_nbs[a]->index[b]];
+              memcpy(best + c, &syn_nbs[a]->best[b], sizeof(collocator));
+              best[c].position = (1 << 2*window) - 1; // syn_nbs[a]->pos[b];
+              best[c].activation_sum = target_sums[syn_nbs[a]->best[b].wordi];
               break;
             }
           }
@@ -904,8 +878,8 @@
       }
     }
     array = newAV();
-    for (a = 0, i=0; a < MAX_NEIGHBOURS && besti[a] >= 0; a++) {
-      long long c = besti[a];
+    for (a = 0, i=0; a < MAX_NEIGHBOURS && best[a].wordi >= 0; a++) {
+      long long c = best[a].wordi;
       if (dedupe) {
 	  		int filtered=0;
         for (j=0; j<i; j++)
@@ -919,20 +893,21 @@
 			}
 			chosen[i++]=&vocab[c * max_w];
       HV* hash = newHV();
-      SV* word = newSVpvf(&vocab[besti[a] * max_w], 0);
+      SV* word = newSVpvf(&vocab[best[a].wordi * max_w], 0);
       if(latin_enc == 0) SvUTF8_on(word);
       hv_store(hash, "word", strlen("word"), word , 0);
-      hv_store(hash, "rank", strlen("rank"), newSVuv(besti[a]), 0);
-      hv_store(hash, "dist", strlen("dist"), newSVnv(bestd[a]), 0);
-      hv_store(hash, "norm", strlen("norm"), newSVnv(bestn[a]), 0);
-      hv_store(hash, "sum", strlen("sum"), newSVnv(target_sums[besti[a]]), 0);
-      hv_store(hash, "pos", strlen("pos"), newSVnv(bestp[a]), 0);
+      hv_store(hash, "rank", strlen("rank"), newSVuv(best[a].wordi), 0);
+      hv_store(hash, "dist", strlen("dist"), newSVnv(best[a].activation), 0);
+      hv_store(hash, "norm", strlen("norm"), newSVnv(best[a].probability), 0);
+      hv_store(hash, "sum", strlen("sum"), newSVnv(target_sums[best[a].wordi]), 0);
+      hv_store(hash, "pos", strlen("pos"), newSVnv(best[a].position), 0);
       av_push(array, newRV_noinc((SV*)hash));
     }
     hv_store(result, "syntagmatic", strlen("syntagmatic"), newRV_noinc((SV*)array), 0);
   }
 end:
 	words = old_words;
+	free(best);
 	return newRV_noinc((SV*)result);
 }
 
