--- a/MatchKeys.c
+++ b/MatchKeys.c
@@ -68,13 +68,14 @@
 	HashTable* ht = HashTable_new0 (NULL, NULL);
 	
 	// Count the references to each keypoint
+    // ARG 13 May 2010: made 64 bit OS safe
 	int i;
 	for(i=0; i<ArrayList_Count(matches); i++) {
 		Match* m = (Match*) ArrayList_GetItem(matches, i);
-		int lI = (HashTable_GetItem(ht, m->kp1) == NULL) ? 0 : (int) HashTable_GetItem(ht, m->kp1);
-		HashTable_SetItem(ht, m->kp1, (void*)(lI + 1));
-		int rI = (HashTable_GetItem(ht, m->kp2) == NULL) ? 0 : (int) HashTable_GetItem(ht, m->kp2);
-		HashTable_SetItem(ht, m->kp2, (void*)(rI + 1));
+               void *lI = (HashTable_GetItem(ht, m->kp1) == NULL) ? NULL : HashTable_GetItem(ht, m->kp1);
+               HashTable_SetItem(ht, m->kp1, (void*)((char *) lI + 1));
+               void *rI = (HashTable_GetItem(ht, m->kp2) == NULL) ? NULL : HashTable_GetItem(ht, m->kp2);
+               HashTable_SetItem(ht, m->kp2, (void*)((char *) rI + 1));
 	}
 
 	ArrayList* survivors = ArrayList_new0(NULL);
@@ -84,7 +85,7 @@
 		Match* m = (Match*) ArrayList_GetItem(matches, j);
 		//WriteLine ("match: %d, %d", (int) HashTable_GetItem(ht, m->kp1), (int) HashTable_GetItem(ht, m->kp2));
 		
-		if (((int) HashTable_GetItem(ht, m->kp1)) <= 1 && ((int) HashTable_GetItem(ht, m->kp2)) <= 1)
+               if (( HashTable_GetItem(ht, m->kp1)) <= (void *)1 && (HashTable_GetItem(ht, m->kp2)) <= (void *)1)
 			ArrayList_AddItem(survivors, m);
 		else
 			removed += 1;