diff --git a/lib/c/Makefile b/lib/c/Makefile
index 742ae358e3f56deb6b1a5065c97241ae8f2691ca..25c86bb49bf6cbf77d3b63190bfe09bb1009f4c4 100644
--- a/lib/c/Makefile
+++ b/lib/c/Makefile
@@ -3,10 +3,10 @@
 # Use LLVM clang if it's found.
 CC = $(shell hash clang 2>/dev/null && echo clang || echo gcc)
 CFLAGS = -g -Wall -Werror -I. -Itest
-LDFLAGS = -L .
+LDFLAGS = -L.
 LDLIBS_TEST = -lcunit -llabcomm
 
-OBJS= labcomm.o labcomm_dynamic_buffer_reader_writer.o labcomm_fd_reader_writer.o labcomm_mem_reader.o labcomm_mem_writer.o
+OBJS= labcomm.o labcomm_dynamic_buffer_writer.o labcomm_fd_reader_writer.o labcomm_mem_reader.o labcomm_mem_writer.o
 LABCOMMC_PATH=../../compiler
 LABCOMMC_JAR=$(LABCOMMC_PATH)/labComm.jar
 
@@ -55,20 +55,16 @@ run-test: $(TEST_DIR)/test_labcomm $(TEST_DIR)/test_labcomm_errors |$(TEST_DIR)
 	test/test_labcomm
 	test/test_labcomm_errors
 
-$(TEST_DIR)/test_labcomm_errors: $(TEST_DIR)/test_labcomm_errors.o liblabcomm.a |$(TEST_DIR)
-	$(CC) $(CFLAGS) $(LDFLAGS) -llabcomm -o $@ $^
+$(TEST_DIR)/%.o: $(TEST_DIR)/%.c
+	$(CC) $(CFLAGS) -o $@ -c $<
 
-$(TEST_DIR)/test_labcomm_errors.o: $(TEST_DIR)/test_labcomm_errors.c $(TEST_DIR)/test_labcomm_errors.h |$(TEST_DIR)
-	cd test; $(CC) $(CFLAGS) -I .. -c $(patsubst $(TEST_DIR)/%, %, $^)
+$(TEST_DIR)/%: $(TEST_DIR)/%.o
+	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) $(LDLIBS_TEST)
 
-$(TEST_DIR)/test_labcomm.o: $(TEST_DIR)/test_labcomm.c $(TEST_GEN_DIR)/test_sample.h |$(TEST_DIR)
-	$(CC) -c $(CFLAGS) -o $@ $<
-
-$(TEST_DIR)/test_labcomm: $(TEST_DIR)/test_labcomm.o $(TEST_GEN_DIR)/test_sample.o liblabcomm.a
-	$(CC) $(CFLAGS) $(LDFLAGS) $(filter-out %.a,$^) $(LDLIBS) $(LDLIBS_TEST) -o $@
-
-$(TEST_GEN_DIR)/%.c $(TEST_GEN_DIR)/%.h: $(TESTDATA_DIR)/%.lc $(LABCOMMC_JAR) |$(TEST_GEN_DIR)
-	java -jar $(LABCOMMC_JAR) --c=$(patsubst %.h,%.c,$@) --h=$(patsubst %.c,%.h,$@) $<
+$(TEST_GEN_DIR)/%.c $(TEST_GEN_DIR)/%.h: $(TESTDATA_DIR)/%.lc \
+					 $(LABCOMMC_JAR) | $(TEST_GEN_DIR)
+	java -jar $(LABCOMMC_JAR) \
+		--c=$(patsubst %.h,%.c,$@) --h=$(patsubst %.c,%.h,$@) $<
 
 $(LABCOMMC_JAR):
 	@echo "======Building LabComm compiler======"
