diff --git a/Makefile b/Makefile
index a0ebd78..a072e6d 100644
--- a/Makefile
+++ b/Makefile
@@ -162,14 +162,14 @@ cleanver:
 # Binary creation
 grok: LDFLAGS+=-levent
 grok: $(GROKOBJ) conf.tab.o conf.yy.o main.o grok_config.o
-	gcc $(LDFLAGS) $^ -o $@
+	$(CC) $(LDFLAGS) $^ -o $@
 
 discogrok: $(GROKOBJ) discover_main.o
-	gcc $(LDFLAGS) $^ -o $@
+	$(CC) $(LDFLAGS) $^ -o $@
 
 libgrok.$(LIBSUFFIX): 
 libgrok.$(LIBSUFFIX): $(GROKOBJ) 
-	gcc $(LDFLAGS) -fPIC $(DYNLIBFLAG) $(LIBNAMEFLAG) $^ -o $@
+	$(CC) $(LDFLAGS) -fPIC $(DYNLIBFLAG) $(LIBNAMEFLAG) $^ -o $@
 
 libgrok.$(VERLIBSUFFIX): libgrok.$(LIBSUFFIX);
 	ln -s $< $@
diff --git a/grok_capture.c b/grok_capture.c
index 47c2678..70171a7 100644
--- a/grok_capture.c
+++ b/grok_capture.c
@@ -96,7 +96,7 @@ const grok_capture *grok_capture_get_by_id(grok_t *grok, int id) {
   return gct;
 }
 
-const grok_capture *grok_capture_get_by_name(grok_t *grok, const char *name) {
+const grok_capture *grok_capture_get_by_name(const grok_t *grok, const char *name) {
   int unused_size;
   const grok_capture *gct;
   const TCLIST *by_name_list;
@@ -111,7 +111,7 @@ const grok_capture *grok_capture_get_by_name(grok_t *grok, const char *name) {
   return gct;
 }
 
-const grok_capture *grok_capture_get_by_subname(grok_t *grok,
+const grok_capture *grok_capture_get_by_subname(const grok_t *grok,
                                                 const char *subname) {
   int unused_size;
   const grok_capture *gct;
@@ -213,11 +213,11 @@ void grok_capture_free(grok_capture *gct) {
 }
 
 /* this function will walk the captures_by_id table */
-void grok_capture_walk_init(grok_t *grok) {
+void grok_capture_walk_init(const grok_t *grok) {
   tctreeiterinit(grok->captures_by_id);
 }
 
-const grok_capture *grok_capture_walk_next(grok_t *grok) {
+const grok_capture *grok_capture_walk_next(const grok_t *grok) {
   int id_size;
   int gct_size;
   int *id;
diff --git a/grok_capture.h b/grok_capture.h
index 759903c..e3c3617 100644
--- a/grok_capture.h
+++ b/grok_capture.h
@@ -10,14 +10,14 @@ void grok_capture_free(grok_capture *gct);
 
 void grok_capture_add(grok_t *grok, const grok_capture *gct);
 const grok_capture *grok_capture_get_by_id(grok_t *grok, int id);
-const grok_capture *grok_capture_get_by_name(grok_t *grok, const char *name);
-const grok_capture *grok_capture_get_by_subname(grok_t *grok,
+const grok_capture *grok_capture_get_by_name(const grok_t *grok, const char *name);
+const grok_capture *grok_capture_get_by_subname(const grok_t *grok,
                                                 const char *subname);
 const grok_capture *grok_capture_get_by_capture_number(grok_t *grok,
                                                        int capture_number);
 
-void grok_capture_walk_init(grok_t *grok);
-const grok_capture *grok_capture_walk_next(grok_t *grok);
+void grok_capture_walk_init(const grok_t *grok);
+const grok_capture *grok_capture_walk_next(const grok_t *grok);
 
 int grok_capture_set_extra(grok_t *grok, grok_capture *gct, void *extra);
 void _grok_capture_encode(grok_capture *gct, char **data_ret, int *size_ret);
diff --git a/grok_logging.c b/grok_logging.c
index bbbba04..64f0bd0 100644
--- a/grok_logging.c
+++ b/grok_logging.c
@@ -1,5 +1,7 @@
 #include <stdio.h>
 #include <stdarg.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include "grok.h"
 
 #ifndef NOLOGGING
diff --git a/grok_match.c b/grok_match.c
index ab7727c..2af0937 100644
--- a/grok_match.c
+++ b/grok_match.c
@@ -37,7 +37,7 @@ int grok_match_get_named_substring(const grok_match_t *gm, const char *name,
 }
 
 void grok_match_walk_init(const grok_match_t *gm) {
-  grok_t *grok = gm->grok;
+  const grok_t *grok = gm->grok;
   grok_capture_walk_init(grok);
 }
 
diff --git a/grok_matchconf.c b/grok_matchconf.c
index 7293961..d5553af 100644
--- a/grok_matchconf.c
+++ b/grok_matchconf.c
@@ -298,8 +298,8 @@ char *grok_matchconfig_filter_reaction(const char *str, grok_match_t *gm) {
               } else { /* VALUE_JSON_COMPLEX */ 
                 entry_len = asprintf(&entry, 
                                      "{ \"%.*s\": { "
-                                     "\"start\": %d, "
-                                     "\"end\": %d, "
+                                     "\"start\": %ld, "
+                                     "\"end\": %ld, "
                                      "\"value\": \"%.*s\""
                                      " } }, ",
                                      pname_len, pname, 
diff --git a/stringhelper.c b/stringhelper.c
index 206ae89..6d0f5df 100644
--- a/stringhelper.c
+++ b/stringhelper.c
@@ -244,7 +244,7 @@ char *string_ndup(const char *src, size_t size) {
 } /* char *string_ndup */
 
 int string_count(const char *src, const char *charlist) {
-  string_ncount(src, strlen(src), charlist, strlen(charlist));
+  return (string_ncount(src, strlen(src), charlist, strlen(charlist)));
 } /* int string_count */
 
 int string_ncount(const char *src, size_t srclen,
