diff --git a/examples/user_types/Makefile b/examples/user_types/Makefile
index 4d68ea9a1ab28408177b093e73c730a919a01919..813d419a720e245cc7c18beb5ce6495c659c022a 100644
--- a/examples/user_types/Makefile
+++ b/examples/user_types/Makefile
@@ -1,7 +1,176 @@
-all:
+LCDIR=../..
+LCCJAR=${LCDIR}/compiler/labcomm_compiler.jar  # the LabComm compiler
+LCLJAR=${LCDIR}/lib/java/labcomm.jar  # the LabComm library
+
+EXECUTABLES=example_encoder example_decoder Encoder.class Decoder.class Encoder.exe Decoder.exe
+include ${LCDIR}/lib/c/os_compat.mk
+
+GENDIR=gen
+
+.PHONY: all cleanbuild clean distclean build run allall buildcs runwcs
+
+all: cleanbuild run
+
+allall: clean build buildcs runwcs
+
+###############################################
+### dependencies and parts ####################
+###############################################
+
+LCC=java -jar ${LCCJAR}
+CLASSPATH=.:${LCLJAR}
+
+${LCCJAR} :
+	$MAKE -C ${LCDIR} make-compiler
+
+${LCLJAR} :
+	$MAKE -C ${LCDIR} labcomm.jar
+
+
+cleanbuild: clean build
+
+labcomm.dll:
+	ln -sf ../../lib/csharp/labcomm.dll $@
+
+Encoder.exe: Encoder.cs gen/test.cs labcomm.dll Makefile
+	mcs -out:$@ $(filter %.cs, $^) -lib:../../lib/csharp/ -r:labcomm
+	chmod a+x $@
+
+Decoder.exe: Decoder.cs gen/test.cs labcomm.dll Makefile
+	mcs -out:$@ $(filter %.cs, $^) -lib:../../lib/csharp/ -r:labcomm
+	chmod a+x $@
+
+build : 
+	mkdir -p ${GENDIR}
+	java -jar ${LCDIR}/compiler/labcomm_compiler.jar --java=${GENDIR} --c=${GENDIR}/test.c --h=${GENDIR}/test.h  --python=${GENDIR}/test.py --cs=${GENDIR}/test.cs test.lc 
+
+	javac -cp ${LCDIR}/lib/java/labcomm.jar:. ${GENDIR}/*.java Encoder.java Decoder.java
+
+	${CC} ${CFLAGS} ${LDFLAGS} -Wall -Werror -Wno-unused-function \
+	    -I. -I${LCDIR}/lib/c -L${LCDIR}/lib/c \
+	    -o example_encoder example_encoder.c ${GENDIR}/test.c \
+	    -llabcomm2014 
+
+	${CC} ${CFLAGS} ${LDFLAGS} -Wall -Werror -I . -I ${LCDIR}/lib/c -L${LCDIR}/lib/c \
+	    -o example_decoder example_decoder.c ${GENDIR}/test.c \
+	    -llabcomm2014 
+
+buildcs: Encoder.exe Decoder.exe
+
+run:
+	export LD_LIBRARY_PATH=${LCDIR}/lib/c/
+	@echo
+	@echo "********************************************"
+	@echo "***   ************ running example for version 2014   ***"
+	@echo "********************************************"
+	@echo
+
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Encoder encoded_data_j
+
+	@echo "************ running Java  decoder: *****************"
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Decoder encoded_data_j
+
+	@echo "************ running C decoder: *****************"
+	@./example_decoder encoded_data_j
+
+	@echo "************ running python decoder (from wiki_example):"
+	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_j LabComm2014
+
+	@echo "************ running C encoder: *****************"
+	@./example_encoder encoded_data_c
+
+	@echo "************ running Java  decoder: *****************"
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Decoder encoded_data_c
+
+	@echo "************ running C decoder: *****************"
+	@./example_decoder encoded_data_c
+
+	@echo "************ running python decoder (from wiki_example):"
+	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_c LabComm2014
+
+	@echo "************ running python encoder: *****************"
+	@PYTHONPATH=${LCDIR}/lib/python:${GENDIR} ./example_encoder.py encoded_data_p LabComm2014
+
+	@echo "************ running Java  decoder: *****************"
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Decoder encoded_data_p
+
+	@echo "************ running C decoder: *****************"
+	@./example_decoder encoded_data_p
+
+	@echo "************ running python decoder (from wiki_example):"
+	PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_p LabComm2014
+
+runwcs: Encoder.exe Decoder.exe
+	export LD_LIBRARY_PATH=${LCDIR}/lib/c/
+	@echo
+	@echo "********************************************"
+	@echo "***   ************ running example for version 2014   ***"
+	@echo "********************************************"
+	@echo
+
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Encoder encoded_data_j
+
+	@echo "************ running Java  decoder: *****************"
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Decoder encoded_data_j
+
+	@echo "************ running C decoder: *****************"
+	@./example_decoder encoded_data_j
+
+	@echo "************ running python decoder (from wiki_example):"
+	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_j LabComm2014
+
+	@echo "************ running C# decoder: *****************"
+	@./Decoder.exe encoded_data_j
+
+	@echo "************ running C encoder: *****************"
+	@./example_encoder encoded_data_c
+
+	@echo "************ running Java  decoder: *****************"
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Decoder encoded_data_c
+
+	@echo "************ running C decoder: *****************"
+	@./example_decoder encoded_data_c
+
+	@echo "************ running python decoder (from wiki_example):"
+	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_c LabComm2014
+
+	@echo "************ running C# decoder: *****************"
+	@./Decoder.exe encoded_data_c
+
+	@echo "************ running python encoder: *****************"
+	@PYTHONPATH=${LCDIR}/lib/python:${GENDIR} ./example_encoder.py encoded_data_p LabComm2014
+
+	@echo "************ running Java  decoder: *****************"
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Decoder encoded_data_p
+
+	@echo "************ running C decoder: *****************"
+	@./example_decoder encoded_data_p
+
+	@echo "************ running python decoder (from wiki_example):"
+	PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_p LabComm2014
+
+	@echo "************ running C# decoder: *****************"
+	@./Decoder.exe encoded_data_p
+
+	@echo "************ running C# encoder: *****************"
+	@./Encoder.exe encoded_data_cs
+
+	@echo "************ running Java  decoder: *****************"
+	@java -cp .:${LCDIR}/lib/java/labcomm.jar:${GENDIR} Decoder encoded_data_cs
+
+	@echo "************ running C decoder: *****************"
+	@./example_decoder encoded_data_cs
+
+	@echo "************ running python decoder (from wiki_example):"
+	@PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_cs LabComm2014
+
+	@echo "************ running C# decoder: *****************"
+	@./Decoder.exe encoded_data_cs
+
+
 
 clean:
+	rm -rf ${GENDIR}
 
-distclean:
-	rm -rf gen
-	rm -f encoded_data
+distclean: clean
+	rm -f ${EXECUTABLES}
diff --git a/examples/user_types/compile.sh b/examples/user_types/compile.sh
deleted file mode 100644
index 42330b2fb69bdc2a14ffe71022b7f794166828b9..0000000000000000000000000000000000000000
--- a/examples/user_types/compile.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-### Example compile script, showing the steps required to build a labcomm application
-### (including compiler and libs).
-
-# For current version (2013)
-(cd ../..; make all)
-
-mkdir -p gen
-java -jar ../../compiler/labcomm_compiler.jar --java=gen --c=gen/test.c --h=gen/test.h  --python=gen/test.py test.lc 
-
-javac -cp ../../lib/java/labcomm2014.jar:. gen/*.java Encoder.java Decoder.java
-
-# for macOS, add     -DLABCOMM_COMPAT=\"labcomm_compat_osx.h\" \
-gcc -Wall -Werror -Wno-unused-function \
-    -I. -I../../lib/c -L../../lib/c \
-    -o example_encoder example_encoder.c gen/test.c \
-    -llabcomm2014 
-
-gcc -Wall -Werror -I . -I ../../lib/c -L../../lib/c \
-    -o example_decoder example_decoder.c gen/test.c \
-    -llabcomm2014 
-    #-Tlabcomm.linkscript
-
diff --git a/examples/user_types/run.sh b/examples/user_types/run.sh
deleted file mode 100644
index dc3a7fddfbf7444e9b79b774b950637db4679025..0000000000000000000000000000000000000000
--- a/examples/user_types/run.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-export LD_LIBRARY_PATH=../../lib/c/
-echo
-echo "********************************************"
-echo "***   Running example for version 2013   ***"
-echo "********************************************"
-echo
-
-java -cp .:../../lib/java/labcomm2014.jar:gen Encoder encoded_data
-
-echo "running Java  decoder:"
-java -cp .:../../lib/java/labcomm2014.jar:gen Decoder encoded_data
-
-echo "running C decoder:"
-./example_decoder encoded_data
-
-echo "running python decoder (from wiki_example):"
-PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm2014
-
-echo "running C encoder:"
-./example_encoder encoded_data
-
-echo "running Java  decoder:"
-java -cp .:../../lib/java/labcomm2014.jar:gen Decoder encoded_data
-
-echo "running C decoder:"
-./example_decoder encoded_data
-
-echo "running python decoder (from wiki_example):"
-PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm2014
-
-echo "running python encoder:"
-PYTHONPATH=../../lib/python:gen ./example_encoder.py encoded_data2
-
-echo "running Java  decoder:"
-java -cp .:../../lib/java/labcomm2014.jar:gen Decoder encoded_data2
-
-echo "running C decoder:"
-./example_decoder encoded_data2
-
diff --git a/lib/c/Makefile b/lib/c/Makefile
index 55a232cfca810a717150eced0a22cdc9f01b302f..46163cbee453a111389d6f586db9436853336de2 100644
--- a/lib/c/Makefile
+++ b/lib/c/Makefile
@@ -1,38 +1,8 @@
 ## Macros
-UNAME_S=$(shell uname -s)
-ALL_DEPS=liblabcomm.a liblabcomm.so.1 liblabcomm2006.a liblabcomm2006.so.1  liblabcomm2014.a liblabcomm2014.so.1
+include os_compat.mk
 
-ifeq ($(UNAME_S),Linux)
-  CFLAGS=-std=c99 -g -Wall -Werror -O3  -I. -Itest -I2006
-  CC=$(CROSS_COMPILE)gcc
-  LD=$(CROSS_COMPILE)ld
-  LDFLAGS=-L.
-  LDLIBS=-llabcomm -llabcomm2006 -lrt
-  MAKESHARED=gcc -o $1 -shared -Wl,-soname,$2 $3 -lc -lrt
-else ifeq ($(UNAME_S),Darwin)
-  CC=$(CROSS_COMPILE)clang
-  LD=$(CROSS_COMPILE)ld
-  CFLAGS=-g -Wall -Werror -O3  -I. -Itest \
-	 -DLABCOMM_COMPAT=\"labcomm_compat_osx.h\" \
-	 -Wno-tautological-compare -Wno-unused-function
-  LDFLAGS=-L.
-  LDLIBS=-llabcomm -llabcomm2006 
-  MAKESHARED=clang -o $1 -shared -Wl,-install_name,$2 $3 -lc
-else ifneq ($(findstring CYGWIN,$(UNAME_S)),)
-  CFLAGS=-std=c99 -g -Wall -Werror -O3  -I. -Itest
-  CC=$(CROSS_COMPILE)gcc
-  LD=$(CROSS_COMPILE)ld
-  LDFLAGS=-L.
-  LDLIBS=-llabcomm -lrt
-  ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS)) # No -fPIC supported in windows?
-else
-  $(error Unknown system $(UNAME_S))
-endif
+ALL_DEPS=liblabcomm.a liblabcomm.so.1 liblabcomm2006.a liblabcomm2006.so.1  liblabcomm2014.a liblabcomm2014.so.1
 
-ifeq ($(CROSS_COMPILE),i586-wrs-vxworks-)
-  ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS)) # PIC is only supported for RTPs
-  CFLAGS:=$(CFLAGS) -DLABCOMM_COMPAT=\"labcomm_compat_vxworks.h\"
-endif
 # TODO: Support for Codesourcery ARM toolchain.
 
 OBJS2006=2006/labcomm2006_memory.o \
diff --git a/lib/c/os_compat.mk b/lib/c/os_compat.mk
new file mode 100644
index 0000000000000000000000000000000000000000..553d0b1bf19971a8b2bd52dd3a0ad16756140017
--- /dev/null
+++ b/lib/c/os_compat.mk
@@ -0,0 +1,34 @@
+## Macros
+UNAME_S=$(shell uname -s)
+
+ifeq ($(UNAME_S),Linux)
+  CFLAGS=-std=c99 -g -Wall -Werror -O3  -I. -Itest -I2006
+  CC=$(CROSS_COMPILE)gcc
+  LD=$(CROSS_COMPILE)ld
+  LDFLAGS=-L.
+  LDLIBS=-llabcomm -llabcomm2006 -lrt
+  MAKESHARED=gcc -o $1 -shared -Wl,-soname,$2 $3 -lc -lrt
+else ifeq ($(UNAME_S),Darwin)
+  CC=$(CROSS_COMPILE)clang
+  LD=$(CROSS_COMPILE)ld
+  CFLAGS=-g -Wall -Werror -O3  -I. -Itest \
+	 -DLABCOMM_COMPAT=\"labcomm_compat_osx.h\" \
+	 -Wno-tautological-compare -Wno-unused-function
+  LDFLAGS=-L.
+  LDLIBS=-llabcomm -llabcomm2006 
+  MAKESHARED=clang -o $1 -shared -Wl,-install_name,$2 $3 -lc
+else ifneq ($(findstring CYGWIN,$(UNAME_S)),)
+  CFLAGS=-std=c99 -g -Wall -Werror -O3  -I. -Itest
+  CC=$(CROSS_COMPILE)gcc
+  LD=$(CROSS_COMPILE)ld
+  LDFLAGS=-L.
+  LDLIBS=-llabcomm -lrt
+  ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS)) # No -fPIC supported in windows?
+else
+  $(error Unknown system $(UNAME_S))
+endif
+
+ifeq ($(CROSS_COMPILE),i586-wrs-vxworks-)
+  ALL_DEPS:=$(filter-out %.so.1, $(ALL_DEPS)) # PIC is only supported for RTPs
+  CFLAGS:=$(CFLAGS) -DLABCOMM_COMPAT=\"labcomm_compat_vxworks.h\"
+endif