@@ -83,7 +79,11 @@ clean:
 	$(RM) test/*.o
 	$(RM) test/*.gch
 	$(RM) test/test_labcomm_errors
+	$(RM) test/testdata/gen/*.[cho]
 	$(RM) $(TEST_DIR)/test_labcomm
 
 distclean: clean
 	$(RM) liblabcomm.a
+
+# Extra dependencies
+$(TEST_DIR)/test_labcomm:  $(TEST_GEN_DIR)/test_sample.o
diff --git a/lib/c/labcomm.c b/lib/c/labcomm.c
index 3b790e5752cd5e97954df1edf9e800621cac685d..7539be7a44281982385b2ed0f68189b47c0fa542 100644
--- a/lib/c/labcomm.c
+++ b/lib/c/labcomm.c
@@ -1,36 +1,16 @@
-#include <errno.h>
-#include <string.h>
-
-#ifndef __VXWORKS__
-  #ifdef ARM_CORTEXM3_CODESOURCERY
-    #include <string.h>
-  #else
-    #include <strings.h>
-  #endif
-#endif
-
-#ifndef ARM_CORTEXM3_CODESOURCERY
-  #include <stdlib.h>
-#endif
-
-// Some projects can not use stdio.h.
-#ifndef LABCOMM_NO_STDIO
+#ifdef LABCOMM_COMPAT
+  #include LABCOMM_COMPAT
+#else
   #include <stdio.h>
+  #include <strings.h>
 #endif
 
-#ifdef __VXWORKS__
-  #if (CPU == PPC603)
-    #undef _LITTLE_ENDIAN
-  #endif
-  #if (CPU == PENTIUM4)
-    #undef _BIG_ENDIAN
-  #endif
-#endif
-
+#include <errno.h>
+#include <string.h>
 #include "labcomm.h"
 #include "labcomm_private.h"
 #include "labcomm_ioctl.h"
-#include "labcomm_dynamic_buffer_reader_writer.h"
+#include "labcomm_dynamic_buffer_writer.h"
 
 typedef struct labcomm_sample_entry {
   struct labcomm_sample_entry *next;
@@ -360,7 +340,6 @@ int labcomm_encoder_ioctl(struct labcomm_encoder *encoder,
   return result;
 }
 
-
 static void collect_flat_signature(
   labcomm_decoder_t *decoder,
   labcomm_encoder_t *signature_writer)
diff --git a/lib/c/labcomm.h b/lib/c/labcomm.h
index 44af7cf6ff2826623af18dc0b3b5c62b6c3d634a..baedb8d0d9b3c56be9bf24c3405876943823dae2 100644
--- a/lib/c/labcomm.h
+++ b/lib/c/labcomm.h
@@ -155,15 +155,10 @@ struct labcomm_encoder *labcomm_encoder_new(
   void *writer_context);
 void labcomm_encoder_free(
   struct labcomm_encoder *encoder);
+
 /* See labcomm_ioctl.h for predefined ioctl_action values */
 int labcomm_encoder_ioctl(struct labcomm_encoder *encoder, 
 			  int ioctl_action,
 			  ...);
 
-void labcomm_encoder_start(struct labcomm_encoder *e,
-                           labcomm_signature_t *s) ;
-
-//HERE BE DRAGONS: is the signature_t* needed here?
-void labcomm_encoder_end(struct labcomm_encoder *e,
-                           labcomm_signature_t *s) ;
 #endif
