--- a/LoweDetector.c
+++ b/LoweDetector.c
@@ -93,6 +93,8 @@
 
 // The Integer-normalized version of the globalKeypoints.
 ArrayList* LoweFeatureDetector_GlobalNaturalKeypoints(LoweFeatureDetector* self) {
+  	int i;
+
 	if (self->globalNaturalKeypoints != NULL)
 		return (self->globalNaturalKeypoints);
 	
@@ -101,9 +103,8 @@
 	
 	self->globalNaturalKeypoints = ArrayList_new0 (KeypointN_delete);
 
-	int i;
 	for(i=0; i<ArrayList_Count(self->globalKeypoints); i++) {
-		Keypoint* kp = ArrayList_GetItem(self->globalKeypoints, i);
+		Keypoint* kp = (Keypoint *) ArrayList_GetItem(self->globalKeypoints, i);
 		ArrayList_AddItem (self->globalNaturalKeypoints, KeypointN_new(kp));
 	}