diff --git a/lib/c/labcomm_compat_arm_cortexm3.h b/lib/c/labcomm_compat_arm_cortexm3.h
new file mode 100644
index 0000000000000000000000000000000000000000..512ad3633fa0bd29e9bbd7c4db22ea8881da95b3
--- /dev/null
+++ b/lib/c/labcomm_compat_arm_cortexm3.h
@@ -0,0 +1,5 @@
+#ifndef ARM_CORTEXM3_CODESOURCERY
+#error "ARM_CORTEXM3_CODESOURCERY" not defined
+#endif
+
+#include <machine/endian.h>
diff --git a/lib/c/labcomm_compat_vxworks.h b/lib/c/labcomm_compat_vxworks.h
new file mode 100644
index 0000000000000000000000000000000000000000..f05ee787d334e27dd32ef03bd0ff84b3c2cea086
--- /dev/null
+++ b/lib/c/labcomm_compat_vxworks.h
@@ -0,0 +1,12 @@
+#ifndef  __VXWORKS__
+#error "__VXWORKS__" not defined
+#endif
+
+#if (CPU == PPC603)
+  #undef _LITTLE_ENDIAN
+#endif
+
+#if (CPU == PENTIUM4)
+  #undef _BIG_ENDIAN
+#endif
+
diff --git a/lib/c/labcomm_dynamic_buffer_reader_writer.c b/lib/c/labcomm_dynamic_buffer_writer.c
similarity index 91%
rename from lib/c/labcomm_dynamic_buffer_reader_writer.c
rename to lib/c/labcomm_dynamic_buffer_writer.c
index b363f175bdfdabdc1485db1ff37ca049f5deec28..c651f19797f8859928313cc7b24843de4469cfc9 100644
--- a/lib/c/labcomm_dynamic_buffer_reader_writer.c
+++ b/lib/c/labcomm_dynamic_buffer_writer.c
@@ -1,8 +1,9 @@
-#include "labcomm_dynamic_buffer_reader_writer.h"
+#include "labcomm_dynamic_buffer_writer.h"
 
 int labcomm_dynamic_buffer_writer(
   labcomm_writer_t *w,
-  labcomm_writer_action_t action, ...)
+  labcomm_writer_action_t action,
+  ...)
 {
   switch (action) {
     case labcomm_writer_alloc: {
diff --git a/lib/c/labcomm_dynamic_buffer_reader_writer.h b/lib/c/labcomm_dynamic_buffer_writer.h
similarity index 87%
rename from lib/c/labcomm_dynamic_buffer_reader_writer.h
rename to lib/c/labcomm_dynamic_buffer_writer.h
index b03e4665e020632d031f10758bcdec1c32d4e351..1591b11e905c5607ed7f54385089b8bd7615c984 100644
--- a/lib/c/labcomm_dynamic_buffer_reader_writer.h
+++ b/lib/c/labcomm_dynamic_buffer_writer.h
@@ -9,6 +9,7 @@ extern int labcomm_dynamic_buffer_reader(
 
 extern int labcomm_dynamic_buffer_writer(
   labcomm_writer_t *writer, 
-  labcomm_writer_action_t action, ...);
+  labcomm_writer_action_t action,
+  ...);
 
 #endif
diff --git a/lib/c/labcomm_fd_reader_writer.h b/lib/c/labcomm_fd_reader_writer.h
index 1de585816ab74ab8334d0a897533c8818b6309b1..e5125d549d4623d1d98fabfe832cd4510e8ff574 100644
--- a/lib/c/labcomm_fd_reader_writer.h
+++ b/lib/c/labcomm_fd_reader_writer.h
@@ -9,6 +9,8 @@ extern int labcomm_fd_reader(
 
 extern int labcomm_fd_writer(
   labcomm_writer_t *writer, 
-  labcomm_writer_action_t action, ...);
+  labcomm_writer_action_t action,
+  ...);
 
 #endif
+
diff --git a/lib/c/labcomm_private.h b/lib/c/labcomm_private.h
index ed5894cd316751f442e1254f43c432ea3cdcbc9a..9d66f4433882660e72e052690b286823e48b0bce 100644
--- a/lib/c/labcomm_private.h
+++ b/lib/c/labcomm_private.h
@@ -1,14 +1,10 @@
 #ifndef _LABCOMM_PRIVATE_H_
 #define _LABCOMM_PRIVATE_H_
 
-#ifdef ARM_CORTEXM3_CODESOURCERY
-  #include <machine/endian.h>
+#ifdef LABCOMM_COMPAT
+  #include LABCOMM_COMPAT
 #else
   #include <endian.h>
-#endif
-
-// Some projects can not use stdio.h.
-#ifndef LABCOMM_NO_STDIO
   #include <stdio.h>
 #endif
 
@@ -233,6 +229,16 @@ void labcomm_internal_encode(
   labcomm_signature_t *signature, 
   void *value);
 
+/* Should these really be visible? */
+void labcomm_encoder_start(struct labcomm_encoder *e,
+                           labcomm_signature_t *s) ;
+
+//HERE BE DRAGONS: is the signature_t* needed here?
+void labcomm_encoder_end(struct labcomm_encoder *e,
+                           labcomm_signature_t *s) ;
+
+
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 
 #define LABCOMM_ENCODE(name, type)					\
@@ -330,33 +336,4 @@ static inline void labcomm_encode_string(labcomm_encoder_t *e,
 
 void labcomm_encode_type_index(labcomm_encoder_t *e, labcomm_signature_t *s);
 
-static inline int labcomm_buffer_write(struct labcomm_writer *w, 
-                                       labcomm_writer_action_t action, ...)
-{
-  // If this gets called, it is an error, 
-  // so note error and let producer proceed
-  w->context = w;
-  w->pos = 0;
-  return 0;
-}
-
-
-static inline int labcomm_buffer_writer_error(struct labcomm_writer *w) 
-{
-  return w->context != NULL;
-} 
-
-
-static inline void labcomm_buffer_writer_setup(struct labcomm_writer *w,
-                                               void *data,
-                                               int length)
-{
-  w->context = NULL; // Used as error flag
-  w->data = data;
-  w->data_size = length;
-  w->count = length;
-  w->pos = 0;
-  w->write = labcomm_buffer_write;
-}
-
 #endif
diff --git a/lib/c/test/test_labcomm_errors.c b/lib/c/test/test_labcomm_errors.c
index 8d810d44a5956d55ac449a8bff8fb26943de1713..78085047502070da17d05264fd572a78fb91a366 100644
--- a/lib/c/test/test_labcomm_errors.c
+++ b/lib/c/test/test_labcomm_errors.c
@@ -37,7 +37,7 @@ void reset_callback_erro_id()
   callback_error_id = -128;
 }
 
-int encoded_size_mock(void *voidp)
+int encoded_size_mock(struct labcomm_signature *signature, void *voidp)
 {
   return 0;
 }
@@ -50,7 +50,12 @@ int test_enc_not_reg_encoder_sign()
   labcomm_encoder_t *encoder = labcomm_encoder_new(labcomm_mem_writer, mcontext);
   labcomm_register_error_handler_encoder(encoder, test_callback);
   
-  labcomm_signature_t signature = {.type = 0, .name = "test_signature", .encoded_size = encoded_size_mock, .size = 0, .signature = (unsigned char *) "0"};
+  labcomm_signature_t signature = {
+    .type = 0, 
+    .name = "test_signature", 
+    .encoded_size = encoded_size_mock, 
+    .size = 0, 
+    .signature = (unsigned char *) "0"};
   encoder->do_encode(encoder, &signature, NULL);
 
   return assert_callback(LABCOMM_ERROR_ENC_NO_REG_SIGNATURE, __FUNCTION__, "");