diff --git a/.gitignore b/.gitignore
index a232684a944c9683dd4ad99e698bb58a593758a0..55247d40c21f3e779c5cbb6f3c531e9c580d9d03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,9 +6,9 @@ lib/c/liblabcomm.so.1
 lib/c/liblabcomm2006.so.1
 lib/c/liblabcomm2006.so
 lib/c/liblabcomm2006.a
-lib/c/liblabcomm2013.so.1
-lib/c/liblabcomm2013.so
-lib/c/liblabcomm2013.a
+lib/c/liblabcomm2014.so.1
+lib/c/liblabcomm2014.so
+lib/c/liblabcomm2014.a
 lib/c/test/test_labcomm
 lib/c/test/test_labcomm_basic_type_encoding
 lib/c/test/test_labcomm_copy
@@ -26,3 +26,7 @@ examples/twoway/gen/
 lib/csharp/labcomm.dll
 lib/java/gen/
 lib/java/labcomm*.jar
+examples/simple/example_decoder
+examples/simple/example_decoder06
+examples/simple/example_encoder
+examples/simple/example_encoder06
diff --git a/compiler/CS_CodeGen.jrag b/compiler/CS_CodeGen.jrag
index c147dc6da26ea3a57bab97c551c31a64aad1a78e..a4a42e03e44a1ce651c15299ddfb800fc77f07b2 100644
--- a/compiler/CS_CodeGen.jrag
+++ b/compiler/CS_CodeGen.jrag
@@ -268,7 +268,7 @@ aspect CS_Class {
       pp(env.getPrintStream());
       env.println("*/");
       env.println();
-      env.println("public class " + getName() + " : LabCommType {");
+      env.println("public class " + getName() + " : SampleType {");
       env.println();
       env.indent();
       getType().CS_emitInstance(env);
@@ -284,11 +284,11 @@ aspect CS_Class {
     pp(env.getPrintStream());
     env.println("*/");
     env.println();
-    env.println("public class " + getName() + " : LabCommSample {");
+    env.println("public class " + getName() + " : Sample {");
     env.println();
     env.indent();
     getType().CS_emitInstance(env);
-    env.println("public interface Handler : LabCommHandler {");
+    env.println("public interface Handler : SampleHandler {");
     env.print("  void handle(");
     if (!isVoid()) {
       getType().CS_emitType(env);
@@ -297,21 +297,21 @@ aspect CS_Class {
     env.println(");");
     env.println("}");
     env.println();
-    env.println("public static void register(LabCommDecoder d, Handler h) {");
+    env.println("public static void register(Decoder d, Handler h) {");
     env.indent();
     env.println("d.register(new Dispatcher(), h);");
     env.unindent();
     env.println("}");
     env.println();
 
-    env.println("public static void register(LabCommEncoder e) {");
+    env.println("public static void register(Encoder e) {");
     env.indent();
     env.println("e.register(new Dispatcher());");
     env.unindent();
     env.println("}");
     env.println(); 
 
-    env.println("private class Dispatcher : LabCommDispatcher {");
+    env.println("private class Dispatcher : SampleDispatcher {");
     env.indent();
     env.println(); 
     env.println("public Type getSampleClass() {");
@@ -332,7 +332,7 @@ aspect CS_Class {
     env.unindent();
     env.println("}");
     env.println(); 
-    env.println("public void decodeAndHandle(LabCommDecoder d, LabCommHandler h) {");
+    env.println("public void decodeAndHandle(Decoder d, SampleHandler h) {");
     env.indent();
     if (isVoid()) {
       env.println(getName() + ".decode(d);");
@@ -374,7 +374,7 @@ aspect CS_Class {
   }
 
   public void TypeDecl.CS_emitEncoder(CS_env env) {
-    env.print("public static void encode(LabCommEncoder e");
+    env.print("public static void encode(Encoder e");
     if (!isVoid()) {
       env.print(", ");
       getType().CS_emitType(env);
@@ -389,7 +389,7 @@ aspect CS_Class {
   }
 
   public void SampleDecl.CS_emitEncoder(CS_env env) {
-    env.print("public static void encode(LabCommEncoder e");
+    env.print("public static void encode(Encoder e");
     if (!isVoid()) {
       env.print(", ");
       getType().CS_emitType(env);
@@ -485,7 +485,7 @@ aspect CS_Class {
   public void Decl.CS_emitDecoder(CS_env env) {
     env.print("public static ");
     getType().CS_emitType(env);
-    env.println(" decode(LabCommDecoder d) {");
+    env.println(" decode(Decoder d) {");
     env.indent();
     if (!isVoid()) {
       getType().CS_emitType(env);
diff --git a/compiler/C_CodeGen.jrag b/compiler/C_CodeGen.jrag
index 25d5fedac7f383c1721d62d9219759417aa81d21..9064f53d7eedddfac9d8d4237a9c095cace5322b 100644
--- a/compiler/C_CodeGen.jrag
+++ b/compiler/C_CodeGen.jrag
@@ -1188,12 +1188,12 @@ aspect C_Signature {
       }
     }
     env.println("};");
+    C_emitSizeofValue(env);
     env.println("struct labcomm"+env.verStr+"_signature labcomm"+env.verStr+"_signature_" + 
 		env.prefix + getName() + " = {");
     env.indent();
-    env.println("LABCOMM_SAMPLE, \"" + getName() + "\",");
-    env.println("(int (*)(struct labcomm"+env.verStr+"_signature *, void *))labcomm"+env.verStr+"_sizeof_" + 
-		env.prefix + getName() + ",");
+    env.println("\"" + getName() + "\",");
+    env.println("sizeof_" + env.prefix + getName() + ",");
     env.println("sizeof(signature_bytes_" + env.prefix + getName() + "),");
     env.println("signature_bytes_" + env.prefix + getName() + ",");
     env.println("0");
@@ -1260,6 +1260,22 @@ aspect C_Sizeof {
     return getType().C_fixedSizeof();
   }
 
+  public void Decl.C_emitSizeof(C_env env) {
+  }
+
+  public void SampleDecl.C_emitSizeof(C_env env) {
+    env = env.nestStruct("(*v)");
+    env.println("int labcomm"+env.verStr+"_sizeof_" + env.prefix + getName() +
+		"(" + env.prefix + getName() + " *v)");
+    env.println("{");
+    env.indent();
+    env.println("return labcomm"+env.verStr+"_internal_sizeof(" +
+                "&labcomm" + env.verStr+"_signature_" + env.prefix + getName() +
+                ", v);");
+    env.unindent();
+    env.println("}");
+  }
+
   public int Type.C_fixedSizeof() {
     throw new Error(this.getClass().getName() + 
 		    ".C_fixedSizeof()" + 
@@ -1308,18 +1324,17 @@ aspect C_Sizeof {
     return getType().C_fixedSizeof() * elements;
   }
 
-  public void Decl.C_emitSizeof(C_env env) {
+  public void Decl.C_emitSizeofValue(C_env env) {
   }
 
-  public void SampleDecl.C_emitSizeof(C_env env) {
+  public void SampleDecl.C_emitSizeofValue(C_env env) {
     env = env.nestStruct("(*v)");
-    env.println("int labcomm"+env.verStr+"_sizeof_" + env.prefix + getName() +
-		"(" + env.prefix + getName() + " *v)");
+    env.println("static int sizeof_" + env.prefix + getName() + "(void *vv)");
     env.println("{");
     env.indent();
-    env.println("int result = labcomm"+env.verStr+"_size_packed32(labcomm"+env.verStr+"_signature_" + 
-                env.prefix + getName() +".index);");
+    env.println("int result = 0;");
     if (C_isDynamic()) {
+      env.println(env.prefix + getName() + " *v = vv;");
       getType().C_emitSizeof(env);
     } else {
       env.println("result += " + C_fixedSizeof() + ";");
@@ -1338,7 +1353,8 @@ aspect C_Sizeof {
   public void PrimType.C_emitSizeof(C_env env) {
     switch (getToken()) {
       case LABCOMM_STRING: { 
-	env.println("result += 0 + strlen(" + env.qualid + ");"); 
+        env.print("{ int l = strlen(" + env.qualid + "); ");
+	env.println("result += labcomm"+env.verStr+"_size_packed32(l) + l; }"); 
       } break;
       default: { 
 	throw new Error(this.getClass().getName() + 
diff --git a/compiler/Java_CodeGen.jrag b/compiler/Java_CodeGen.jrag
index b01ff8f02e5052fd9979c69ed60bee9e32768586..c21260b249922d3fba854ce0b298d09e09dbb6b9 100644
--- a/compiler/Java_CodeGen.jrag
+++ b/compiler/Java_CodeGen.jrag
@@ -206,21 +206,6 @@ aspect Java_CodeGen {
 
   public void Program.J_gen(PrintStream ps, String pack, int version) throws IOException {
     Java_env env;
-/*
-    // Registration class
-    env = new Java_env(version, ps);
-    if (pack != null && pack.length() > 0) {
-      env.println("package " + pack + ";");
-    }
-    env.println("public class LabCommRegister {");
-    env.println();
-    env.indent();
-    Java_emitTypeRegister(env);
-    env.unindent();
-    env.println();
-    env.println("}");
-//    env.close();
-*/
     env = new Java_env(version, ps);
     for (int i = 0; i < getNumDecl(); i++) {
       Decl d = getDecl(i);
@@ -236,21 +221,6 @@ aspect Java_CodeGen {
 
   public void Program.J_gen(String dir, String pack, int version) throws IOException {
     Java_env env;
-/*
-    // Registration class
-    env = new Java_env(version, new File(dir, "LabCommRegister.java"));
-    if (pack != null && pack.length() > 0) {
-      env.println("package " + pack + ";");
-    }
-    env.println("public class LabCommRegister {");
-    env.println();
-    env.indent();
-    Java_emitTypeRegister(env);
-    env.unindent();
-    env.println();
-    env.println("}");
-    env.close();
-*/
     for (int i = 0; i < getNumDecl(); i++) {
       Decl d = getDecl(i);
       try {
@@ -286,38 +256,6 @@ aspect Java_CodeGen {
       }
     }
   }
-
-}
-
-aspect Java_Register {
-
-  public void Program.Java_emitTypeRegister(Java_env env) {
-    /*
-    env.println("static void register(LabCommChannel c) {");
-    env.indent();
-    for (int i = 0; i < getNumDecl(); i++) {
-      getDecl(i).Java_emitTypeRegister(env);
-    }
-    env.unindent();
-    env.println("}");
-*/
-
-  }
-
-  public void Decl.Java_emitTypeRegister(Java_env env) {
-    throw new Error(this.getClass().getName() + 
-		    ".Java_emitTypeRegister(Java_env env)" + 
-		    " not declared");
-  }
-
-  public void SampleDecl.Java_emitTypeRegister(Java_env env) {
-    env.println(getName() + ".register(c);");
-  }
-
-  public void TypeDecl.Java_emitTypeRegister(Java_env env) {
-    // TODO
-  }
-
 }
 
 aspect Java_Class {
@@ -340,11 +278,11 @@ aspect Java_Class {
       }
 
       env.println("import java.io.IOException;");
-      env.println("import se.lth.control.labcomm"+env.verStr+".LabCommType;");
-      env.println("import se.lth.control.labcomm"+env.verStr+".LabCommEncoder;");
-      env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDecoder;");
+      env.println("import se.lth.control.labcomm"+env.verStr+".SampleType;");
+      env.println("import se.lth.control.labcomm"+env.verStr+".Encoder;");
+      env.println("import se.lth.control.labcomm"+env.verStr+".Decoder;");
       env.println();
-      env.println("public class " + getName() + " implements LabCommType {");
+      env.println("public class " + getName() + " implements SampleType {");
       env.println();
       env.indent();
       getType().Java_emitInstance(env);
@@ -380,21 +318,21 @@ aspect Java_Class {
     }
 
     env.println("import java.io.IOException;");
-    env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDecoder;");
-    env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDispatcher;");
-    env.println("import se.lth.control.labcomm"+env.verStr+".LabCommEncoder;");
-    env.println("import se.lth.control.labcomm"+env.verStr+".LabCommHandler;");
-    env.println("import se.lth.control.labcomm"+env.verStr+".LabCommSample;");
+    env.println("import se.lth.control.labcomm"+env.verStr+".Decoder;");
+    env.println("import se.lth.control.labcomm"+env.verStr+".SampleDispatcher;");
+    env.println("import se.lth.control.labcomm"+env.verStr+".Encoder;");
+    env.println("import se.lth.control.labcomm"+env.verStr+".SampleHandler;");
+    env.println("import se.lth.control.labcomm"+env.verStr+".Sample;");
     env.println();
     env.print("public class " + getName());
 //    if(getType().isUserType()) {
 //        env.print(" extends "+getType().getTypeName());
 //    }
-    env.println(" implements LabCommSample {");
+    env.println(" implements Sample {");
     env.println();
     env.indent();
     getType().Java_emitInstance(env);
-    env.println("public interface Handler extends LabCommHandler {");
+    env.println("public interface Handler extends SampleHandler {");
     env.print("  public void handle_" + getName() + "(");
     if (!isVoid()) {
       getType().Java_emitType(env);
@@ -403,21 +341,21 @@ aspect Java_Class {
     env.println(") throws Exception;");
     env.println("}");
     env.println();
-    env.println("public static void register(LabCommDecoder d, Handler h) throws IOException {");
+    env.println("public static void register(Decoder d, SampleHandler h) throws IOException {");
     env.indent();
     env.println("d.register(new Dispatcher(), h);");
     env.unindent();
     env.println("}");
     env.println();
 
-    env.println("public static void register(LabCommEncoder e) throws IOException {");
+    env.println("public static void register(Encoder e) throws IOException {");
     env.indent();
     env.println("e.register(new Dispatcher());");
     env.unindent();
     env.println("}");
     env.println(); 
 
-    env.println("private static class Dispatcher implements LabCommDispatcher {");
+    env.println("private static class Dispatcher implements SampleDispatcher {");
     env.indent();
     env.println(); 
     env.println("public Class getSampleClass() {");
@@ -438,8 +376,8 @@ aspect Java_Class {
     env.unindent();
     env.println("}");
     env.println(); 
-    env.println("public void decodeAndHandle(LabCommDecoder d,");
-    env.println("                            LabCommHandler h) throws Exception {");
+    env.println("public void decodeAndHandle(Decoder d,");
+    env.println("                            SampleHandler h) throws Exception {");
     env.indent();
     if (isVoid()) {
       env.println(getName() + ".decode(d);");
@@ -481,7 +419,7 @@ aspect Java_Class {
   }
 
   public void TypeDecl.Java_emitEncoder(Java_env env) {
-    env.print("public static void encode(LabCommEncoder e");
+    env.print("public static void encode(Encoder e");
     if (!isVoid()) {
       env.print(", ");
       getType().Java_emitType(env);
@@ -496,7 +434,7 @@ aspect Java_Class {
   }
 
   public void SampleDecl.Java_emitEncoder(Java_env env) {
-    env.print("public static void encode(LabCommEncoder e");
+    env.print("public static void encode(Encoder e");
     if (!isVoid()) {
       env.print(", ");
       getType().Java_emitType(env);
@@ -588,7 +526,7 @@ aspect Java_Class {
   public void Decl.Java_emitDecoder(Java_env env) {
     env.print("public static ");
     getType().Java_emitType(env);
-    env.println(" decode(LabCommDecoder d) throws IOException {");
+    env.println(" decode(Decoder d) throws IOException {");
     env.indent();
     if (!isVoid()) {
       getType().Java_emitType(env);
diff --git a/compiler/Python_CodeGen.jrag b/compiler/Python_CodeGen.jrag
index ff6cef0c6e1917c9efebd141e3790926cbcbf274..7a41813a73ccde3f497e9772c5b6ea68a8a4a6e1 100644
--- a/compiler/Python_CodeGen.jrag
+++ b/compiler/Python_CodeGen.jrag
@@ -83,6 +83,7 @@ aspect Python_CodeGen {
     env.println("import labcomm");
     env.println();
     Python_genTypes(env);
+/* Typedefs curenntly disabled
     env.println("typedef = [");
     env.indent();
     for (int i = 0 ; i < getNumDecl() ; i++) {
@@ -90,6 +91,7 @@ aspect Python_CodeGen {
     }
     env.unindent();
     env.println("]");
+*/
     env.println("sample = [");
     env.indent();
     for (int i = 0 ; i < getNumDecl() ; i++) {
@@ -105,11 +107,7 @@ aspect PythonTypes {
   
   public void Program.Python_genTypes(Python_env env) {
     for (int i = 0 ; i < getNumDecl() ; i++) {
-      env.println("class " + getDecl(i).getName() + "(object):");
-      env.indent();
       getDecl(i).Python_genSignature(env);
-      env.unindent();
-      env.println();
     }
   }
 
@@ -120,19 +118,29 @@ aspect PythonTypes {
   }
 
   public void TypeDecl.Python_genSignature(Python_env env) {
+/*
+    env.println("class " + getName() + "(object):");
+    env.indent();
     env.println("signature = labcomm.typedef('" + getName() + "',");
     env.indent();
     getType().Python_genSignature(env);
     env.unindent();
     env.println(")");
+    env.unindent();
+    env.println();
+*/
   }
 
   public void SampleDecl.Python_genSignature(Python_env env) {
+    env.println("class " + getName() + "(object):");
+    env.indent();
     env.println("signature = labcomm.sample('" + getName() + "', ");
     env.indent();
     getType().Python_genSignature(env);
     env.unindent();
     env.println(")");
+    env.unindent();
+    env.println();
   }
 
   public void UserType.Python_genSignature(Python_env env) {
diff --git a/examples/dynamic/test/DynamicPart.java b/examples/dynamic/test/DynamicPart.java
index 334d493c421bcc46fd8139fe899a379b729e4940..a3137220ca98e8e00ddf25a6b879d2406d3817c6 100644
--- a/examples/dynamic/test/DynamicPart.java
+++ b/examples/dynamic/test/DynamicPart.java
@@ -18,12 +18,12 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Map;
 
-import se.lth.control.labcomm.LabCommDecoder;
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoder;
-import se.lth.control.labcomm.LabCommEncoderChannel;
-import AST.LabCommParser;
-import AST.LabCommScanner;
+import se.lth.control.labcomm.Decoder;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.Encoder;
+import se.lth.control.labcomm.EncoderChannel;
+import AST.Parser;
+import AST.Scanner;
 import AST.Program;
 import beaver.Parser.Exception;
 
@@ -160,8 +160,8 @@ public class DynamicPart {
 	public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
 		Program ast = null;
 		InputStream in = new ByteArrayInputStream(lcDecl.getBytes());
-		LabCommScanner scanner = new LabCommScanner(in);
-		LabCommParser parser = new LabCommParser();
+		Scanner scanner = new Scanner(in);
+		Parser parser = new Parser();
 		Collection errors = new LinkedList();
 
 		InRAMCompiler irc = null;
@@ -272,7 +272,7 @@ public class DynamicPart {
 	private void decodeTest(InRAMCompiler irc, HandlerContext ctxt, String tmpFile, String... sampleNames) {
 		try {
 			FileInputStream in = new FileInputStream(tmpFile);
-			LabCommDecoderChannel dec = new LabCommDecoderChannel(in);
+			DecoderChannel dec = new DecoderChannel(in);
 			Class handlerClass =  irc.load(handlerClassName);
 			Constructor hcc = handlerClass.getDeclaredConstructor(Object.class);
 			Object handler = hcc.newInstance(ctxt);
@@ -282,7 +282,7 @@ public class DynamicPart {
 				Class sampleClass = irc.load(sampleName);
 				Class handlerInterface = irc.load(sampleName+"$Handler");
 
-				Method reg = sampleClass.getDeclaredMethod("register", LabCommDecoder.class, handlerInterface);
+				Method reg = sampleClass.getDeclaredMethod("register", Decoder.class, handlerInterface);
 				reg.invoke(sampleClass, dec, handler);
 			}
 
@@ -324,20 +324,20 @@ public class DynamicPart {
 
 
 			FileOutputStream out = new FileOutputStream(tmpFile);
-			LabCommEncoderChannel enc = new LabCommEncoderChannel(out);
+			EncoderChannel enc = new EncoderChannel(out);
 
 			/* register and send foo */
-			Method regFoo = fc.getDeclaredMethod("register", LabCommEncoder.class);
+			Method regFoo = fc.getDeclaredMethod("register", Encoder.class);
 			regFoo.invoke(fc, enc);
 
-			Method doEncodeFoo = fc.getDeclaredMethod("encode", LabCommEncoder.class, ft);
+			Method doEncodeFoo = fc.getDeclaredMethod("encode", Encoder.class, ft);
 			doEncodeFoo.invoke(fc, enc, fv);
 
 			/* register and send bar (NB! uses primitive type int) */
-			Method regBar = bc.getDeclaredMethod("register", LabCommEncoder.class);
+			Method regBar = bc.getDeclaredMethod("register", Encoder.class);
 			regBar.invoke(bc, enc);
 
-			Method doEncodeBar = bc.getDeclaredMethod("encode", LabCommEncoder.class, Integer.TYPE);
+			Method doEncodeBar = bc.getDeclaredMethod("encode", Encoder.class, Integer.TYPE);
 			doEncodeBar.invoke(bc, enc, ctxt.bar);
 
 			out.close();
diff --git a/examples/dynamic/test/StaticDecoder.java b/examples/dynamic/test/StaticDecoder.java
index b3d74edf4c407397f2aae315b1899303ad27d6f9..c1c06d3b90a06270ceaaa0b492fc580a4c1dcd07 100644
--- a/examples/dynamic/test/StaticDecoder.java
+++ b/examples/dynamic/test/StaticDecoder.java
@@ -6,16 +6,16 @@ import gen.bar;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
-import se.lth.control.labcomm.LabCommDecoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
 
 
 public class StaticDecoder implements foo.Handler, bar.Handler
 {
 
-  LabCommDecoderChannel decoder;
+  DecoderChannel decoder;
 
   public StaticDecoder(InputStream in) throws Exception {
-    decoder = new LabCommDecoderChannel(in);
+    decoder = new DecoderChannel(in);
     foo.register(decoder, this);
     bar.register(decoder, this);
 
diff --git a/examples/dynamic/test/StaticEncoder.java b/examples/dynamic/test/StaticEncoder.java
index 697f339e8335de34a4aef9f6bbdc3928d2c207f2..4ea48be4e2e94daf915caac4bb4a2ac2a0ad33f5 100644
--- a/examples/dynamic/test/StaticEncoder.java
+++ b/examples/dynamic/test/StaticEncoder.java
@@ -2,19 +2,19 @@ package test;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 
 import gen.foo;
 import gen.bar;
 
 public class StaticEncoder {
 
-  LabCommEncoderChannel encoder;
+  EncoderChannel encoder;
 
   public StaticEncoder(OutputStream out) 
     throws Exception 
   {
-    encoder = new LabCommEncoderChannel(out);
+    encoder = new EncoderChannel(out);
     foo.register(encoder);
     bar.register(encoder);
   }
diff --git a/examples/dynamic/test/TestLabCommCompiler.java b/examples/dynamic/test/TestLabCommCompiler.java
index a71e0a67125fd30ac8d34d78276c021743902b35..fe9f5e659633cf036698e2c531a1a295dc99bf32 100644
--- a/examples/dynamic/test/TestLabCommCompiler.java
+++ b/examples/dynamic/test/TestLabCommCompiler.java
@@ -16,18 +16,18 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Map;
 
-import se.lth.control.labcomm.LabCommDecoder;
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoder;
-import se.lth.control.labcomm.LabCommEncoderChannel;
-import AST.LabCommParser;
-import AST.LabCommScanner;
+import se.lth.control.labcomm.Decoder;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.Encoder;
+import se.lth.control.labcomm.EncoderChannel;
+import AST.Parser;
+import AST.Scanner;
 import AST.Program;
 import beaver.Parser.Exception;
 
 
 
-public class TestLabCommCompiler {
+public class TestCompiler {
 
 	private static final String BAR = "bar";
 	private static final String FOO = "foo";
@@ -73,7 +73,7 @@ public class TestLabCommCompiler {
 	private static void decodeTest(InRAMCompiler irc, String tmpFile) {
 		try {
 			FileInputStream in = new FileInputStream(tmpFile);
-			LabCommDecoderChannel dec = new LabCommDecoderChannel(in);
+			DecoderChannel dec = new DecoderChannel(in);
 	
 			Class fc = irc.load(FOO);
 			Class hc = irc.load("gen_"+FOO+"Handler");
@@ -81,7 +81,7 @@ public class TestLabCommCompiler {
 
 			Object h = hc.newInstance(); 
 		
-			Method reg = fc.getDeclaredMethod("register", LabCommDecoder.class, hi);
+			Method reg = fc.getDeclaredMethod("register", Decoder.class, hi);
 			reg.invoke(fc, dec, h);
 			
 			dec.runOne();
@@ -106,11 +106,11 @@ public class TestLabCommCompiler {
 			z.setInt(f, 12);
 			
 			FileOutputStream out = new FileOutputStream(tmpFile);
-			LabCommEncoderChannel enc = new LabCommEncoderChannel(out);
-			Method reg = fc.getDeclaredMethod("register", LabCommEncoder.class);
+			EncoderChannel enc = new EncoderChannel(out);
+			Method reg = fc.getDeclaredMethod("register", Encoder.class);
 			reg.invoke(fc, enc);
 			
-			Method doEncode = fc.getDeclaredMethod("encode", LabCommEncoder.class, fc);
+			Method doEncode = fc.getDeclaredMethod("encode", Encoder.class, fc);
 			doEncode.invoke(fc, enc, f);
 			
 			out.close();
@@ -123,8 +123,8 @@ public class TestLabCommCompiler {
 	public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
 		Program ast = null;
 		InputStream in = new ByteArrayInputStream(lcDecl.getBytes());
-		LabCommScanner scanner = new LabCommScanner(in);
-		LabCommParser parser = new LabCommParser();
+		Scanner scanner = new Scanner(in);
+		Parser parser = new Parser();
 		Collection errors = new LinkedList();
 
 		InRAMCompiler irc = null;
diff --git a/examples/dynamic/test/TestLabcommGen.java b/examples/dynamic/test/TestLabcommGen.java
index 1ad36b4d81b10b5f289ba28004417044834be04e..7ff4e03a3f12cee2e4c321b90f6ef067d397ac76 100644
--- a/examples/dynamic/test/TestLabcommGen.java
+++ b/examples/dynamic/test/TestLabcommGen.java
@@ -18,12 +18,12 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Map;
 
-import se.lth.control.labcomm.LabCommDecoder;
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoder;
-import se.lth.control.labcomm.LabCommEncoderChannel;
-import AST.LabCommParser;
-import AST.LabCommScanner;
+import se.lth.control.labcomm.Decoder;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.Encoder;
+import se.lth.control.labcomm.EncoderChannel;
+import AST.Parser;
+import AST.Scanner;
 import AST.Program;
 import beaver.Parser.Exception;
 
@@ -163,8 +163,8 @@ public class TestLabcommGen {
 	public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
 		Program ast = null;
 		InputStream in = new ByteArrayInputStream(lcDecl.getBytes());
-		LabCommScanner scanner = new LabCommScanner(in);
-		LabCommParser parser = new LabCommParser();
+		Scanner scanner = new Scanner(in);
+		Parser parser = new Parser();
 		Collection errors = new LinkedList();
 
 		InRAMCompiler irc = null;
@@ -332,7 +332,7 @@ public class TestLabcommGen {
 	private static void decodeTest(InRAMCompiler irc, String tmpFile, String... sampleNames) {
 		try {
 			FileInputStream in = new FileInputStream(tmpFile);
-			LabCommDecoderChannel dec = new LabCommDecoderChannel(in);
+			DecoderChannel dec = new DecoderChannel(in);
 			Class handlerClass =  irc.load(handlerClassName);
 			Constructor hcc = handlerClass.getDeclaredConstructor(Object.class);
 //			Object handler = handlerClass.newInstance(); 
@@ -344,7 +344,7 @@ public class TestLabcommGen {
 				Class sampleClass = irc.load(sampleName);
 				Class handlerInterface = irc.load(sampleName+"$Handler");
 
-				Method reg = sampleClass.getDeclaredMethod("register", LabCommDecoder.class, handlerInterface);
+				Method reg = sampleClass.getDeclaredMethod("register", Decoder.class, handlerInterface);
 				reg.invoke(sampleClass, dec, handler);
 			}
 
@@ -389,20 +389,20 @@ public class TestLabcommGen {
 
 
 			FileOutputStream out = new FileOutputStream(tmpFile);
-			LabCommEncoderChannel enc = new LabCommEncoderChannel(out);
+			EncoderChannel enc = new EncoderChannel(out);
 
 			/* register and send foo */
-			Method regFoo = fc.getDeclaredMethod("register", LabCommEncoder.class);
+			Method regFoo = fc.getDeclaredMethod("register", Encoder.class);
 			regFoo.invoke(fc, enc);
 
-			Method doEncodeFoo = fc.getDeclaredMethod("encode", LabCommEncoder.class, ft);
+			Method doEncodeFoo = fc.getDeclaredMethod("encode", Encoder.class, ft);
 			doEncodeFoo.invoke(fc, enc, f);
 
 			/* register and send bar (NB! uses primitive type int) */
-			Method regBar = bc.getDeclaredMethod("register", LabCommEncoder.class);
+			Method regBar = bc.getDeclaredMethod("register", Encoder.class);
 			regBar.invoke(bc, enc);
 
-			Method doEncodeBar = bc.getDeclaredMethod("encode", LabCommEncoder.class, Integer.TYPE);
+			Method doEncodeBar = bc.getDeclaredMethod("encode", Encoder.class, Integer.TYPE);
 			doEncodeBar.invoke(bc, enc, 42);
 
 			out.close();
@@ -475,7 +475,7 @@ public class TestLabcommGen {
 	private static void decodeTestSeparate(InRAMCompiler irc, String tmpFile, String... sampleNames) {
 		try {
 			FileInputStream in = new FileInputStream(tmpFile);
-			LabCommDecoderChannel dec = new LabCommDecoderChannel(in);
+			DecoderChannel dec = new DecoderChannel(in);
 			for (String sampleName : sampleNames) {
 				System.out.println("registering handler for "+sampleName);
 				Class sampleClass = irc.load(sampleName);
@@ -484,7 +484,7 @@ public class TestLabcommGen {
 
 				Object handler = handlerClass.newInstance(); 
 
-				Method reg = sampleClass.getDeclaredMethod("register", LabCommDecoder.class, handlerInterface);
+				Method reg = sampleClass.getDeclaredMethod("register", Decoder.class, handlerInterface);
 				reg.invoke(sampleClass, dec, handler);
 			}
 
diff --git a/examples/jgrafchart/labcommTCPtest/client/TestClient.java b/examples/jgrafchart/labcommTCPtest/client/TestClient.java
index 0582d9e912c5b7f7eb841e402f4f421406ba59f5..66fa1342e470b12c1516ceacdd89a85b4a7d0616 100644
--- a/examples/jgrafchart/labcommTCPtest/client/TestClient.java
+++ b/examples/jgrafchart/labcommTCPtest/client/TestClient.java
@@ -6,8 +6,8 @@ import java.io.OutputStream;
 import java.net.Socket;
 import java.net.UnknownHostException;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 import labcommTCPtest.gen.foo;
 import labcommTCPtest.gen.foo.Handler;
 
@@ -25,7 +25,7 @@ public class TestClient implements Handler {
 	public void test() {
 		
 		try {
-			LabCommEncoderChannel e = new LabCommEncoderChannel(out );
+			EncoderChannel e = new EncoderChannel(out );
 			foo.register(e);
 			foo sample = new foo();
 			sample.c = 17;
@@ -36,7 +36,7 @@ public class TestClient implements Handler {
 			printSample("Client sending", sample);
 			foo.encode(e, sample);
 
-			LabCommDecoderChannel c = new LabCommDecoderChannel(in);
+			DecoderChannel c = new DecoderChannel(in);
 			foo.register(c,this);
 			c.run();
 		} catch (Exception e) {
diff --git a/examples/jgrafchart/labcommTCPtest/client/TestClientSingleshot.java b/examples/jgrafchart/labcommTCPtest/client/TestClientSingleshot.java
index d54c7bb09f78ab3502199f40c70c88677539d3f5..9601bcabcf45d174367aeeb61229ccc3dfeb8d25 100644
--- a/examples/jgrafchart/labcommTCPtest/client/TestClientSingleshot.java
+++ b/examples/jgrafchart/labcommTCPtest/client/TestClientSingleshot.java
@@ -6,8 +6,8 @@ import java.io.OutputStream;
 import java.net.Socket;
 import java.net.UnknownHostException;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 import labcommTCPtest.gen.FooSample;
 import labcommTCPtest.gen.FooSample.Handler;
 
@@ -25,7 +25,7 @@ public class TestClientSingleshot implements Handler {
 	public void test() {
 		
 		try {
-			LabCommEncoderChannel e = new LabCommEncoderChannel(out );
+			EncoderChannel e = new EncoderChannel(out );
 			FooSample.register(e);
 			FooSample sample = new FooSample();
 			sample.x = 17;
@@ -35,7 +35,7 @@ public class TestClientSingleshot implements Handler {
 			printSample("Client sending", sample);
 			FooSample.encode(e, sample);
 
-			LabCommDecoderChannel c = new LabCommDecoderChannel(in);
+			DecoderChannel c = new DecoderChannel(in);
 			FooSample.register(c,this);
 			c.runOne();
 		} catch (Exception e) {
diff --git a/examples/jgrafchart/labcommTCPtest/server/TestServer.java b/examples/jgrafchart/labcommTCPtest/server/TestServer.java
index 33be0cdaae064bc00c8eaf2d03fd9883b224ff00..4b95a362a6a1784407336df5b5eab411f2e25f1d 100644
--- a/examples/jgrafchart/labcommTCPtest/server/TestServer.java
+++ b/examples/jgrafchart/labcommTCPtest/server/TestServer.java
@@ -8,8 +8,8 @@ import java.lang.reflect.Method;
 import java.net.ServerSocket;
 import java.net.Socket;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 import labcommTCPtest.gen.foo;
 import labcommTCPtest.gen.foo.Handler;
 
@@ -38,7 +38,7 @@ public class TestServer implements Handler {
 	public void runOne() {
 		
 		try {
-			LabCommDecoderChannel c = new LabCommDecoderChannel(in);
+			DecoderChannel c = new DecoderChannel(in);
 			foo.register(c,this);
 			c.runOne();
 		} catch (Exception e) {
@@ -47,7 +47,7 @@ public class TestServer implements Handler {
 	}
 
 	public void handle_foo(foo sample) throws Exception {
-		LabCommEncoderChannel e = new LabCommEncoderChannel(out );
+		EncoderChannel e = new EncoderChannel(out );
 		foo.register(e);
 		System.out.println("TestServer.handle_foo...");
 		sample.b *= 2;
diff --git a/examples/robot/Program.cs b/examples/robot/Program.cs
index 28fddc27a50c93ec91d9db5ced4ab3d58a215a01..56cfb271d07a42885f8e5790b2eed23adebbc894 100644
--- a/examples/robot/Program.cs
+++ b/examples/robot/Program.cs
@@ -24,7 +24,7 @@ namespace RobotCtrl
             try
             {
                 client.Connect(serverEndPoint);
-                LabCommEncoder enc = new LabCommEncoderChannel(client.GetStream(), true);
+                Encoder enc = new EncoderChannel(client.GetStream(), true);
                 jointtarget.register(enc);
                 jointtarget.encode(enc, val);
                 for (int i = 0; i < 10; i++)
diff --git a/examples/simple/Decoder.java b/examples/simple/Decoder.java
index 4ab97e48fccda695f051157b6eb86d293b700d3f..48dd3edfa2cb6b9501890f17f62f3b9df79047fb 100644
--- a/examples/simple/Decoder.java
+++ b/examples/simple/Decoder.java
@@ -2,19 +2,19 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
 
 public class Decoder
   implements theTwoInts.Handler, anotherTwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler, doavoid.Handler
 
 {
 
-  LabCommDecoderChannel decoder;
+  DecoderChannel decoder;
 
   public Decoder(InputStream in) 
     throws Exception 
   {
-    decoder = new LabCommDecoderChannel(in);
+    decoder = new DecoderChannel(in);
     theTwoInts.register(decoder, this);
     anotherTwoInts.register(decoder, this);
     IntString.register(decoder, this);
diff --git a/examples/simple/Decoder06.java b/examples/simple/Decoder06.java
index b6185d7b04e70d89080a79a4fcdacb7b1c8ee1e1..86ba71846540577b0561c101ca62a6ae17758d20 100644
--- a/examples/simple/Decoder06.java
+++ b/examples/simple/Decoder06.java
@@ -2,19 +2,19 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
-import se.lth.control.labcomm2006.LabCommDecoderChannel;
+import se.lth.control.labcomm2006.DecoderChannel;
 
 public class Decoder06
   implements theTwoInts.Handler, anotherTwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler
 
 {
 
-  LabCommDecoderChannel decoder;
+  DecoderChannel decoder;
 
   public Decoder06(InputStream in) 
     throws Exception 
   {
-    decoder = new LabCommDecoderChannel(in);
+    decoder = new DecoderChannel(in);
     theTwoInts.register(decoder, this);
     anotherTwoInts.register(decoder, this);
     IntString.register(decoder, this);
diff --git a/examples/simple/Encoder.java b/examples/simple/Encoder.java
index b209ea62b547ad289fe553d823bceadb58fb78ff..d70384cee5fe7452d4cb413db3c7c6ef09f9e7a1 100644
--- a/examples/simple/Encoder.java
+++ b/examples/simple/Encoder.java
@@ -2,7 +2,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
 
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 
 /**
  * Simple encoder 
@@ -10,12 +10,12 @@ import se.lth.control.labcomm.LabCommEncoderChannel;
 public class Encoder 
 {
 
-  LabCommEncoderChannel encoder;
+  EncoderChannel encoder;
 
   public Encoder(OutputStream out) 
     throws Exception 
   {
-    encoder = new LabCommEncoderChannel(out);
+    encoder = new EncoderChannel(out);
     theTwoInts.register(encoder);
     IntString.register(encoder);
     TwoArrays.register(encoder);
diff --git a/examples/simple/Encoder06.java b/examples/simple/Encoder06.java
index 5d913d9fc98748c012717ea5f51d662562e39341..1da84c85b6e3efe483e02f7b661b7efcfdc48cd8 100644
--- a/examples/simple/Encoder06.java
+++ b/examples/simple/Encoder06.java
@@ -2,7 +2,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
 
-import se.lth.control.labcomm2006.LabCommEncoderChannel;
+import se.lth.control.labcomm2006.EncoderChannel;
 
 /**
  * Simple encoder 
@@ -10,12 +10,12 @@ import se.lth.control.labcomm2006.LabCommEncoderChannel;
 public class Encoder06 
 {
 
-  LabCommEncoderChannel encoder;
+  EncoderChannel encoder;
 
   public Encoder06(OutputStream out) 
     throws Exception 
   {
-    encoder = new LabCommEncoderChannel(out);
+    encoder = new EncoderChannel(out);
     theTwoInts.register(encoder);
     IntString.register(encoder);
     TwoArrays.register(encoder);
diff --git a/examples/simple/Makefile b/examples/simple/Makefile
index 757301e818275ec4ae55c10514b825483b2ce0b8..e12fb678ad0e8a583f3c1d64cfca56788fbdae0e 100644
--- a/examples/simple/Makefile
+++ b/examples/simple/Makefile
@@ -4,3 +4,10 @@ clean:
 
 distclean:
 	rm -rf gen
+	rm -rf gen06
+	rm -f *.class
+	rm -f example_encoder
+	rm -f example_encoder06
+	rm -f example_decoder
+	rm -f example_decoder06
+	rm -f encoded_data
diff --git a/examples/simple/compile.sh b/examples/simple/compile.sh
index a5566fc61fb48e8d90681415033a17b9ff878d47..ac5860108bfa5701629fa497990e0d3b439a3f88 100644
--- a/examples/simple/compile.sh
+++ b/examples/simple/compile.sh
@@ -7,15 +7,15 @@
 mkdir -p gen
 java -jar ../../compiler/labComm.jar --java=gen --c=gen/simple.c --h=gen/simple.h  --python=gen/simple.py simple.lc 
 
-javac -cp ../../lib/java/labcomm2013.jar:. gen/*.java Encoder.java Decoder.java
+javac -cp ../../lib/java/labcomm2014.jar:. gen/*.java Encoder.java Decoder.java
 
 gcc -Wall -Werror -Wno-unused-function \
     -I. -I../../lib/c -L../../lib/c \
     -o example_encoder example_encoder.c gen/simple.c \
-    -llabcomm2013 -Tlabcomm.linkscript
+    -llabcomm2014 -Tlabcomm.linkscript
 gcc -Wall -Werror -I . -I ../../lib/c -L../../lib/c \
     -o example_decoder example_decoder.c gen/simple.c \
-    -llabcomm2013 -Tlabcomm.linkscript
+    -llabcomm2014 -Tlabcomm.linkscript
 
 # For version 2006
 
diff --git a/examples/simple/example_encoder.py b/examples/simple/example_encoder.py
index 277eb93589e7b77bd8224a3c91888d065698a003..c89f1348841dafb81e0eb2ba5e20c53c5606b79b 100755
--- a/examples/simple/example_encoder.py
+++ b/examples/simple/example_encoder.py
@@ -5,7 +5,7 @@ import sys
 import simple
 
 if __name__ == '__main__':
-    version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2013"
+    version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
     encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version)
     encoder.add_decl(simple.theTwoInts.signature)
     encoder.add_decl(simple.IntString.signature)
diff --git a/examples/simple/run.sh b/examples/simple/run.sh
index 192225d33f8522c12c4a14e956b37c9fb5cfe4b9..750d122cc2cf8215b8bf6e8942bf7fa3e3d7bbd9 100644
--- a/examples/simple/run.sh
+++ b/examples/simple/run.sh
@@ -5,17 +5,17 @@ echo "***   Running example for version 2013   ***"
 echo "********************************************"
 echo
 
-java -cp .:../../lib/java/labcomm2013.jar:gen Encoder encoded_data
+java -cp .:../../lib/java/labcomm2014.jar:gen Encoder encoded_data
 ./example_decoder encoded_data
 
 PYTHONPATH=../../lib/python:gen ./example_encoder.py encoded_data
-java -cp .:../../lib/java/labcomm2013.jar:gen Decoder encoded_data
+java -cp .:../../lib/java/labcomm2014.jar:gen Decoder encoded_data
 
 ./example_encoder encoded_data
-java -cp .:../../lib/java/labcomm2013.jar:gen Decoder encoded_data
+java -cp .:../../lib/java/labcomm2014.jar:gen Decoder encoded_data
 
 echo "running python decoder (from wiki_example):"
-PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm2013
+PYTHONPATH=../../lib/python ../wiki_example/example_decoder.py encoded_data LabComm2014
 
 echo
 echo "*******************************************************"
diff --git a/examples/tcp/labcommTCPtest/client/TestClient.java b/examples/tcp/labcommTCPtest/client/TestClient.java
index d9040fb3475ebaa36f2f85ac5f261d7d2b07205f..fcd621e5f0749184d271602054b1d84c151074d8 100644
--- a/examples/tcp/labcommTCPtest/client/TestClient.java
+++ b/examples/tcp/labcommTCPtest/client/TestClient.java
@@ -6,8 +6,8 @@ import java.io.OutputStream;
 import java.net.Socket;
 import java.net.UnknownHostException;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 import labcommTCPtest.gen.FooSample;
 import labcommTCPtest.gen.FooSample.Handler;
 
@@ -25,7 +25,7 @@ public class TestClient implements Handler {
 	public void test() {
 		
 		try {
-			LabCommEncoderChannel e = new LabCommEncoderChannel(out );
+			EncoderChannel e = new EncoderChannel(out );
 			FooSample.register(e);
 			FooSample sample = new FooSample();
 			int a[] = new int[3];
@@ -42,7 +42,7 @@ public class TestClient implements Handler {
 			printSample("Client sending", sample);
 			FooSample.encode(e, sample);
 
-			LabCommDecoderChannel c = new LabCommDecoderChannel(in);
+			DecoderChannel c = new DecoderChannel(in);
 			FooSample.register(c,this);
 			c.runOne();
 		} catch (Exception e) {
diff --git a/examples/tcp/labcommTCPtest/client/TestClientSingleshot.java b/examples/tcp/labcommTCPtest/client/TestClientSingleshot.java
index d54c7bb09f78ab3502199f40c70c88677539d3f5..9601bcabcf45d174367aeeb61229ccc3dfeb8d25 100644
--- a/examples/tcp/labcommTCPtest/client/TestClientSingleshot.java
+++ b/examples/tcp/labcommTCPtest/client/TestClientSingleshot.java
@@ -6,8 +6,8 @@ import java.io.OutputStream;
 import java.net.Socket;
 import java.net.UnknownHostException;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 import labcommTCPtest.gen.FooSample;
 import labcommTCPtest.gen.FooSample.Handler;
 
@@ -25,7 +25,7 @@ public class TestClientSingleshot implements Handler {
 	public void test() {
 		
 		try {
-			LabCommEncoderChannel e = new LabCommEncoderChannel(out );
+			EncoderChannel e = new EncoderChannel(out );
 			FooSample.register(e);
 			FooSample sample = new FooSample();
 			sample.x = 17;
@@ -35,7 +35,7 @@ public class TestClientSingleshot implements Handler {
 			printSample("Client sending", sample);
 			FooSample.encode(e, sample);
 
-			LabCommDecoderChannel c = new LabCommDecoderChannel(in);
+			DecoderChannel c = new DecoderChannel(in);
 			FooSample.register(c,this);
 			c.runOne();
 		} catch (Exception e) {
diff --git a/examples/tcp/labcommTCPtest/server/OneShotServer.java b/examples/tcp/labcommTCPtest/server/OneShotServer.java
index b929d8ba52cdd7df9751502030c43c231fcee36b..b79b93e7d8f14d7eac194207d7914c17187fc113 100644
--- a/examples/tcp/labcommTCPtest/server/OneShotServer.java
+++ b/examples/tcp/labcommTCPtest/server/OneShotServer.java
@@ -6,8 +6,8 @@ import java.io.OutputStream;
 import java.net.Socket;
 import java.net.ServerSocket;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 import labcommTCPtest.gen.FooSample;
 
 public class OneShotServer {//implements Handler {
@@ -21,7 +21,7 @@ public class OneShotServer {//implements Handler {
 	public void test() {
 		
 		try {
-			LabCommEncoderChannel e = new LabCommEncoderChannel(out );
+			EncoderChannel e = new EncoderChannel(out );
 			FooSample.register(e);
 			FooSample sample = new FooSample();
 			sample.s = "OneShotServer message";
diff --git a/examples/tcp/labcommTCPtest/server/TestServer.java b/examples/tcp/labcommTCPtest/server/TestServer.java
index b9b6d0b969a05f266510fca8556ec744290185c7..441bac4df2d1d4a08eda8322c0c2717b0e886521 100644
--- a/examples/tcp/labcommTCPtest/server/TestServer.java
+++ b/examples/tcp/labcommTCPtest/server/TestServer.java
@@ -8,8 +8,8 @@ import java.lang.reflect.Method;
 import java.net.ServerSocket;
 import java.net.Socket;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 import labcommTCPtest.gen.FooSample;
 import labcommTCPtest.gen.FooSample.Handler;
 
@@ -38,7 +38,7 @@ public class TestServer implements Handler {
 	public void runOne() {
 		
 		try {
-			LabCommDecoderChannel c = new LabCommDecoderChannel(in);
+			DecoderChannel c = new DecoderChannel(in);
 			FooSample.register(c,this);
 			c.runOne();
 		} catch (Exception e) {
@@ -47,7 +47,7 @@ public class TestServer implements Handler {
 	}
 
 	public void handle_FooSample(FooSample sample) throws Exception {
-		LabCommEncoderChannel e = new LabCommEncoderChannel(out );
+		EncoderChannel e = new EncoderChannel(out );
 		FooSample.register(e);
 		System.out.println("TestServer.handle_FooSample: "+sample.s);
 		int tmp[] = new int[2*sample.a.length];
diff --git a/examples/twoway/decimating.c b/examples/twoway/decimating.c
index dbcc80cc2ed52f4c4019cbcec4c0d2c9dfe9aa00..32d1ab0c79b826d4f7380801e8eaa1c276f77ee5 100644
--- a/examples/twoway/decimating.c
+++ b/examples/twoway/decimating.c
@@ -62,14 +62,13 @@ static void set_decimation(
 
 static int wrap_reader_alloc(
   struct labcomm_reader *r, 
-  struct labcomm_reader_action_context *action_context, 
-  char *labcomm_version)
+  struct labcomm_reader_action_context *action_context)
 {
   struct decimating_private *decimating = action_context->context;
   
   labcomm_decoder_register_decimating_messages_set_decimation(
     r->decoder, set_decimation, decimating);
-  return labcomm_reader_alloc(r, action_context->next, labcomm_version);
+  return labcomm_reader_alloc(r, action_context->next);
 }
 
 struct send_set_decimation {
@@ -186,14 +185,13 @@ static void register_signatures(void *context)
 
 static int wrap_writer_alloc(
   struct labcomm_writer *w, 
-  struct labcomm_writer_action_context *action_context, 
-  char *labcomm_version)
+  struct labcomm_writer_action_context *action_context)
 {
   struct decimating_private *decimating = action_context->context;
 
   labcomm_scheduler_enqueue(decimating->scheduler, 
 			    0, register_signatures, decimating);
-  return labcomm_writer_alloc(w, action_context->next, labcomm_version);
+  return labcomm_writer_alloc(w, action_context->next);
 }
 
 static int wrap_writer_start(
@@ -206,20 +204,22 @@ static int wrap_writer_start(
   struct decimation *decimation;
   int result;
 
-  labcomm_scheduler_data_lock(decimating->scheduler);
-
-  decimation = LABCOMM_SIGNATURE_ARRAY_REF(decimating->memory, 
-					   decimating->writer_decimation, 
-					   struct decimation, index);
-  decimation->current++;
-  if (decimation->current < decimation->n) {
-    result = -EALREADY;
-  } else {
-    decimation->current = 0;
+  if (index < LABCOMM_USER) {
     result = 0;
+  } else {
+    labcomm_scheduler_data_lock(decimating->scheduler);
+    decimation = LABCOMM_SIGNATURE_ARRAY_REF(decimating->memory, 
+                                             decimating->writer_decimation, 
+                                             struct decimation, index);
+    decimation->current++;
+    if (decimation->current < decimation->n) {
+      result = -EALREADY;
+    } else {
+      decimation->current = 0;
+      result = 0;
+    }
+    labcomm_scheduler_data_unlock(decimating->scheduler);
   }
-  labcomm_scheduler_data_unlock(decimating->scheduler);
-
   if (result == 0) {
     result = labcomm_writer_start(w, action_context->next,
 				 index, signature, value);
diff --git a/examples/twoway/introspecting.c b/examples/twoway/introspecting.c
index a1e10281f31333d8cb9ac6f4e20c22af24dc260e..0f90b2be1f22ebe776a58c9ef4fd6e85e6dc8482 100644
--- a/examples/twoway/introspecting.c
+++ b/examples/twoway/introspecting.c
@@ -124,15 +124,14 @@ static void handles_signature(
 
 static int wrap_reader_alloc(
   struct labcomm_reader *r, 
-  struct labcomm_reader_action_context *action_context, 
-  char *labcomm_version)
+  struct labcomm_reader_action_context *action_context)
 {
   struct introspecting_private *introspecting = action_context->context;
 
   labcomm_decoder_register_introspecting_messages_handles_signature(
     introspecting->introspecting.reader->decoder, 
     handles_signature, introspecting);
-  return labcomm_reader_alloc(r, action_context->next, labcomm_version);
+  return labcomm_reader_alloc(r, action_context->next);
 }
 
 struct handles_signature {
@@ -213,14 +212,13 @@ static void register_encoder_signatures(void *context)
 
 static int wrap_writer_alloc(
   struct labcomm_writer *w, 
-  struct labcomm_writer_action_context *action_context, 
-  char *labcomm_version)
+  struct labcomm_writer_action_context *action_context)
 {
   struct introspecting_private *introspecting = action_context->context;
 
   labcomm_scheduler_enqueue(introspecting->scheduler, 
 			    0, register_encoder_signatures, introspecting);
-  return labcomm_writer_alloc(w, action_context->next, labcomm_version);
+  return labcomm_writer_alloc(w, action_context->next);
 }
 
 static int wrap_writer_start(
@@ -231,7 +229,7 @@ static int wrap_writer_start(
 {
   struct introspecting_private *introspecting = action_context->context;
 
-  if (value == NULL) {
+  if (index >= LABCOMM_USER && value == NULL) {
     struct local *local;
 
     labcomm_scheduler_data_lock(introspecting->scheduler);
diff --git a/examples/user_types/Decoder.java b/examples/user_types/Decoder.java
index 01bea43a658960fa2817416fd4d6efcf81b1f7de..bdb17374517015db59e66c02c3144b9d9bf886bc 100644
--- a/examples/user_types/Decoder.java
+++ b/examples/user_types/Decoder.java
@@ -2,19 +2,19 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
 
 public class Decoder
   implements twoLines.Handler
 
 {
 
-  LabCommDecoderChannel decoder;
+  DecoderChannel decoder;
 
   public Decoder(InputStream in) 
     throws Exception 
   {
-    decoder = new LabCommDecoderChannel(in);
+    decoder = new DecoderChannel(in);
     twoLines.register(decoder, this);
 
     try {
diff --git a/examples/user_types/Encoder.java b/examples/user_types/Encoder.java
index 8cdbba85598ada7a850b1c110e13cea212719d74..aa2f80e9617aa3b47b468f4d46469573743a8bc9 100644
--- a/examples/user_types/Encoder.java
+++ b/examples/user_types/Encoder.java
@@ -2,7 +2,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
 
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 
 /**
  * Simple encoder 
@@ -10,12 +10,12 @@ import se.lth.control.labcomm.LabCommEncoderChannel;
 public class Encoder 
 {
 
-  LabCommEncoderChannel encoder;
+  EncoderChannel encoder;
 
   public Encoder(OutputStream out) 
     throws Exception 
   {
-    encoder = new LabCommEncoderChannel(out);
+    encoder = new EncoderChannel(out);
     twoLines.register(encoder);
   }
 
diff --git a/examples/user_types/Makefile b/examples/user_types/Makefile
index 607a20a97e9bcdab4a3951690e38322c5d650af7..4d68ea9a1ab28408177b093e73c730a919a01919 100644
--- a/examples/user_types/Makefile
+++ b/examples/user_types/Makefile
@@ -3,3 +3,5 @@ all:
 clean:
 
 distclean:
+	rm -rf gen
+	rm -f encoded_data
diff --git a/examples/user_types/compile.sh b/examples/user_types/compile.sh
index e1029d83815313c72f21915695fdf66464bd8113..d46c6698add6172a9eabd7fce70bf4d11e6cb708 100644
--- a/examples/user_types/compile.sh
+++ b/examples/user_types/compile.sh
@@ -7,16 +7,16 @@
 mkdir -p gen
 java -jar ../../compiler/labComm.jar --java=gen --c=gen/test.c --h=gen/test.h  --python=gen/test.py test.lc 
 
-javac -cp ../../lib/java/labcomm2013.jar:. gen/*.java Encoder.java Decoder.java
+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 \
-    -llabcomm2013 
+    -llabcomm2014 
 
 gcc -Wall -Werror -I . -I ../../lib/c -L../../lib/c \
     -o example_decoder example_decoder.c gen/test.c \
-    -llabcomm2013 
+    -llabcomm2014 
     #-Tlabcomm.linkscript
 
diff --git a/examples/user_types/example_encoder.py b/examples/user_types/example_encoder.py
index 1fa406936de61fc043a3592d964d7b3e623c7da4..cdd2135ef8d971fd36e9cbee282871f0474672ca 100755
--- a/examples/user_types/example_encoder.py
+++ b/examples/user_types/example_encoder.py
@@ -5,7 +5,7 @@ import sys
 import test
 
 if __name__ == '__main__':
-    version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2013"
+    version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
     encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version)
     encoder.add_decl(test.twoLines.signature)
     tl = dict(
diff --git a/examples/user_types/run.sh b/examples/user_types/run.sh
index 2bdc6eea0cdf570c61a26f24e0aa9c294dfd9758..dc3a7fddfbf7444e9b79b774b950637db4679025 100644
--- a/examples/user_types/run.sh
+++ b/examples/user_types/run.sh
@@ -5,34 +5,34 @@ echo "***   Running example for version 2013   ***"
 echo "********************************************"
 echo
 
-java -cp .:../../lib/java/labcomm2013.jar:gen Encoder encoded_data
+java -cp .:../../lib/java/labcomm2014.jar:gen Encoder encoded_data
 
 echo "running Java  decoder:"
-java -cp .:../../lib/java/labcomm2013.jar:gen Decoder encoded_data
+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 LabComm2013
+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/labcomm2013.jar:gen Decoder encoded_data
+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 LabComm2013
+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/labcomm2013.jar:gen Decoder encoded_data2
+java -cp .:../../lib/java/labcomm2014.jar:gen Decoder encoded_data2
 
 echo "running C decoder:"
 ./example_decoder encoded_data2
diff --git a/examples/wiki_example/data.java b/examples/wiki_example/data.java
index 7acf55a5a1c915dc72ed235b9d3a88cd45ad8b5d..5860ed9a4fb01ca0f411ed347256aff2bed412cc 100644
--- a/examples/wiki_example/data.java
+++ b/examples/wiki_example/data.java
@@ -2,27 +2,27 @@
 sample float data;
 */
 import java.io.IOException;
-import se.lth.control.labcomm.LabCommDecoder;
-import se.lth.control.labcomm.LabCommDispatcher;
-import se.lth.control.labcomm.LabCommEncoder;
-import se.lth.control.labcomm.LabCommHandler;
-import se.lth.control.labcomm.LabCommSample;
+import se.lth.control.labcomm.Decoder;
+import se.lth.control.labcomm.Dispatcher;
+import se.lth.control.labcomm.Encoder;
+import se.lth.control.labcomm.Handler;
+import se.lth.control.labcomm.Sample;
 
-public class data implements LabCommSample {
+public class data implements Sample {
 
-  public interface Handler extends LabCommHandler {
+  public interface Handler extends Handler {
     public void handle_data(float value) throws Exception;
   }
   
-  public static void register(LabCommDecoder d, Handler h) throws IOException {
+  public static void register(Decoder d, Handler h) throws IOException {
     d.register(new Dispatcher(), h);
   }
   
-  public static void register(LabCommEncoder e) throws IOException {
+  public static void register(Encoder e) throws IOException {
     e.register(new Dispatcher());
   }
   
-  private static class Dispatcher implements LabCommDispatcher {
+  private static class Dispatcher implements Dispatcher {
     
     public Class getSampleClass() {
       return data.class;
@@ -36,20 +36,20 @@ public class data implements LabCommSample {
       return signature;
     }
     
-    public void decodeAndHandle(LabCommDecoder d,
-                                LabCommHandler h) throws Exception {
+    public void decodeAndHandle(Decoder d,
+                                Handler h) throws Exception {
       ((Handler)h).handle_data(data.decode(d));
     }
     
   }
   
-  public static void encode(LabCommEncoder e, float value) throws IOException {
+  public static void encode(Encoder e, float value) throws IOException {
     e.begin(data.class);
     e.encodeFloat(value);
     e.end(data.class);
   }
   
-  public static float decode(LabCommDecoder d) throws IOException {
+  public static float decode(Decoder d) throws IOException {
     float result;
     result = d.decodeFloat();
     return result;
diff --git a/examples/wiki_example/example_decoder.py b/examples/wiki_example/example_decoder.py
index a72533062a083eea23c67bbb4843ad666168ea09..03b01c7955e8205c50159bd2587bc53e9893fd67 100755
--- a/examples/wiki_example/example_decoder.py
+++ b/examples/wiki_example/example_decoder.py
@@ -4,7 +4,7 @@ import labcomm
 import sys
 
 if __name__ == "__main__":
-    version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2013"
+    version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
     d = labcomm.Decoder(labcomm.StreamReader(open(sys.argv[1])), version)
 
     while True:
diff --git a/examples/wiki_example/example_decoder_encoder.java b/examples/wiki_example/example_decoder_encoder.java
index 63f1d96b7a00da8b60e946af48fcd6bdb0e8c943..252cc1d8411ad59259dd445930f74b8f1ff61e2f 100644
--- a/examples/wiki_example/example_decoder_encoder.java
+++ b/examples/wiki_example/example_decoder_encoder.java
@@ -4,24 +4,24 @@ import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 
-import se.lth.control.labcomm.LabCommDecoderChannel;
-import se.lth.control.labcomm.LabCommEncoderChannel;
+import se.lth.control.labcomm.DecoderChannel;
+import se.lth.control.labcomm.EncoderChannel;
 
 public class example_decoder_encoder 
   implements data.Handler, log_message.Handler 
 {
 
-  LabCommDecoderChannel decoder;
-  LabCommEncoderChannel encoder;
+  DecoderChannel decoder;
+  EncoderChannel encoder;
 
   public example_decoder_encoder(InputStream in, OutputStream out) 
     throws Exception 
   {
-    decoder = new LabCommDecoderChannel(in);
+    decoder = new DecoderChannel(in);
     log_message.register(decoder, this);
     data.register(decoder, this);
 
-    encoder = new LabCommEncoderChannel(out);
+    encoder = new EncoderChannel(out);
     log_message.register(encoder);
     data.register(encoder);
  
diff --git a/lib/Makefile b/lib/Makefile
index ed696a878ae4cc8bdbb0292731f8e2e69cbbe32d..8f5b6da81b17cb553c991b1f03f11bcd7f6013b4 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -10,8 +10,10 @@ clean:
 	cd c ; make clean
 	cd csharp ; make clean
 	cd java ; make clean
+	$(MAKE) -C python clean
 
 distclean:
 	cd c ; make distclean
 	cd csharp ; make clean
 	cd java ; make clean
+	$(MAKE) -C python clean
diff --git a/lib/RAPID/README b/lib/RAPID/README
index f296d4d0de253a5758efb8ce408c759c247f9c79..e59711f6ff138ff8aa123ebb1bafdc1d4f6cf1cc 100644
--- a/lib/RAPID/README
+++ b/lib/RAPID/README
@@ -34,7 +34,7 @@ or
 	$ VAR Encoder e;
 	$ Init_Encoder e, st;
 This will read/write the version of LabComm to ensure compatibility, current
-version is "LabComm2013".
+version is "LabComm2014".
 
 # Initiate the labcomm samples:
 LabComm trusts the application to manage each sample. It requests the samples,
diff --git a/lib/c/2006/labcomm2006.c b/lib/c/2006/labcomm2006.c
index 34a13ec11ca428da1eac5db458e8e388362b8d56..111ec2f24320a0213b4d98a0efd6fdc6b3864d09 100644
--- a/lib/c/2006/labcomm2006.c
+++ b/lib/c/2006/labcomm2006.c
@@ -48,10 +48,9 @@
   }
 
 int labcomm2006_reader_alloc(struct labcomm2006_reader *r, 
-                         struct labcomm2006_reader_action_context *action_context, 
-                         char *labcomm2006_version)
+                         struct labcomm2006_reader_action_context *action_context)
 {
-  UNWRAP(alloc, r, action_context, labcomm2006_version);
+  UNWRAP(alloc, r, action_context);
 }
 
 int labcomm2006_reader_free(struct labcomm2006_reader *r, 
@@ -92,10 +91,9 @@ int labcomm2006_reader_ioctl(struct labcomm2006_reader *r,
 }
 
 int labcomm2006_writer_alloc(struct labcomm2006_writer *w, 
-                         struct labcomm2006_writer_action_context *action_context, 
-                         char *labcomm2006_version)
+                         struct labcomm2006_writer_action_context *action_context)
 {
-  UNWRAP(alloc, w, action_context, labcomm2006_version);
+  UNWRAP(alloc, w, action_context);
 }
 
 int labcomm2006_writer_free(struct labcomm2006_writer *w, 
@@ -260,3 +258,11 @@ int labcomm2006_get_local_index(struct labcomm2006_signature *signature)
   }
   return signature->index;
 }
+
+int labcomm2006_internal_sizeof(struct labcomm2006_signature *signature,
+                            void *v)
+{
+  int length = signature->encoded_size(v);
+  return (labcomm2006_size_packed32(signature->index) +
+          length);
+}
diff --git a/lib/c/2006/labcomm2006.h b/lib/c/2006/labcomm2006.h
index 938aa2d7e7612dfc9554e41600ec8cad930ccee0..fc7919ead1c5ba7430d9af51f532bb82e274f8ff 100644
--- a/lib/c/2006/labcomm2006.h
+++ b/lib/c/2006/labcomm2006.h
@@ -44,9 +44,8 @@ struct labcomm2006_decoder;
  * Signature entry
  */
 struct labcomm2006_signature {
-  int type;
   char *name;
-  int (*encoded_size)(struct labcomm2006_signature *, void *); // void * == encoded_sample *
+  int (*encoded_size)(void *); /* void* refers to sample_data */
   int size;
   unsigned char *signature; 
   int index;
diff --git a/lib/c/2006/labcomm2006_decoder.c b/lib/c/2006/labcomm2006_decoder.c
index a936f3e1bfd3d1eb0cdf77f0836026aabe55d8e5..d472cdfa9add29c0ac4f140796ed2f700eddf975 100644
--- a/lib/c/2006/labcomm2006_decoder.c
+++ b/lib/c/2006/labcomm2006_decoder.c
@@ -186,11 +186,10 @@ static int decode_typedef_or_sample(struct labcomm2006_decoder *d, int kind)
   
   local_signature = NULL;
   local_index = 0;
-  labcomm2006_writer_alloc(&writer, writer.action_context, "");
+  labcomm2006_writer_alloc(&writer, writer.action_context);
   labcomm2006_writer_start(&writer, writer.action_context, 0, NULL, NULL);
   remote_index = labcomm2006_read_packed32(d->reader);
   signature.name = labcomm2006_read_string(d->reader);
-  signature.type = kind;
   collect_flat_signature(d, &writer);
   labcomm2006_writer_end(&writer, writer.action_context);
   err = writer_ioctl(&writer, 
@@ -221,7 +220,6 @@ static int decode_typedef_or_sample(struct labcomm2006_decoder *d, int kind)
       s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, 
 				      d->local,  struct sample_entry, i);
       if (s->signature &&
-	  s->signature->type == signature.type &&
 	  s->signature->size == signature.size &&
 	  strcmp(s->signature->name, signature.name) == 0 &&
 	  memcmp((void*)s->signature->signature, (void*)signature.signature,
@@ -288,8 +286,7 @@ static void reader_alloc(struct labcomm2006_decoder *d)
 {
   if (!d->reader_allocated) {
     d->reader_allocated = 1;
-    labcomm2006_reader_alloc(d->reader, d->reader->action_context,
-			 LABCOMM_VERSION);
+    labcomm2006_reader_alloc(d->reader, d->reader->action_context);
   }
 }
 
diff --git a/lib/c/2006/labcomm2006_dynamic_buffer_writer.c b/lib/c/2006/labcomm2006_dynamic_buffer_writer.c
index 02acb62199b936c43a9faee3be21174344a6a156..c931ec0a1bb6584bcd70cfc721e1e40143d41e35 100644
--- a/lib/c/2006/labcomm2006_dynamic_buffer_writer.c
+++ b/lib/c/2006/labcomm2006_dynamic_buffer_writer.c
@@ -28,8 +28,7 @@
 #include "labcomm2006_dynamic_buffer_writer.h"
 
 static int dyn_alloc(struct labcomm2006_writer *w, 
-		     struct labcomm2006_writer_action_context *action_context,
-		     char *labcomm2006_version)
+		     struct labcomm2006_writer_action_context *action_context)
 {
   w->data_size = 1000;
   w->count = w->data_size;
diff --git a/lib/c/2006/labcomm2006_encoder.c b/lib/c/2006/labcomm2006_encoder.c
index 06eb4dca403a0a43d44544cfe3a939963bc3d63d..9e17a60de5b9f0f79fe3c2c1f3be79e6d9235a2c 100644
--- a/lib/c/2006/labcomm2006_encoder.c
+++ b/lib/c/2006/labcomm2006_encoder.c
@@ -53,7 +53,7 @@ struct labcomm2006_encoder *labcomm2006_encoder_new(
     result->scheduler = scheduler;
     LABCOMM_SIGNATURE_ARRAY_INIT(result->registered, int);
     labcomm2006_writer_alloc(result->writer,
-			 result->writer->action_context, LABCOMM_VERSION);
+			 result->writer->action_context);
   }
   return result;
 }
@@ -77,7 +77,6 @@ int labcomm2006_internal_encoder_register(
 
   index = labcomm2006_get_local_index(signature);
   labcomm2006_scheduler_writer_lock(e->scheduler);
-  if (signature->type != LABCOMM_SAMPLE) { goto out; }
   if (index <= 0) { goto out; }
   done = LABCOMM_SIGNATURE_ARRAY_REF(e->memory, e->registered, int, index);
   if (*done) { goto out; }
@@ -86,7 +85,7 @@ int labcomm2006_internal_encoder_register(
 			     index, signature, NULL);
   if (err == -EALREADY) { result = 0; goto out; }
   if (err != 0) { result = err; goto out; }
-  labcomm2006_write_packed32(e->writer, signature->type);
+  labcomm2006_write_packed32(e->writer, LABCOMM_SAMPLE);
   labcomm2006_write_packed32(e->writer, index);
   labcomm2006_write_string(e->writer, signature->name);
   for (i = 0 ; i < signature->size ; i++) {
diff --git a/lib/c/2006/labcomm2006_fd_reader.c b/lib/c/2006/labcomm2006_fd_reader.c
index 485be6bc9eee84f1ba4bd546c12bb7a8369a8e80..15f1bfb5654e349d7f175d3a8af8cdde4c190f39 100644
--- a/lib/c/2006/labcomm2006_fd_reader.c
+++ b/lib/c/2006/labcomm2006_fd_reader.c
@@ -36,19 +36,9 @@ struct labcomm2006_fd_reader {
 };
 
 static int fd_alloc(struct labcomm2006_reader *r,
-		    struct labcomm2006_reader_action_context *action_context, 
-		    char *version)
+		    struct labcomm2006_reader_action_context *action_context)
 {
   int result = 0;
-// in-band version is not included in version 2006.
-// This may be a place for version checking and/or printing
-// a warning message
-  if (version && version[0]) {
-    if (strcmp(LABCOMM_VERSION, version) != 0) {
-      fprintf(stderr, "ERROR: version mismatch: %s != %s\n", version, LABCOMM_VERSION);
-      return -EINVAL;
-    } 
-  }
   
   r->count = 0;
   r->pos = 0;
diff --git a/lib/c/2006/labcomm2006_fd_writer.c b/lib/c/2006/labcomm2006_fd_writer.c
index af058b98465f24f2f01ed8d935ec3906960d61bd..69f30bb543afeeb3c997f096b489b7ddea31c84b 100644
--- a/lib/c/2006/labcomm2006_fd_writer.c
+++ b/lib/c/2006/labcomm2006_fd_writer.c
@@ -40,20 +40,9 @@ static int fd_flush(struct labcomm2006_writer *w,
 		    struct labcomm2006_writer_action_context *action_context);
 
 static int fd_alloc(struct labcomm2006_writer *w, 
-		    struct labcomm2006_writer_action_context *action_context, 
-		    char *version)
+		    struct labcomm2006_writer_action_context *action_context)
 {
-// in-band version is not included in version 2006.
-// This may be a place for version checking and/or printing
-// a warning message
-  if (version && version[0]) {
-    if (strcmp(LABCOMM_VERSION, version) != 0) {
-      fprintf(stderr, "ERROR: version mismatch: %s != %s\n", version, LABCOMM_VERSION);
-      return -EINVAL;
-    } 
-  }
-  
-  w->data = labcomm2006_memory_alloc(w->memory, 0, BUFFER_SIZE);
+    w->data = labcomm2006_memory_alloc(w->memory, 0, BUFFER_SIZE);
   if (! w->data) {
     w->error = -ENOMEM;
     w->data_size = 0;
diff --git a/lib/c/2006/labcomm2006_private.h b/lib/c/2006/labcomm2006_private.h
index 1be45d2e0a3d98c3744373895389f78f9b6cf1ab..b8f7b781852cac7591403f9257b32450f18929b9 100644
--- a/lib/c/2006/labcomm2006_private.h
+++ b/lib/c/2006/labcomm2006_private.h
@@ -96,17 +96,14 @@ struct labcomm2006_reader_action_context;
 
 struct labcomm2006_reader_action {
   /* 'alloc' is called at the first invocation of 'labcomm2006_decoder_decode_one' 
-     on the decoder containing the reader. If 'labcomm2006_version' != NULL
-     and non-empty the transport layer may use it to ensure that
-     compatible versions are used.
+     on the decoder containing the reader.
 
      Returned value:
        >  0    Number of bytes allocated for buffering
        <= 0    Error
   */
   int (*alloc)(struct labcomm2006_reader *r, 
-	       struct labcomm2006_reader_action_context *action_context, 
-	       char *labcomm2006_version);
+	       struct labcomm2006_reader_action_context *action_context);
   /* 'free' returns the resources claimed by 'alloc' and might have other
      reader specific side-effects as well.
 
@@ -159,8 +156,7 @@ struct labcomm2006_reader {
 };
 
 int labcomm2006_reader_alloc(struct labcomm2006_reader *r, 
-			 struct labcomm2006_reader_action_context *action_context, 
-			 char *labcomm2006_version);
+			 struct labcomm2006_reader_action_context *action_context);
 int labcomm2006_reader_free(struct labcomm2006_reader *r, 
 			struct labcomm2006_reader_action_context *action_context);
 int labcomm2006_reader_start(struct labcomm2006_reader *r, 
@@ -299,8 +295,7 @@ struct labcomm2006_writer_action_context;
 
 struct labcomm2006_writer_action {
   int (*alloc)(struct labcomm2006_writer *w, 
-	       struct labcomm2006_writer_action_context *action_context, 
-	       char *labcomm2006_version);
+	       struct labcomm2006_writer_action_context *action_context);
   int (*free)(struct labcomm2006_writer *w, 
 	      struct labcomm2006_writer_action_context *action_context);
   /* 'start' is called right before a sample is to be sent. In the 
@@ -345,8 +340,7 @@ struct labcomm2006_writer {
 };
 
 int labcomm2006_writer_alloc(struct labcomm2006_writer *w, 
-			 struct labcomm2006_writer_action_context *action_context, 
-			 char *labcomm_version);
+			 struct labcomm2006_writer_action_context *action_context);
 int labcomm2006_writer_free(struct labcomm2006_writer *w, 
 			struct labcomm2006_writer_action_context *action_context);
 int labcomm2006_writer_start(struct labcomm2006_writer *w, 
@@ -377,6 +371,9 @@ int labcomm2006_internal_encoder_ioctl(struct labcomm2006_encoder *encoder,
 				   struct labcomm2006_signature *signature,
 				   uint32_t ioctl_action, va_list args);
 
+int labcomm2006_internal_sizeof(struct labcomm2006_signature *signature,
+                                void *v);
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 
 #define LABCOMM_ENCODE(name, type)					\
diff --git a/lib/c/Makefile b/lib/c/Makefile
index 43e892ff1f7d3b5c942083e287c5d227c75636d9..274ef6f24c8c92de029fa311b800dd8b42b4a658 100644
--- a/lib/c/Makefile
+++ b/lib/c/Makefile
@@ -1,6 +1,6 @@
 ## Macros
 UNAME_S=$(shell uname -s)
-ALL_DEPS=liblabcomm.a liblabcomm.so.1 liblabcomm2006.a liblabcomm2006.so.1  liblabcomm2013.a liblabcomm2013.so.1
+ALL_DEPS=liblabcomm.a liblabcomm.so.1 liblabcomm2006.a liblabcomm2006.so.1  liblabcomm2014.a liblabcomm2014.so.1
 
 ifeq ($(UNAME_S),Linux)
   CFLAGS=-std=c99 -g -Wall -Werror -O3  -I. -Itest -I2006
@@ -95,10 +95,10 @@ liblabcomm.a: $(OBJS) $(OBJS2006)
 liblabcomm.so.1: $(OBJS:%.o=%.pic.o) $(OBJS2006:%.o=%.pic.o)
 	$(call MAKESHARED,$@,$@,$^)
 
-liblabcomm2013.a: $(OBJS)
+liblabcomm2014.a: $(OBJS)
 	ar -r $@ $^
 
-liblabcomm2013.so.1: $(OBJS:%.o=%.pic.o)
+liblabcomm2014.so.1: $(OBJS:%.o=%.pic.o)
 	$(call MAKESHARED,$@,$@,$^)
 
 liblabcomm2006.a: $(OBJS2006)
@@ -178,8 +178,8 @@ distclean: clean
 	$(RM) liblabcomm.a
 	$(RM) liblabcomm2006.so.1
 	$(RM) liblabcomm2006.a
-	$(RM) liblabcomm2013.so.1
-	$(RM) liblabcomm2013.a
+	$(RM) liblabcomm2014.so.1
+	$(RM) liblabcomm2014.a
 
 # Extra dependencies
 $(TEST_DIR)/test_labcomm_basic_type_encoding.o: labcomm_private.h
diff --git a/lib/c/labcomm.c b/lib/c/labcomm.c
index ed4e61779d2d21eb2025fd7f16ca6430e26ec0de..416574fbb46280474412f848209649f476226ebb 100644
--- a/lib/c/labcomm.c
+++ b/lib/c/labcomm.c
@@ -37,7 +37,7 @@
 #include "labcomm_ioctl.h"
 #include "labcomm_dynamic_buffer_writer.h"
 
-#define LABCOMM_VERSION "LabComm2013"
+#define CURRENT_VERSION "LabComm2014"
 
 /* Unwrapping reader/writer functions */
 #define UNWRAP_ac(rw, ac, ...) ac
@@ -50,10 +50,9 @@
   }
 
 int labcomm_reader_alloc(struct labcomm_reader *r, 
-                         struct labcomm_reader_action_context *action_context, 
-                         char *labcomm_version)
+                         struct labcomm_reader_action_context *action_context)
 {
-  UNWRAP(alloc, r, action_context, labcomm_version);
+  UNWRAP(alloc, r, action_context);
 }
 
 int labcomm_reader_free(struct labcomm_reader *r, 
@@ -94,10 +93,9 @@ int labcomm_reader_ioctl(struct labcomm_reader *r,
 }
 
 int labcomm_writer_alloc(struct labcomm_writer *w, 
-                         struct labcomm_writer_action_context *action_context, 
-                         char *labcomm_version)
+                         struct labcomm_writer_action_context *action_context)
 {
-  UNWRAP(alloc, w, action_context, labcomm_version);
+  UNWRAP(alloc, w, action_context);
 }
 
 int labcomm_writer_free(struct labcomm_writer *w, 
@@ -260,3 +258,13 @@ int labcomm_get_local_index(struct labcomm_signature *signature)
   }
   return signature->index;
 }
+
+int labcomm_internal_sizeof(struct labcomm_signature *signature,
+                            void *v)
+{
+  int length = signature->encoded_size(v);
+  return (labcomm_size_packed32(signature->index) +
+          labcomm_size_packed32(length) +
+          length);
+}
+
diff --git a/lib/c/labcomm.h b/lib/c/labcomm.h
index 0c264bcb956ceb73bcddcd6027318c6763340838..ce28ac521294af135827ec460a54142b3f4ffc25 100644
--- a/lib/c/labcomm.h
+++ b/lib/c/labcomm.h
@@ -43,9 +43,8 @@ struct labcomm_decoder;
  * Signature entry
  */
 struct labcomm_signature {
-  int type;
   char *name;
-  int (*encoded_size)(struct labcomm_signature *, void *); // void * == encoded_sample *
+  int (*encoded_size)(void *); /* void* refers to sample_data */
   int size;
   unsigned char *signature; 
   int index;
diff --git a/lib/c/labcomm_decoder.c b/lib/c/labcomm_decoder.c
index 0de42d3d1be477be7ee46bd60788c853a2b2c512..8a3e1ba75192bdb3b4cf68a96b0a69bf93510047 100644
--- a/lib/c/labcomm_decoder.c
+++ b/lib/c/labcomm_decoder.c
@@ -18,7 +18,7 @@
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
-#define LABCOMM_VERSION "LabComm2013"
+#define CURRENT_VERSION "LabComm2014"
 
 #include <errno.h>
 #include "labcomm.h"
@@ -37,6 +37,7 @@ struct sample_entry {
 struct labcomm_decoder {
   struct labcomm_reader *reader;
   int reader_allocated;
+  int version_ok;
   struct labcomm_error_handler *error;
   struct labcomm_memory *memory;
   struct labcomm_scheduler *scheduler;
@@ -64,6 +65,7 @@ struct labcomm_decoder *labcomm_decoder_new(
     result->reader->pos = 0;
     result->reader->error = 0;
     result->reader_allocated = 0;
+    result->version_ok = 0;
     result->error = error;
     result->memory = memory;
     result->scheduler = scheduler;
@@ -84,188 +86,77 @@ void labcomm_decoder_free(struct labcomm_decoder* d)
   labcomm_memory_free(memory, 0, d);
 }
 
-static int collect_flat_signature(
-  struct labcomm_decoder *decoder,
-  struct labcomm_writer *writer)
-{
-  int result, type;
-
-  type = labcomm_read_packed32(decoder->reader); 
-  result = decoder->reader->error;
-  if (result < 0) { goto out; }
-  if (type >= LABCOMM_USER) {
-    decoder->on_error(LABCOMM_ERROR_UNIMPLEMENTED_FUNC, 3,
-		      "Implement %s ... (1) for type 0x%x\n",
-		      __FUNCTION__, type);
-  } else {
-    labcomm_write_packed32(writer, type); 
-    switch (type) {
-      case LABCOMM_ARRAY: {
-	int dimensions, i;
-
-	dimensions = labcomm_read_packed32(decoder->reader);
-	labcomm_write_packed32(writer, dimensions);
-	for (i = 0 ; i < dimensions ; i++) {
-	  int n = labcomm_read_packed32(decoder->reader);
-	  labcomm_write_packed32(writer, n);
-	}
-	result = collect_flat_signature(decoder, writer);
-	if (result < 0) { goto out; }
-      } break;
-      case LABCOMM_STRUCT: {
-	int fields, i;
-
-	fields = labcomm_read_packed32(decoder->reader); 
-	labcomm_write_packed32(writer, fields); 
-	for (i = 0 ; i < fields ; i++) {
-	  char *name = labcomm_read_string(decoder->reader);
-	  labcomm_write_string(writer, name);
-	  labcomm_memory_free(decoder->memory, 1, name);
-	  result = collect_flat_signature(decoder, writer);
-	  if (result < 0) { goto out; }
-	}
-      } break;
-      case LABCOMM_BOOLEAN:
-      case LABCOMM_BYTE:
-      case LABCOMM_SHORT:
-      case LABCOMM_INT:
-      case LABCOMM_LONG:
-      case LABCOMM_FLOAT:
-      case LABCOMM_DOUBLE:
-      case LABCOMM_STRING: {
-      } break;
-      default: {
-	result = -ENOSYS;
-	decoder->on_error(LABCOMM_ERROR_UNIMPLEMENTED_FUNC, 3,
-			  "Implement %s (2) for type 0x%x...\n",
-			  __FUNCTION__, type);
-      } break;
-    }
-  }
-out:
-  return result;
-}
-
-static int writer_ioctl(struct labcomm_writer *writer,
-			uint32_t action,
-			...)
+static int decode_sample(struct labcomm_decoder *d, int kind)
 {
   int result;
-  va_list va;
-
-  if (LABCOMM_IOC_SIG(action) != LABCOMM_IOC_NOSIG) {
-    result = -EINVAL;
-    goto out;
-  }
-  
-  va_start(va, action);
-  result = labcomm_writer_ioctl(writer, writer->action_context, 
-				0, NULL, action, va);
-  va_end(va);
-out:
-  return result;
-}
-
-static int decode_typedef_or_sample(struct labcomm_decoder *d, int kind)
-{
-  int result;
-
-  /* TODO: should the labcomm_dynamic_buffer_writer be 
-     a permanent part of labcomm_decoder? */
-  struct labcomm_writer_action_context action_context = {
-    .next = NULL,
-    .action = labcomm_dynamic_buffer_writer_action,
-    .context = NULL
-  };
-  struct labcomm_writer writer = {
-    .action_context = &action_context,
-    .memory = d->memory,
-    .data = NULL,
-    .data_size = 0,
-    .count = 0,
-    .pos = 0,
-    .error = 0,
-  };
   struct labcomm_signature signature, *local_signature;
-  int remote_index, local_index, err;
+  int remote_index, local_index, i;
   
   local_signature = NULL;
   local_index = 0;
-  labcomm_writer_alloc(&writer, writer.action_context, "");
-  labcomm_writer_start(&writer, writer.action_context, 0, NULL, NULL);
   remote_index = labcomm_read_packed32(d->reader);
+  if (d->reader->error < 0) {
+    result = d->reader->error;
+    goto out;
+  }
   signature.name = labcomm_read_string(d->reader);
-  signature.type = kind;
-  collect_flat_signature(d, &writer);
-  labcomm_writer_end(&writer, writer.action_context);
-  err = writer_ioctl(&writer, 
-		     LABCOMM_IOCTL_WRITER_GET_BYTES_WRITTEN,
-		     &signature.size);
-  if (err < 0) {
-    d->on_error(LABCOMM_ERROR_BAD_WRITER, 2,
-		"Failed to get size: %s\n", strerror(-err));
-    result = -ENOENT;
+  if (d->reader->error < 0) {
+    result = d->reader->error;
+    goto out;
+  }
+  signature.size = labcomm_read_packed32(d->reader);
+  if (d->reader->error < 0) {
+    result = d->reader->error;
     goto free_signature_name;
   }
-  err = writer_ioctl(&writer, 
-		     LABCOMM_IOCTL_WRITER_GET_BYTE_POINTER,
-		     &signature.signature);
-  if (err < 0) {
-    d->on_error(LABCOMM_ERROR_BAD_WRITER, 2,
-		"Failed to get pointer: %s\n", strerror(-err));
-    result = -ENOENT;
+  signature.signature = labcomm_memory_alloc(d->memory, 1,  signature.size);
+  if (d->reader->error < 0) {
+    result = d->reader->error;
     goto free_signature_name;
   }
-  {
-    int i;
-
-    labcomm_scheduler_data_lock(d->scheduler);
-    LABCOMM_SIGNATURE_ARRAY_FOREACH(d->local, struct sample_entry, i) {
-      struct sample_entry *s;
-      int *remote_to_local;
+  for (i = 0 ; i < signature.size ; i++) {
+    signature.signature[i] = labcomm_read_byte(d->reader);
+    if (d->reader->error < 0) {
+      result = d->reader->error;
+      goto free_signature_signature;
+    }
+  }
+  labcomm_scheduler_data_lock(d->scheduler);
+  LABCOMM_SIGNATURE_ARRAY_FOREACH(d->local, struct sample_entry, i) {
+    struct sample_entry *s;
+    int *remote_to_local;
       
-      result = -ENOENT;
-      s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, 
+    result = -ENOENT;
+    s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, 
 				      d->local,  struct sample_entry, i);
-      if (s->signature &&
-	  s->signature->type == signature.type &&
-	  s->signature->size == signature.size &&
-	  strcmp(s->signature->name, signature.name) == 0 &&
-	  memcmp((void*)s->signature->signature, (void*)signature.signature,
+    if (s->signature &&
+        s->signature->size == signature.size &&
+        strcmp(s->signature->name, signature.name) == 0 &&
+        memcmp((void*)s->signature->signature, (void*)signature.signature,
 	       signature.size) == 0) {
-	s->remote_index = remote_index;
-	local_signature = s->signature;
-	local_index = i;
-	remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
-						      d->remote_to_local, int,
-						      remote_index);
-	*remote_to_local = i;
-	result = remote_index;
-	break;
-      }
-    }
-    labcomm_scheduler_data_unlock(d->scheduler);
-    if (local_signature) {
-      labcomm_reader_start(d->reader, d->reader->action_context,
-			   local_index, remote_index, local_signature,
-			   NULL);
-      labcomm_reader_end(d->reader, d->reader->action_context);
+      s->remote_index = remote_index;
+      local_signature = s->signature;
+      local_index = i;
+      remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
+                                                    d->remote_to_local, int,
+                                                    remote_index);
+      *remote_to_local = i;
+      result = remote_index;
+      break;
     }
   }
-#if 0
-  if (! entry) {
-    /* Unknown datatype, bail out */
-    d->on_new_datatype(d, &signature);
-    result = -ENOENT;
-  } else if (entry->index && entry->index != remote_index) {
-    d->on_error(LABCOMM_ERROR_DEC_INDEX_MISMATCH, 5,
-		"%s(): index mismatch '%s' (id=0x%x != 0x%x)\n",
-		__FUNCTION__, signature.name, entry->index, remote_index);
-    result = -ENOENT;
-#endif
+  labcomm_scheduler_data_unlock(d->scheduler);
+  if (local_signature) {
+    labcomm_reader_start(d->reader, d->reader->action_context,
+                         local_index, remote_index, local_signature,
+                         NULL);
+    labcomm_reader_end(d->reader, d->reader->action_context);
+  }
+free_signature_signature:
+  labcomm_memory_free(d->memory, 1,  signature.signature);
 free_signature_name:
   labcomm_memory_free(d->memory, 0, signature.name);
-  labcomm_writer_free(&writer, writer.action_context);
+out:
   return result;
 }
 
@@ -295,14 +186,13 @@ static void reader_alloc(struct labcomm_decoder *d)
 {
   if (!d->reader_allocated) {
     d->reader_allocated = 1;
-    labcomm_reader_alloc(d->reader, d->reader->action_context,
-			 LABCOMM_VERSION);
+    labcomm_reader_alloc(d->reader, d->reader->action_context);
   }
 }
 
 int labcomm_decoder_decode_one(struct labcomm_decoder *d)
 {
-  int result, remote_index;
+  int result, remote_index, length;
 
   reader_alloc(d);
   remote_index = labcomm_read_packed32(d->reader);
@@ -310,8 +200,34 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
     result = d->reader->error;
     goto out;
   }
-  if (remote_index == LABCOMM_TYPEDEF || remote_index == LABCOMM_SAMPLE) {
-    result = decode_typedef_or_sample(d, remote_index); 
+  length = labcomm_read_packed32(d->reader);
+  if (d->reader->error < 0) {
+    result = d->reader->error;
+    goto out;
+  }
+  if (remote_index == LABCOMM_VERSION) {
+    char *version = labcomm_read_string(d->reader);
+    if (d->reader->error < 0) {
+      result = d->reader->error;
+      goto out;
+    }
+    if (strcmp(version, CURRENT_VERSION) == 0) {
+      result = LABCOMM_VERSION;
+      d->version_ok = 1;
+    } else {
+      result = -ECONNRESET;
+    }  
+    labcomm_memory_free(d->memory, 1,  version);
+  } else if (! d->version_ok) {
+    fprintf(stderr, "No VERSION %d %d\n", remote_index, length);
+    result = -ECONNRESET;
+  } else if (remote_index == LABCOMM_SAMPLE) {
+    result = decode_sample(d, remote_index); 
+  } else if (remote_index == LABCOMM_PRAGMA && 0 /* d->pragma_handler*/) {
+    /* d->prama_handler(...); */
+  } else if (remote_index < LABCOMM_USER) {
+    fprintf(stderr, "SKIP %d %d\n", remote_index, length);
+    result = remote_index;
   } else {
     int *local_index;
     struct call_handler_context wrap = {
@@ -350,7 +266,7 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
       result = -ENOENT;
     }
   }
-out:
+out:   
   return result;
 }
 
diff --git a/lib/c/labcomm_dynamic_buffer_writer.c b/lib/c/labcomm_dynamic_buffer_writer.c
index 3a7425d9643cd1b24d71ccb4804cdfd6bdbddd3e..8a9b6d1aede401276414befc6ff3c46e0455c34a 100644
--- a/lib/c/labcomm_dynamic_buffer_writer.c
+++ b/lib/c/labcomm_dynamic_buffer_writer.c
@@ -28,8 +28,7 @@
 #include "labcomm_dynamic_buffer_writer.h"
 
 static int dyn_alloc(struct labcomm_writer *w, 
-		     struct labcomm_writer_action_context *action_context,
-		     char *labcomm_version)
+		     struct labcomm_writer_action_context *action_context)
 {
   w->data_size = 1000;
   w->count = w->data_size;
diff --git a/lib/c/labcomm_encoder.c b/lib/c/labcomm_encoder.c
index 92307428dc877e539d9c0dfbcb6275508adb99a8..5526421f90f8dd5c723c66e0e6727a2d35aac451 100644
--- a/lib/c/labcomm_encoder.c
+++ b/lib/c/labcomm_encoder.c
@@ -18,7 +18,7 @@
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
-#define LABCOMM_VERSION "LabComm2013"
+#define CURRENT_VERSION "LabComm2014"
 
 #include <errno.h>
 #include "labcomm.h"
@@ -43,6 +43,8 @@ struct labcomm_encoder *labcomm_encoder_new(
 
   result = labcomm_memory_alloc(memory, 0, sizeof(*result));
   if (result) {
+    int length;
+
     result->writer = writer;
     result->writer->encoder = result;
     result->writer->data = NULL;
@@ -55,7 +57,16 @@ struct labcomm_encoder *labcomm_encoder_new(
     result->scheduler = scheduler;
     LABCOMM_SIGNATURE_ARRAY_INIT(result->registered, int);
     labcomm_writer_alloc(result->writer,
-			 result->writer->action_context, LABCOMM_VERSION);
+			 result->writer->action_context);
+    labcomm_writer_start(result->writer, 
+                         result->writer->action_context, 
+                         LABCOMM_VERSION, NULL, CURRENT_VERSION);
+    labcomm_write_packed32(result->writer, LABCOMM_VERSION);
+    length = (labcomm_size_packed32(LABCOMM_VERSION) +
+              labcomm_size_string(CURRENT_VERSION));
+    labcomm_write_packed32(result->writer, length);
+    labcomm_write_string(result->writer, CURRENT_VERSION);
+    labcomm_writer_end(result->writer, result->writer->action_context);
   }
   return result;
 }
@@ -75,11 +86,10 @@ int labcomm_internal_encoder_register(
   labcomm_encoder_function encode)
 {
   int result = -EINVAL;
-  int index, *done, err, i;
+  int index, *done, err, i, length;
 
   index = labcomm_get_local_index(signature);
   labcomm_scheduler_writer_lock(e->scheduler);
-  if (signature->type != LABCOMM_SAMPLE) { goto out; }
   if (index <= 0) { goto out; }
   done = LABCOMM_SIGNATURE_ARRAY_REF(e->memory, e->registered, int, index);
   if (*done) { goto out; }
@@ -88,9 +98,15 @@ int labcomm_internal_encoder_register(
 			     index, signature, NULL);
   if (err == -EALREADY) { result = 0; goto out; }
   if (err != 0) { result = err; goto out; }
-  labcomm_write_packed32(e->writer, signature->type);
+  labcomm_write_packed32(e->writer, LABCOMM_SAMPLE);
+  length = (labcomm_size_packed32(index) +
+            labcomm_size_string(signature->name) +
+            labcomm_size_packed32(signature->size) +
+            signature->size);
+  labcomm_write_packed32(e->writer, length);
   labcomm_write_packed32(e->writer, index);
   labcomm_write_string(e->writer, signature->name);
+  labcomm_write_packed32(e->writer, signature->size);
   for (i = 0 ; i < signature->size ; i++) {
     if (e->writer->pos >= e->writer->count) {
       labcomm_writer_flush(e->writer, e->writer->action_context);
@@ -111,16 +127,17 @@ int labcomm_internal_encode(
   labcomm_encoder_function encode,
   void *value)
 {
-  int result;
-  int index;
+  int result, index, length;
 
   index = labcomm_get_local_index(signature);
+  length = (signature->encoded_size(value));
   labcomm_scheduler_writer_lock(e->scheduler);
   result = labcomm_writer_start(e->writer, e->writer->action_context, 
 				index, signature, value);
   if (result == -EALREADY) { result = 0; goto no_end; }
   if (result != 0) { goto out; }
   result = labcomm_write_packed32(e->writer, index);
+  result = labcomm_write_packed32(e->writer, length);
   if (result != 0) { goto out; }
   result = encode(e->writer, value);
 out:
diff --git a/lib/c/labcomm_fd_reader.c b/lib/c/labcomm_fd_reader.c
index 65a9fbbc20f3ed7526677fa3feeb6ef13465bf74..eaa59f9a0974fd63462e043d134371ecd2ff4ba5 100644
--- a/lib/c/labcomm_fd_reader.c
+++ b/lib/c/labcomm_fd_reader.c
@@ -36,8 +36,7 @@ struct labcomm_fd_reader {
 };
 
 static int fd_alloc(struct labcomm_reader *r,
-		    struct labcomm_reader_action_context *action_context, 
-		    char *version)
+		    struct labcomm_reader_action_context *action_context)
 {
   int result = 0;
   
@@ -51,17 +50,6 @@ static int fd_alloc(struct labcomm_reader *r,
 
     r->data_size = BUFFER_SIZE;
     result = r->data_size;
-    if (version && version[0]) {
-      char *tmp;
-      
-      tmp = labcomm_read_string(r);
-      if (strcmp(tmp, version) != 0) {
-	result = -EINVAL;
-      } else {
-	result = r->data_size;
-      }
-      labcomm_memory_free(r->memory, 1, tmp);
-    }
   }
   return result;
 }
diff --git a/lib/c/labcomm_fd_writer.c b/lib/c/labcomm_fd_writer.c
index 9ea707fdae04c8e4dece32fa63a342d7b86687eb..a395c54da4cd1a7ec3fb7acfd551591aa94d0eb8 100644
--- a/lib/c/labcomm_fd_writer.c
+++ b/lib/c/labcomm_fd_writer.c
@@ -40,8 +40,7 @@ static int fd_flush(struct labcomm_writer *w,
 		    struct labcomm_writer_action_context *action_context);
 
 static int fd_alloc(struct labcomm_writer *w, 
-		    struct labcomm_writer_action_context *action_context, 
-		    char *version)
+		    struct labcomm_writer_action_context *action_context)
 {
   w->data = labcomm_memory_alloc(w->memory, 0, BUFFER_SIZE);
   if (! w->data) {
@@ -53,10 +52,6 @@ static int fd_alloc(struct labcomm_writer *w,
     w->data_size = BUFFER_SIZE;
     w->count = BUFFER_SIZE;
     w->pos = 0;
-    if (version && version[0]) {
-      labcomm_write_string(w, version);
-      fd_flush(w, action_context);
-    }
   }
 
   return w->error;
diff --git a/lib/c/labcomm_private.h b/lib/c/labcomm_private.h
index e615799bb1b92225d4f6604aa36e8a33953fa06c..1ba35c7ab6eb6893d729e8dde043e28ff60e5748 100644
--- a/lib/c/labcomm_private.h
+++ b/lib/c/labcomm_private.h
@@ -37,15 +37,22 @@
 #include "labcomm.h"
 
 /*
- * Predeclared aggregate type indices
+ * Allowed packet tags
  */
-#define LABCOMM_TYPEDEF  0x01
+#define LABCOMM_VERSION  0x01
 #define LABCOMM_SAMPLE   0x02
+#define LABCOMM_PRAGMA   0x3f
+#define LABCOMM_USER     0x40 /* ..0xffffffff */
+
+
+/*
+ * Predefined aggregate type indices
+ */
 #define LABCOMM_ARRAY    0x10
 #define LABCOMM_STRUCT   0x11
 
 /*
- * Predeclared primitive type indices
+ * Predefined primitive type indices
  */
 #define LABCOMM_BOOLEAN  0x20 
 #define LABCOMM_BYTE     0x21
@@ -56,10 +63,6 @@
 #define LABCOMM_DOUBLE   0x26
 #define LABCOMM_STRING   0x27
 
-/*
- * Start index for user defined types
- */
-#define LABCOMM_USER     0x40
 
 /*
  * Macro to automagically call constructors in modules compiled 
@@ -96,17 +99,14 @@ struct labcomm_reader_action_context;
 
 struct labcomm_reader_action {
   /* 'alloc' is called at the first invocation of 'labcomm_decoder_decode_one' 
-     on the decoder containing the reader. If 'labcomm_version' != NULL
-     and non-empty the transport layer may use it to ensure that
-     compatible versions are used.
+     on the decoder containing the reader.
 
      Returned value:
        >  0    Number of bytes allocated for buffering
        <= 0    Error
   */
   int (*alloc)(struct labcomm_reader *r, 
-	       struct labcomm_reader_action_context *action_context, 
-	       char *labcomm_version);
+	       struct labcomm_reader_action_context *action_context);
   /* 'free' returns the resources claimed by 'alloc' and might have other
      reader specific side-effects as well.
 
@@ -159,8 +159,7 @@ struct labcomm_reader {
 };
 
 int labcomm_reader_alloc(struct labcomm_reader *r, 
-			 struct labcomm_reader_action_context *action_context, 
-			 char *labcomm_version);
+			 struct labcomm_reader_action_context *action_context);
 int labcomm_reader_free(struct labcomm_reader *r, 
 			struct labcomm_reader_action_context *action_context);
 int labcomm_reader_start(struct labcomm_reader *r, 
@@ -299,8 +298,7 @@ struct labcomm_writer_action_context;
 
 struct labcomm_writer_action {
   int (*alloc)(struct labcomm_writer *w, 
-	       struct labcomm_writer_action_context *action_context, 
-	       char *labcomm_version);
+	       struct labcomm_writer_action_context *action_context);
   int (*free)(struct labcomm_writer *w, 
 	      struct labcomm_writer_action_context *action_context);
   /* 'start' is called right before a sample is to be sent. In the 
@@ -345,8 +343,7 @@ struct labcomm_writer {
 };
 
 int labcomm_writer_alloc(struct labcomm_writer *w, 
-			 struct labcomm_writer_action_context *action_context, 
-			 char *labcomm_version);
+			 struct labcomm_writer_action_context *action_context);
 int labcomm_writer_free(struct labcomm_writer *w, 
 			struct labcomm_writer_action_context *action_context);
 int labcomm_writer_start(struct labcomm_writer *w, 
@@ -377,6 +374,9 @@ int labcomm_internal_encoder_ioctl(struct labcomm_encoder *encoder,
 				   struct labcomm_signature *signature,
 				   uint32_t ioctl_action, va_list args);
 
+int labcomm_internal_sizeof(struct labcomm_signature *signature,
+                            void *v);
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 
 #define LABCOMM_ENCODE(name, type)					\
@@ -445,7 +445,7 @@ static inline int labcomm_write_string(struct labcomm_writer *w, char *s)
 {
   int length, i, err; 
 
-  length = strlen((char*)s);
+  length = strlen(s);
   err = labcomm_write_packed32(w, length);
   if (err != 0) { return err; }
   for (i = 0 ; i < length ; i++) {
@@ -473,6 +473,13 @@ static inline int labcomm_size_packed32(unsigned int data)
 
 }
 
+static inline int labcomm_size_string(char *s)
+{
+  int length = strlen(s);
+  
+  return labcomm_size_packed32(length) + length;
+}
+
 /*
  * Macros for handling arrays indexed by signature index
  */
diff --git a/lib/c/test/test_labcomm.c b/lib/c/test/test_labcomm.c
index b14f81440ecba90956701a31a60d270df5b978f4..4d158a690b04e22a24fa78feaf6c99047452123d 100644
--- a/lib/c/test/test_labcomm.c
+++ b/lib/c/test/test_labcomm.c
@@ -33,8 +33,7 @@
 static unsigned char buffer[512];
 
 static int writer_alloc(struct labcomm_writer *w, 
-			struct labcomm_writer_action_context *action_context, 
-			char *labcomm_version)
+			struct labcomm_writer_action_context *action_context)
 {
   w->data = buffer;
   w->data_size = sizeof(buffer);
@@ -68,8 +67,7 @@ static struct labcomm_writer writer =  {
 };
 
 static int reader_alloc(struct labcomm_reader *r, 
-			struct labcomm_reader_action_context *action_context, 
-			char *labcomm_version)
+			struct labcomm_reader_action_context *action_context)
 {
   r->data = buffer;
   r->data_size = sizeof(buffer);
@@ -127,8 +125,8 @@ int test_decode_one(struct labcomm_decoder *decoder)
   for (reader.count = 0 ; reader.count < writer.pos ; reader.count++) {
     reader.error = 0;
     reader.pos = 0;
-    result = labcomm_decoder_decode_one(decoder);
-    if (result >= 0) {
+    result = labcomm_decoder_decode_one(decoder); 
+    if (result >= 0 ) {
       fprintf(stderr, "Got result from buffer with bogus length (%d)\n",
 	      result);
       exit(1);
@@ -187,212 +185,27 @@ int main(void)
     labcomm_default_error_handler,
     labcomm_default_memory,
     labcomm_default_scheduler);
+  err = test_decode_one(decoder);
+  fprintf(stderr, "decode of version -> index %d\n", err);
+  writer.pos = 0;
   labcomm_decoder_register_test_sample_test_var(decoder,
 						handle_test_var, 
 						NULL);
   labcomm_encoder_register_test_sample_test_var(encoder);
   err = test_decode_one(decoder);
   fprintf(stderr, "decode of register -> index %d\n", err);
-  test_encode_decode(encoder, decoder, 7, 1, 1);
+  test_encode_decode(encoder, decoder, 8, 1, 1);
   if (decoder_var.a[0] != encoder_var.a[0]) {
     fprintf(stderr, "Failed to decode correct value %d != %d\n", 
 	    encoder_var.a[0], decoder_var.a[0]);
     exit(1);
   }
-  test_encode_decode(encoder, decoder, 19, 2, 2);
-  test_encode_decode(encoder, decoder, 3, 0, 0);
+  test_encode_decode(encoder, decoder, 20, 2, 2);
+  test_encode_decode(encoder, decoder, 4, 0, 0);
   for (i = 1 ; i <= 4 ; i++) {
-    test_encode_decode(encoder, decoder, 2+i, 0, (1<<(7*i))-1);
-    test_encode_decode(encoder, decoder, 3+i, 0, (1<<(7*i)));
+    test_encode_decode(encoder, decoder, 3+i, 0, (1<<(7*i))-1);
+    test_encode_decode(encoder, decoder, 4+i, 0, (1<<(7*i)));
   }
-  test_encode_decode(encoder, decoder, 7, 0, 4294967295);
+  test_encode_decode(encoder, decoder, 8, 0, 4294967295);
   return 0;
 }
-
-#if 0
-#include <stdbool.h>
-#include <stdlib.h>
-
-#include <labcomm.h>
-#include <labcomm_mem_writer.h>
-#include <labcomm_mem_reader.h>
-#include "test/testdata/gen/test_sample.h"
-
-#define TEST_BUFFER_SIZE (50)
-
-void test_error_handler(enum labcomm_error error_id, size_t nbr_va_args, ...);
-
-int init_suit_labcomm()
-{
-	return 0;
-}
-
-int clean_suit_labcomm()
-{
-	return 0;
-}
-
-void setup_connected_encoder_decoder(struct labcomm_encoder **enc,
-		labcomm_mem_writer_context_t *enc_ctx,
-		struct labcomm_decoder **dec,
-		labcomm_mem_reader_context_t *dec_ctx)
-{
-	enc_ctx->write_pos = 0;
-	enc_ctx->buf = malloc(TEST_BUFFER_SIZE);
-	enc_ctx->length = TEST_BUFFER_SIZE;
-
-	*enc = labcomm_encoder_new(labcomm_mem_writer, enc_ctx);
-
-	dec_ctx->size = 0;
-	dec_ctx->enc_data = enc_ctx->buf;
-	*dec = labcomm_decoder_new(labcomm_mem_reader, dec_ctx);
-
-	labcomm_register_error_handler_decoder(*dec, test_error_handler);
-	labcomm_register_error_handler_encoder(*enc, test_error_handler);
-}
-
-static bool in_error = false;
-static enum labcomm_error in_error_id = LABCOMM_ERROR_ENUM_BEGIN_GUARD;
-void test_error_handler(enum labcomm_error error_id, size_t nbr_va_args, ...)
-{
-	in_error = true;
-	in_error_id = error_id;
-}
-
-static bool got_sample = false;
-void test_decoder_handle_test_sample_test_var(test_sample_test_var *v, void *ctx)
-{
-	got_sample = true;
-}
-
-void test_decoder_decode_sig()
-{
-	labcomm_mem_writer_context_t enc_ctx;
-	struct labcomm_encoder *encoder;
-	labcomm_mem_reader_context_t dec_ctx;
-	struct labcomm_decoder *decoder;
-	setup_connected_encoder_decoder(&encoder, &enc_ctx, &decoder, &dec_ctx);
-
-	labcomm_encoder_register_test_sample_test_var(encoder);
-	dec_ctx.size = enc_ctx.write_pos;
-
-	labcomm_decoder_register_test_sample_test_var(decoder,
-			test_decoder_handle_test_sample_test_var, NULL);
-	labcomm_decoder_decode_one(decoder);
-
-	CU_ASSERT_FALSE(in_error);
-	enc_ctx.write_pos = 0;
-	test_sample_test_var var = 1;
-	labcomm_encode_test_sample_test_var(encoder, &var);
-	dec_ctx.size = enc_ctx.write_pos;
-	labcomm_decoder_decode_one(decoder);
-
-	CU_ASSERT_FALSE(in_error);
-	CU_ASSERT_FALSE(got_sample);
-
-	labcomm_decoder_free(decoder);
-	labcomm_encoder_free(encoder);
-	free(enc_ctx.buf);
-
-	in_error = false;
-	in_error_id = LABCOMM_ERROR_ENUM_BEGIN_GUARD;
-	got_sample = false;
-}
-
-static bool got_new_datatype = false;
-static labcomm_signature_t new_sig;
-int test_new_datatype(struct labcomm_decoder *decoder,
-		labcomm_signature_t *sig)
-{
-	got_new_datatype = true;
-	memcpy(&new_sig, sig, sizeof(labcomm_signature_t));
-	return 0;
-}
-
-void test_decode_unreg_signature_handle()
-{
-	labcomm_mem_writer_context_t enc_ctx;
-	struct labcomm_encoder *encoder;
-	labcomm_mem_reader_context_t dec_ctx;
-	struct labcomm_decoder *decoder;
-	setup_connected_encoder_decoder(&encoder, &enc_ctx, &decoder, &dec_ctx);
-
-	labcomm_encoder_register_test_sample_test_var(encoder);
-	dec_ctx.size = enc_ctx.write_pos;
-	labcomm_decoder_register_new_datatype_handler(decoder, test_new_datatype);
-	labcomm_decoder_decode_one(decoder);
-
-	CU_ASSERT_TRUE(got_new_datatype);
-	CU_ASSERT_EQUAL(
-			memcmp(new_sig.signature, dec_ctx.enc_data, dec_ctx.size), 0);
-
-	got_new_datatype = false;
-	labcomm_decoder_free(decoder);
-	labcomm_encoder_free(encoder);
-	free(enc_ctx.buf);
-}
-
-void test_decode_unreg_signature_error()
-{
-	labcomm_mem_writer_context_t enc_ctx;
-	struct labcomm_encoder *encoder;
-	labcomm_mem_reader_context_t dec_ctx;
-	struct labcomm_decoder *decoder;
-	setup_connected_encoder_decoder(&encoder, &enc_ctx, &decoder, &dec_ctx);
-
-	labcomm_encoder_register_test_sample_test_var(encoder);
-	dec_ctx.size = enc_ctx.write_pos;
-
-	labcomm_decoder_decode_one(decoder);
-
-	CU_ASSERT_TRUE(in_error);
-	CU_ASSERT_EQUAL(in_error_id, LABCOMM_ERROR_DEC_UNKNOWN_DATATYPE);
-	got_new_datatype = false;
-	labcomm_decoder_free(decoder);
-	labcomm_encoder_free(encoder);
-	free(enc_ctx.buf);
-}
-int main()
-{
-	CU_pSuite suite_decoder = NULL;
-
-	// Initialize CUnit test registry.
-	if (CUE_SUCCESS != CU_initialize_registry()) {
-		return CU_get_error();
-	}
-
-	// Add our test suites.
-	suite_decoder = CU_add_suite("transport_enc_dec",
-			init_suit_labcomm, clean_suit_labcomm);
-	if (suite_decoder == NULL) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-
-	if (
-			(CU_add_test(suite_decoder, "test_decoder_decode_sig",
-					test_decoder_decode_sig) == NULL)
-			||
-			(CU_add_test(suite_decoder, "test_decode_unreg_signature_handle",
-					test_decode_unreg_signature_handle) == NULL)
-			||
-			(CU_add_test(suite_decoder, "test_decode_unreg_signature_error",
-					test_decode_unreg_signature_error) == NULL)
-		) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-
-	// Set verbosity.
-	CU_basic_set_mode(CU_BRM_VERBOSE);
-	/*CU_console_run_tests();*/
-
-	// Run all test suites.
-	CU_basic_run_tests();
-
-	// Clean up.
-	CU_cleanup_registry();
-
-	return CU_get_error();
-}
-#endif
diff --git a/lib/c/test/test_labcomm_generated_encoding.c b/lib/c/test/test_labcomm_generated_encoding.c
index 670b8247472c127839eaabf6340e438d538d6c81..8a85ada6d15f74a5aafbb60798ff410b770ff98c 100644
--- a/lib/c/test/test_labcomm_generated_encoding.c
+++ b/lib/c/test/test_labcomm_generated_encoding.c
@@ -37,8 +37,7 @@ struct labcomm_writer *writer;
 
 static int buf_writer_alloc(
   struct labcomm_writer *w, 
-  struct labcomm_writer_action_context *action_context,
-  char *labcomm_version)
+  struct labcomm_writer_action_context *action_context)
 {
   writer = w; /* Hack */
   w->data_size = sizeof(buffer);
@@ -190,23 +189,25 @@ int main(void)
     labcomm_pthread_scheduler_new(labcomm_default_memory));
 
   labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
+  /* Register twice to make sure that only one registration gets encoded */
   labcomm_encoder_register_generated_encoding_V(encoder);
   labcomm_encoder_register_generated_encoding_V(encoder);
-  EXPECT({ 0x02, -1, 0x01, 'V', 0x11, 0x00 });
+  EXPECT({ 0x02, 0x06, -1, 0x01, 'V', 0x02, 0x11, 0x00 });
 
   labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
+  /* Register twice to make sure that only one registration gets encoded */
   labcomm_encoder_register_generated_encoding_B(encoder);
   labcomm_encoder_register_generated_encoding_B(encoder);
-  EXPECT({0x02, -1, 0x01, 'B', 0x21});
+  EXPECT({0x02, 0x05, -1, 0x01, 'B',0x01, 0x21});
 
   labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
   // was: labcomm_encode_generated_encoding_V(encoder, &V);
   labcomm_encode_generated_encoding_V(encoder);
-  EXPECT({-1});
+  EXPECT({-1, 0x00 });
 
   labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
   labcomm_encode_generated_encoding_B(encoder, &B);
-  EXPECT({-1, 1});
+  EXPECT({-1, 0x01, 1});
 
   return 0;
 }
diff --git a/lib/csharp/Makefile b/lib/csharp/Makefile
index 9a7d581e2594e79c0480ca0b9d26b9138e295187..370c77e2fce1d12e48fa99ff3ce766feab2748b7 100644
--- a/lib/csharp/Makefile
+++ b/lib/csharp/Makefile
@@ -1,14 +1,14 @@
-MODULES=LabCommDispatcher \
-	LabCommDecoderRegistry \
-	LabComm \
-	LabCommSample \
-	LabCommHandler \
-	LabCommEncoderRegistry \
-	LabCommDecoder \
-	LabCommType \
-	LabCommEncoderChannel \
-	LabCommEncoder \
-	LabCommDecoderChannel \
+MODULES=Constant\
+	Decoder \
+	DecoderChannel \
+	DecoderRegistry \
+	Encoder \
+	EncoderChannel \
+	EncoderRegistry \
+	Sample \
+	SampleDispatcher \
+	SampleHandler \
+	SampleType 
 
 all: labcomm.dll
 
diff --git a/lib/csharp/se/lth/control/labcomm/LabComm.cs b/lib/csharp/se/lth/control/labcomm/Constant.cs
similarity index 67%
rename from lib/csharp/se/lth/control/labcomm/LabComm.cs
rename to lib/csharp/se/lth/control/labcomm/Constant.cs
index 93efe6813aa68f97dcdef394e2eaef9931973901..170cb55055244cf0ccc53bc3daca5a0ecc7260cf 100644
--- a/lib/csharp/se/lth/control/labcomm/LabComm.cs
+++ b/lib/csharp/se/lth/control/labcomm/Constant.cs
@@ -1,14 +1,20 @@
 namespace se.lth.control.labcomm {
 
-  public class LabComm {
+  public class Constant {
 
-   public const string VERSION = "LabComm2013";
+    public const string CURRENT_VERSION = "LabComm2014";
 
-   /*
-     * Predeclared aggregate type indices
+    /*
+     * Allowed packet tags
      */
-    public const int TYPEDEF          = 0x01;
+    public const int VERSION          = 0x01;
     public const int SAMPLE           = 0x02;
+    public const int PRAGMA           = 0x3f;
+    public const int FIRST_USER_INDEX = 0x40; /* ..0xffffffff */
+
+    /*
+     * Predefined aggregate type indices
+     */
     public const int ARRAY            = 0x10;
     public const int STRUCT           = 0x11;
     
@@ -24,11 +30,6 @@ namespace se.lth.control.labcomm {
     public const int DOUBLE           = 0x26;
     public const int STRING           = 0x27;
     
-    /*
-     * start of user defined types 
-     */
-    public const int FIRST_USER_INDEX = 0x40;
-
   }
 
 }
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDecoder.cs b/lib/csharp/se/lth/control/labcomm/Decoder.cs
similarity index 71%
rename from lib/csharp/se/lth/control/labcomm/LabCommDecoder.cs
rename to lib/csharp/se/lth/control/labcomm/Decoder.cs
index bcb9dea3ba2de20d94ad76b0826048b605156ab4..6f2086b8aa4a6b622998f4ef043dbd765dac61a7 100644
--- a/lib/csharp/se/lth/control/labcomm/LabCommDecoder.cs
+++ b/lib/csharp/se/lth/control/labcomm/Decoder.cs
@@ -2,10 +2,10 @@ using System;
 
 namespace se.lth.control.labcomm {
 
-  public interface LabCommDecoder {
+  public interface Decoder {
 
-    void register(LabCommDispatcher dispatcher, 
-		  LabCommHandler handler);
+    void register(SampleDispatcher dispatcher, 
+		  SampleHandler handler);
 
     bool decodeBoolean();
     byte decodeByte();
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs b/lib/csharp/se/lth/control/labcomm/DecoderChannel.cs
similarity index 60%
rename from lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs
rename to lib/csharp/se/lth/control/labcomm/DecoderChannel.cs
index 2d6b8d4126daac41875ea3864e6eedfdf91bb54a..19e4e0db484c5c4d8cef067c0403c450d4c14fe4 100644
--- a/lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs
+++ b/lib/csharp/se/lth/control/labcomm/DecoderChannel.cs
@@ -5,44 +5,47 @@ namespace se.lth.control.labcomm {
   using System.Runtime.InteropServices;
   using System.Text;
 
-  public class LabCommDecoderChannel : LabCommDecoder {
+  public class DecoderChannel : Decoder {
 
     private Stream stream;
-    private LabCommDecoderRegistry registry = new LabCommDecoderRegistry();
+    private DecoderRegistry registry = new DecoderRegistry();
     byte[] buf = new byte[8];
 
-    public LabCommDecoderChannel(Stream stream) {
+    public DecoderChannel(Stream stream) {
       this.stream = stream;
-      String version = decodeString();
-      if (version != LabComm.VERSION) {
-	throw new IOException("LabComm version mismatch " +
-			      version + " != " + LabComm.VERSION);
-      }
     }
 
     public void runOne() {
       bool done = false;
       while (!done) {
 	int tag = decodePacked32();
+        int length = decodePacked32();
 	switch (tag) {
-	case LabComm.TYPEDEF:
-        case LabComm.SAMPLE: {
+        case Constant.VERSION: {
+          String version = decodeString();
+          if (version != Constant.CURRENT_VERSION) {
+  	    throw new IOException("LabComm version mismatch " +
+			          version + " != " + Constant.CURRENT_VERSION);
+          }
+        } break;
+        case Constant.SAMPLE: {
           int index = decodePacked32();
           String name = decodeString();
-	  MemoryStream signature = new MemoryStream();
-	  collectFlatSignature(new LabCommEncoderChannel(signature, false));
-	  registry.add(index, name, signature.ToArray());
+          int signature_length = decodePacked32();
+          byte[] signature = new byte[signature_length];
+          ReadBytes(signature, signature_length);
+	  registry.add(index, name, signature);
         } break;
         default: {
-          LabCommDecoderRegistry.Entry e = registry.get(tag);
+          DecoderRegistry.Entry e = registry.get(tag);
           if (e == null) {
             throw new IOException("Unhandled tag " + tag);
           }
-          LabCommDispatcher d = e.getDispatcher();
+          SampleDispatcher d = e.getSampleDispatcher();
           if (d == null) {
             throw new IOException("No dispatcher for '" + e.getName() + "'" + e.getSignature());
           }
-          LabCommHandler h = e.getHandler();
+          SampleHandler h = e.getHandler();
           if (h == null) {
             throw new IOException("No handler for '" + e.getName() +"'");
           }
@@ -59,44 +62,8 @@ namespace se.lth.control.labcomm {
       }
     }
 
-    private void collectFlatSignature(LabCommEncoder e) {
-      int type = decodePacked32();
-      e.encodePacked32(type);
-      switch (type) {
-      case LabComm.ARRAY: {
-        int dimensions = decodePacked32();
-        e.encodePacked32(dimensions);
-        for (int i = 0 ; i < dimensions ; i++) {
-          e.encodePacked32(decodePacked32());
-        }
-        collectFlatSignature(e);
-      } break;
-      case LabComm.STRUCT: {
-        int fields = decodePacked32();
-        e.encodePacked32(fields);
-        for (int i = 0 ; i < fields ; i++) {
-          e.encodeString(decodeString());
-          collectFlatSignature(e);
-        }
-      } break;
-      case LabComm.BOOLEAN:
-      case LabComm.BYTE:
-      case LabComm.SHORT:
-      case LabComm.INT:
-      case LabComm.LONG:
-      case LabComm.FLOAT:
-      case LabComm.DOUBLE:
-      case LabComm.STRING: {
-      } break;
-      default: {
-        throw new IOException("Unimplemented type=" + type);
-      }
-      }
-      e.end(null);
-    }
-
-    public void register(LabCommDispatcher dispatcher, 
-			 LabCommHandler handler) {
+    public void register(SampleDispatcher dispatcher, 
+			 SampleHandler handler) {
       registry.add(dispatcher, handler);
     }
 
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDecoderRegistry.cs b/lib/csharp/se/lth/control/labcomm/DecoderRegistry.cs
similarity index 84%
rename from lib/csharp/se/lth/control/labcomm/LabCommDecoderRegistry.cs
rename to lib/csharp/se/lth/control/labcomm/DecoderRegistry.cs
index ed522e0d76f5a2935d401e2b55fcbf9ab559c4ce..132e37b1849c965a51093fc403f277b1bc615394 100644
--- a/lib/csharp/se/lth/control/labcomm/LabCommDecoderRegistry.cs
+++ b/lib/csharp/se/lth/control/labcomm/DecoderRegistry.cs
@@ -3,18 +3,18 @@ namespace se.lth.control.labcomm {
   using System;
   using System.Collections.Generic;
 
-  public class LabCommDecoderRegistry {
+  public class DecoderRegistry {
 
     public class Entry {
     
-      private LabCommDispatcher dispatcher;
-      private LabCommHandler handler;
+      private SampleDispatcher dispatcher;
+      private SampleHandler handler;
       private int index;
       private String name;
       private byte[] signature;
 
-      public Entry(LabCommDispatcher dispatcher,
-		   LabCommHandler handler) {
+      public Entry(SampleDispatcher dispatcher,
+		   SampleHandler handler) {
 	this.dispatcher = dispatcher;
 	this.name = dispatcher.getName();
 	this.signature = dispatcher.getSignature();
@@ -27,19 +27,19 @@ namespace se.lth.control.labcomm {
 	this.signature = signature;
       }
 
-      public LabCommDispatcher getDispatcher() {
+      public SampleDispatcher getSampleDispatcher() {
 	return dispatcher;
       }
 
-      public void setDispatcher(LabCommDispatcher dispatcher) {
+      public void setSampleDispatcher(SampleDispatcher dispatcher) {
 	this.dispatcher = dispatcher;
       }
 
-      public LabCommHandler getHandler() {
+      public SampleHandler getHandler() {
 	return handler;
       }
 
-      public void setHandler(LabCommHandler handler) {
+      public void setHandler(SampleHandler handler) {
 	this.handler = handler;
       }
 
@@ -93,13 +93,13 @@ namespace se.lth.control.labcomm {
     private Dictionary<Type, Entry> byClass;
     private Dictionary<int, Entry> byIndex;
 
-    public LabCommDecoderRegistry() {
+    public DecoderRegistry() {
       byClass = new Dictionary<Type, Entry>();
       byIndex = new Dictionary<int, Entry>();
     }
 
-    public void add(LabCommDispatcher dispatcher,
-		    LabCommHandler handler) {
+    public void add(SampleDispatcher dispatcher,
+		    SampleHandler handler) {
       lock(this) {
 	Entry e;
 	byClass.TryGetValue(dispatcher.getSampleClass(), out e);
@@ -109,7 +109,7 @@ namespace se.lth.control.labcomm {
 	} else {
 	  foreach (Entry e2 in byIndex.Values) {
 	    if (e2.match(dispatcher.getName(), dispatcher.getSignature())) {
-	      e2.setDispatcher(dispatcher);
+	      e2.setSampleDispatcher(dispatcher);
 	      e2.setHandler(handler);
 	      e = e2;
 	      break;
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommEncoder.cs b/lib/csharp/se/lth/control/labcomm/Encoder.cs
similarity index 83%
rename from lib/csharp/se/lth/control/labcomm/LabCommEncoder.cs
rename to lib/csharp/se/lth/control/labcomm/Encoder.cs
index aadc98ebfc4c2cd00844ade06ae5a1dd13f19043..f33af1718bdbb7ad1e5523659be86a8f6d0ff920 100644
--- a/lib/csharp/se/lth/control/labcomm/LabCommEncoder.cs
+++ b/lib/csharp/se/lth/control/labcomm/Encoder.cs
@@ -2,9 +2,9 @@ namespace se.lth.control.labcomm {
 
   using System;
 
-  public interface LabCommEncoder {
+  public interface Encoder {
     
-    void register(LabCommDispatcher dispatcher);
+    void register(SampleDispatcher dispatcher);
     void begin(Type c);
     void end(Type c);
 
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommEncoderChannel.cs b/lib/csharp/se/lth/control/labcomm/EncoderChannel.cs
similarity index 72%
rename from lib/csharp/se/lth/control/labcomm/LabCommEncoderChannel.cs
rename to lib/csharp/se/lth/control/labcomm/EncoderChannel.cs
index 6cabb59bba22383ccc4fb36b103f33117aa794a5..ca717d501dc98475145ba17c87af41ea1282c157 100644
--- a/lib/csharp/se/lth/control/labcomm/LabCommEncoderChannel.cs
+++ b/lib/csharp/se/lth/control/labcomm/EncoderChannel.cs
@@ -5,45 +5,64 @@ namespace se.lth.control.labcomm {
   using System.Text;
   using System.Runtime.InteropServices;
 
-  public class LabCommEncoderChannel : LabCommEncoder {
+  public class EncoderChannel : Encoder {
 
     private Stream writer;
     private MemoryStream bytes = new MemoryStream();
-    private LabCommEncoderRegistry registry = new LabCommEncoderRegistry();
+    private EncoderRegistry registry = new EncoderRegistry();
     byte[] buf = new byte[8];
+    private int current_tag; 
 
-    public LabCommEncoderChannel(Stream writer, bool emitVersion) {
+    public EncoderChannel(Stream writer) {
       this.writer = writer;
-      if (emitVersion) {
-	encodeString(LabComm.VERSION);
-      }
-    }
 
-    public LabCommEncoderChannel(Stream writer) : this(writer, true) {
+      begin(Constant.VERSION);
+      encodeString(Constant.CURRENT_VERSION);
+      end(null);
     }
 
-    public void register(LabCommDispatcher dispatcher) {
+    public void register(SampleDispatcher dispatcher) {
       int index = registry.add(dispatcher);
-      encodePacked32(LabComm.SAMPLE);
+      begin(Constant.SAMPLE);
       encodePacked32(index);
       encodeString(dispatcher.getName());
       byte[] signature = dispatcher.getSignature();
+      encodePacked32(signature.Length);
       for (int i = 0 ; i < signature.Length ; i++) {
 	encodeByte(signature[i]);
       }
       end(null);
     }
 
+    private void begin(int tag) {
+      current_tag = tag;
+      bytes.SetLength(0);
+    }
+
     public void begin(Type c) {
-      encodePacked32(registry.getTag(c));
+      begin(registry.getTag(c));
     }
 
     public void end(Type c) {
+      WritePacked32(writer, current_tag);
+      WritePacked32(writer, bytes.Length);
       bytes.WriteTo(writer);
       bytes.SetLength(0);
       writer.Flush();
     }
 
+    private void WritePacked32(Stream s, Int64 value) {
+      Int64 v = value & 0xffffffff;
+      int i;
+  
+      for (i = 0 ; i == 0 || v != 0 ; i++, v = (v >> 7)) {
+        buf[i] = (byte)(v & 0x7f | (i!=0?0x80:0x00));
+      }
+      for (i = i - 1 ; i >= 0 ; i--) {
+        s.WriteByte(buf[i]);
+      }      
+    }
+
     private void WriteInt(Int64 value, int length) {
       for (int i = length - 1 ; i >= 0 ; i--) {
 	buf[i] = (byte)(value & 0xff);
@@ -96,16 +115,7 @@ namespace se.lth.control.labcomm {
     }
 
     public void encodePacked32(Int64 value) {
-      byte[] tmp = new byte[5];
-      Int64 v = value & 0xffffffff;
-      int i;
-  
-      for (i = 0 ; i == 0 || v != 0 ; i++, v = (v >> 7)) {
-        tmp[i] = (byte)(v & 0x7f);
-      }
-      for (i = i - 1 ; i >= 0 ; i--) {
-        encodeByte((byte)(tmp[i] | (i!=0?0x80:0x00)));
-      }
+      WritePacked32(bytes, value);
     }
   }
 }
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommEncoderRegistry.cs b/lib/csharp/se/lth/control/labcomm/EncoderRegistry.cs
similarity index 72%
rename from lib/csharp/se/lth/control/labcomm/LabCommEncoderRegistry.cs
rename to lib/csharp/se/lth/control/labcomm/EncoderRegistry.cs
index 6bc5d4056459eccac4db6ea586ccfc7ed826c554..9c40028567ac2d3df3080e6d2fd88d7e796a6d4f 100644
--- a/lib/csharp/se/lth/control/labcomm/LabCommEncoderRegistry.cs
+++ b/lib/csharp/se/lth/control/labcomm/EncoderRegistry.cs
@@ -3,19 +3,19 @@ namespace se.lth.control.labcomm {
   using System;
   using System.Collections.Generic;
 
-  public class LabCommEncoderRegistry {
+  public class EncoderRegistry {
 
     public class Entry {
     
-      private LabCommDispatcher dispatcher;
+      private SampleDispatcher dispatcher;
       private int index;
 
-      public Entry(LabCommDispatcher dispatcher, int index) {
+      public Entry(SampleDispatcher dispatcher, int index) {
 	this.dispatcher = dispatcher;
 	this.index = index;
       }
 
-      public LabCommDispatcher getDispatcher() {
+      public SampleDispatcher getSampleDispatcher() {
 	return dispatcher;
       }
 
@@ -25,14 +25,14 @@ namespace se.lth.control.labcomm {
 
     }
 
-    private int userIndex = LabComm.FIRST_USER_INDEX;
+    private int userIndex = Constant.FIRST_USER_INDEX;
     private Dictionary<Type, Entry> byClass;
 
-    public LabCommEncoderRegistry() {
+    public EncoderRegistry() {
       byClass = new Dictionary<Type, Entry>();
     }
 
-    public int add(LabCommDispatcher dispatcher) {
+    public int add(SampleDispatcher dispatcher) {
       lock(this) {
 	Entry e;
 	byClass.TryGetValue(dispatcher.getSampleClass(), out e);
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommSample.cs b/lib/csharp/se/lth/control/labcomm/LabCommSample.cs
deleted file mode 100644
index 235d97d1e48443e290428df905531ef63402a377..0000000000000000000000000000000000000000
--- a/lib/csharp/se/lth/control/labcomm/LabCommSample.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-public interface LabCommSample {
-
-}
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommType.cs b/lib/csharp/se/lth/control/labcomm/LabCommType.cs
deleted file mode 100644
index 10046819f059d114af4de5f3a15a4a35da5017c5..0000000000000000000000000000000000000000
--- a/lib/csharp/se/lth/control/labcomm/LabCommType.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-public interface LabCommType {
-
-}
diff --git a/lib/csharp/se/lth/control/labcomm/Sample.cs b/lib/csharp/se/lth/control/labcomm/Sample.cs
new file mode 100644
index 0000000000000000000000000000000000000000..ac562293a0e369a7996099068b5d7b94473a7f84
--- /dev/null
+++ b/lib/csharp/se/lth/control/labcomm/Sample.cs
@@ -0,0 +1,3 @@
+public interface Sample {
+
+}
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDispatcher.cs b/lib/csharp/se/lth/control/labcomm/SampleDispatcher.cs
similarity index 57%
rename from lib/csharp/se/lth/control/labcomm/LabCommDispatcher.cs
rename to lib/csharp/se/lth/control/labcomm/SampleDispatcher.cs
index 75b06522be195d6337bf132221aff045bd71406c..23d39ed510ac07653c753e201f452788a97a901f 100644
--- a/lib/csharp/se/lth/control/labcomm/LabCommDispatcher.cs
+++ b/lib/csharp/se/lth/control/labcomm/SampleDispatcher.cs
@@ -2,7 +2,7 @@ namespace se.lth.control.labcomm {
 
   using System;
 
-  public interface LabCommDispatcher {
+  public interface SampleDispatcher {
     
     Type getSampleClass();
     
@@ -10,8 +10,8 @@ namespace se.lth.control.labcomm {
     
     byte[] getSignature();
     
-    void decodeAndHandle(LabCommDecoder decoder,
-			 LabCommHandler handler);
+    void decodeAndHandle(Decoder decoder,
+			 SampleHandler handler);
 
   }
 
diff --git a/lib/csharp/se/lth/control/labcomm/LabCommHandler.cs b/lib/csharp/se/lth/control/labcomm/SampleHandler.cs
similarity index 53%
rename from lib/csharp/se/lth/control/labcomm/LabCommHandler.cs
rename to lib/csharp/se/lth/control/labcomm/SampleHandler.cs
index 3d7f293d471b439d373a215f663b83c62d132781..d30cd2623c954dcb22917225d46ed79a4d6dc3f3 100644
--- a/lib/csharp/se/lth/control/labcomm/LabCommHandler.cs
+++ b/lib/csharp/se/lth/control/labcomm/SampleHandler.cs
@@ -1,6 +1,6 @@
 namespace se.lth.control.labcomm {
 
-  public interface LabCommHandler {
+  public interface SampleHandler {
   }
 
 }
\ No newline at end of file
diff --git a/lib/csharp/se/lth/control/labcomm/SampleType.cs b/lib/csharp/se/lth/control/labcomm/SampleType.cs
new file mode 100644
index 0000000000000000000000000000000000000000..42bd601cb74a9516e3fdd2ff631f9340077802c5
--- /dev/null
+++ b/lib/csharp/se/lth/control/labcomm/SampleType.cs
@@ -0,0 +1,3 @@
+public interface SampleType {
+
+}
diff --git a/lib/java/Makefile b/lib/java/Makefile
index 48204f46e11adc1a71d1cff40ace66d2576f8cd7..20f439e7d06c073ab30036e7b13fd8ff85efc530 100644
--- a/lib/java/Makefile
+++ b/lib/java/Makefile
@@ -1,25 +1,25 @@
-MODULES=LabCommDispatcher \
-	LabCommDecoderRegistry \
-	LabComm \
-	LabCommSample \
-	LabCommHandler \
-	LabCommEncoderRegistry \
-	LabCommType \
-	LabCommEncoder \
-	LabCommEncoderChannel \
-	LabCommDecoder \
-	LabCommDecoderChannel \
-	LabCommWriter \
-	LabCommReader \
+MODULES=Constant \
+	Decoder \
+	DecoderChannel \
+	DecoderRegistry \
+	Encoder \
+	EncoderChannel \
+	EncoderRegistry \
+	Reader \
+	Sample \
+	SampleDispatcher \
+	SampleHandler \
+	SampleType \
+	Writer \
 	WriterWrapper
 
-all: labcomm.jar labcomm2013.jar labcomm2006.jar
+all: labcomm.jar labcomm2014.jar labcomm2006.jar
 
 labcomm.jar: gen/JAVAC
 	echo $@
 	cd gen ; jar cf ../$@ se/lth/control/labcomm/*.class se/lth/control/labcomm2006/*.class
 
-labcomm2013.jar: gen/JAVAC
+labcomm2014.jar: gen/JAVAC
 	echo $@
 	cd gen ; jar cf ../$@ se/lth/control/labcomm/*.class
 
@@ -38,5 +38,5 @@ gen/JAVAC: $(MODULES:%=se/lth/control/labcomm/%.java) $(MODULES:%=se/lth/control
 .PHONY: clean
 
 clean:
-	rm -rf labcomm.jar labcomm2006.jar labcomm2013.jar gen 
+	rm -rf labcomm.jar labcomm2006.jar labcomm2014.jar gen 
 
diff --git a/lib/java/se/lth/control/labcomm/LabComm.java b/lib/java/se/lth/control/labcomm/Constant.java
similarity index 68%
rename from lib/java/se/lth/control/labcomm/LabComm.java
rename to lib/java/se/lth/control/labcomm/Constant.java
index 99c74c201a8f7dee87776f23e534000617679aa7..194ae8de66a428a8396ac97ac1f0d48923b6d7ca 100644
--- a/lib/java/se/lth/control/labcomm/LabComm.java
+++ b/lib/java/se/lth/control/labcomm/Constant.java
@@ -1,14 +1,23 @@
 package se.lth.control.labcomm;
 
-public class LabComm {
+public class Constant {
 
-  public static final String VERSION = "LabComm2013";
+  public static final String CURRENT_VERSION = "LabComm2014";
 
+  /*
+   * Allowed packet tags
+   */
   /*
    * Predeclared aggregate type indices
    */
-  public static final int TYPEDEF          = 0x01;
+  public static final int VERSION          = 0x01;
   public static final int SAMPLE           = 0x02;
+  public static final int PRAGMA           = 0x3f;
+  public static final int FIRST_USER_INDEX = 0x40; /* ..0xffffffff */
+
+  /*
+   * Predefined aggregate type indices
+   */
   public static final int ARRAY            = 0x10;
   public static final int STRUCT           = 0x11;
   
@@ -24,9 +33,4 @@ public class LabComm {
   public static final int DOUBLE           = 0x26;
   public static final int STRING           = 0x27;
 
-  /*
-   * Start of user declared types
-   */
-  public static final int FIRST_USER_INDEX = 0x40;
-
 }
diff --git a/lib/java/se/lth/control/labcomm/LabCommDecoder.java b/lib/java/se/lth/control/labcomm/Decoder.java
similarity index 78%
rename from lib/java/se/lth/control/labcomm/LabCommDecoder.java
rename to lib/java/se/lth/control/labcomm/Decoder.java
index a40fb8531f43c8b064835ca2de4b904325b838ca..c3320f3b5db17573882333472b74b5e8975bafc3 100644
--- a/lib/java/se/lth/control/labcomm/LabCommDecoder.java
+++ b/lib/java/se/lth/control/labcomm/Decoder.java
@@ -2,10 +2,10 @@ package se.lth.control.labcomm;
 
 import java.io.IOException;
 
-public interface LabCommDecoder {
+public interface Decoder {
   
-  public void register(LabCommDispatcher dispatcher, 
-		       LabCommHandler handler) throws IOException;
+  public void register(SampleDispatcher dispatcher, 
+		       SampleHandler handler) throws IOException;
   public boolean decodeBoolean() throws IOException;
   public byte decodeByte() throws IOException;
   public short decodeShort() throws IOException;
diff --git a/lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java b/lib/java/se/lth/control/labcomm/DecoderChannel.java
similarity index 52%
rename from lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java
rename to lib/java/se/lth/control/labcomm/DecoderChannel.java
index 0fe0e8261dee9977ccb510b814408796f1489ab5..6f7760fc457fb1d651118dcfe891246f36b0821a 100644
--- a/lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java
+++ b/lib/java/se/lth/control/labcomm/DecoderChannel.java
@@ -4,46 +4,49 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.InputStream;
 import java.io.IOException;
+import java.io.EOFException;
 
-public class LabCommDecoderChannel implements LabCommDecoder {
+public class DecoderChannel implements Decoder {
 
   private DataInputStream in;
-  private LabCommDecoderRegistry registry;
+  private DecoderRegistry registry;
 
-  public LabCommDecoderChannel(InputStream in) throws IOException {
+  public DecoderChannel(InputStream in) throws IOException {
     this.in = new DataInputStream(in);
-    registry = new LabCommDecoderRegistry();
-    String version = decodeString();
-    if (! version.equals(LabComm.VERSION)) {
-      throw new IOException("LabComm version mismatch " +
-			    version + " != " + LabComm.VERSION);
-    }
-    System.err.println(LabComm.VERSION);
+    registry = new DecoderRegistry();
   }
 
   public void runOne() throws Exception {
     boolean done = false;
     while (!done) {
       int tag = decodePacked32();
+      int length = decodePacked32();
       switch (tag) {
-	case LabComm.TYPEDEF:
-	case LabComm.SAMPLE: {
+        case Constant.VERSION: {
+          String version = decodeString();
+          if (! version.equals(Constant.CURRENT_VERSION)) {
+            throw new IOException("LabComm version mismatch " +
+			          version + " != " + Constant.CURRENT_VERSION);
+          }
+        } break;
+	case Constant.SAMPLE: {
 	  int index = decodePacked32();
 	  String name = decodeString();
-	  ByteArrayOutputStream signature = new ByteArrayOutputStream();
-	  collectFlatSignature(new LabCommEncoderChannel(signature, false));
-	  registry.add(index, name, signature.toByteArray());
+          int signature_length = decodePacked32();
+          byte[] signature = new byte[signature_length];
+          ReadBytes(signature, signature_length);
+	  registry.add(index, name, signature);
 	} break;
 	default: {
-	  LabCommDecoderRegistry.Entry e = registry.get(tag);
+	  DecoderRegistry.Entry e = registry.get(tag);
 	  if (e == null) {
 	    throw new IOException("Unhandled tag " + tag);
 	  }
-	  LabCommDispatcher d = e.getDispatcher();
+	  SampleDispatcher d = e.getDispatcher();
 	  if (d == null) {
 	    throw new IOException("No dispatcher for '" + e.getName() + "'");
 	  }
-	  LabCommHandler h = e.getHandler();
+	  SampleHandler h = e.getHandler();
 	  if (h == null) {
 	    throw new IOException("No handler for '" + e.getName() +"'");
 	  }
@@ -60,47 +63,24 @@ public class LabCommDecoderChannel implements LabCommDecoder {
     }
   }
 
-  private void collectFlatSignature(LabCommEncoder out) throws IOException {
-    int type = decodePacked32();
-    out.encodePacked32(type);
-    switch (type) {
-      case LabComm.ARRAY: {
-	int dimensions = decodePacked32();
-	out.encodePacked32(dimensions);
-	for (int i = 0 ; i < dimensions ; i++) {
-	  out.encodePacked32(decodePacked32());
-	}
-	collectFlatSignature(out);
-      } break;
-      case LabComm.STRUCT: {
-	int fields = decodePacked32();
-	out.encodePacked32(fields);
-	for (int i = 0 ; i < fields ; i++) {
-	  out.encodeString(decodeString());
-	  collectFlatSignature(out);
-	}
-      } break;
-      case LabComm.BOOLEAN:
-      case LabComm.BYTE:
-      case LabComm.SHORT:
-      case LabComm.INT:
-      case LabComm.LONG:
-      case LabComm.FLOAT:
-      case LabComm.DOUBLE:
-      case LabComm.STRING: {
-      } break;
-      default: {
-	throw new IOException("Unimplemented type=" + type);
-      }
-    }
-    out.end(null);
-  }
-
-  public void register(LabCommDispatcher dispatcher, 
-                       LabCommHandler handler) throws IOException {
+  public void register(SampleDispatcher dispatcher, 
+                       SampleHandler handler) throws IOException {
     registry.add(dispatcher, handler);
   }
 
+  private void ReadBytes(byte[] result, int length) throws IOException {
+      int offset = 0;
+      while (offset < length) {
+	int count = in.read(result, offset, length - offset);
+	if (count <= 0) {
+	  throw new EOFException(
+	    "End of stream reached with " +
+            (length - offset) + " bytes left to read");
+        }
+	offset += count;
+      }
+    }
+
   public boolean decodeBoolean() throws IOException {
     return in.readBoolean();
   }
diff --git a/lib/java/se/lth/control/labcomm/LabCommDecoderRegistry.java b/lib/java/se/lth/control/labcomm/DecoderRegistry.java
similarity index 84%
rename from lib/java/se/lth/control/labcomm/LabCommDecoderRegistry.java
rename to lib/java/se/lth/control/labcomm/DecoderRegistry.java
index 890aeae2d0ac3d56d1525053daa5f66729f6dba7..fdf8f591d646dad3680e7fbea48e2dcb9ed2ba15 100644
--- a/lib/java/se/lth/control/labcomm/LabCommDecoderRegistry.java
+++ b/lib/java/se/lth/control/labcomm/DecoderRegistry.java
@@ -3,18 +3,18 @@ package se.lth.control.labcomm;
 import java.io.IOException;
 import java.util.HashMap;
 
-public class LabCommDecoderRegistry {
+public class DecoderRegistry {
 
   public static class Entry {
     
-    private LabCommDispatcher dispatcher;
-    private LabCommHandler handler;
+    private SampleDispatcher dispatcher;
+    private SampleHandler handler;
     private int index;
     private String name;
     private byte[] signature;
 
-    public Entry(LabCommDispatcher dispatcher,
-		 LabCommHandler handler) {
+    public Entry(SampleDispatcher dispatcher,
+		 SampleHandler handler) {
       this.dispatcher = dispatcher;
       this.name = dispatcher.getName();
       this.signature = dispatcher.getSignature();
@@ -27,19 +27,19 @@ public class LabCommDecoderRegistry {
       this.signature = signature;
     }
 
-    public LabCommDispatcher getDispatcher() {
+    public SampleDispatcher getDispatcher() {
       return dispatcher;
     }
 
-    public void setDispatcher(LabCommDispatcher dispatcher) {
+    public void setDispatcher(SampleDispatcher dispatcher) {
       this.dispatcher = dispatcher;
     }
 
-    public LabCommHandler getHandler() {
+    public SampleHandler getHandler() {
       return handler;
     }
 
-    public void setHandler(LabCommHandler handler) {
+    public void setHandler(SampleHandler handler) {
       this.handler = handler;
     }
 
@@ -89,13 +89,13 @@ public class LabCommDecoderRegistry {
   private HashMap<Class, Entry> byClass;
   private HashMap<Integer, Entry> byIndex;
 
-  public LabCommDecoderRegistry() {
+  public DecoderRegistry() {
     byClass = new HashMap<Class, Entry>();
     byIndex = new HashMap<Integer, Entry>();
   }
 
-  public synchronized void add(LabCommDispatcher dispatcher,
-			       LabCommHandler handler) throws IOException{
+  public synchronized void add(SampleDispatcher dispatcher,
+			       SampleHandler handler) throws IOException{
     Entry e = byClass.get(dispatcher.getSampleClass());
     if (e != null) {
       e.check(dispatcher.getName(), dispatcher.getSignature());
@@ -141,4 +141,4 @@ public class LabCommDecoderRegistry {
     return byIndex.get(Integer.valueOf(index));
   }
 
-}
\ No newline at end of file
+}
diff --git a/lib/java/se/lth/control/labcomm/LabCommEncoder.java b/lib/java/se/lth/control/labcomm/Encoder.java
similarity index 71%
rename from lib/java/se/lth/control/labcomm/LabCommEncoder.java
rename to lib/java/se/lth/control/labcomm/Encoder.java
index f332d78784cf6281befe30a1eb099fdaea7c175c..d6ef3e5ff2a08502dcde3c548a36e58aa9a5faf5 100644
--- a/lib/java/se/lth/control/labcomm/LabCommEncoder.java
+++ b/lib/java/se/lth/control/labcomm/Encoder.java
@@ -2,11 +2,11 @@ package se.lth.control.labcomm;
 
 import java.io.IOException;
 
-public interface LabCommEncoder {
+public interface Encoder {
 
-  public void register(LabCommDispatcher dispatcher) throws IOException;
-  public void begin(Class<? extends LabCommSample> c) throws IOException;
-  public void end(Class<? extends LabCommSample> c) throws IOException;
+  public void register(SampleDispatcher dispatcher) throws IOException;
+  public void begin(Class<? extends Sample> c) throws IOException;
+  public void end(Class<? extends Sample> c) throws IOException;
   public void encodeBoolean(boolean value) throws IOException;
   public void encodeByte(byte value) throws IOException;
   public void encodeShort(short value) throws IOException;
diff --git a/lib/java/se/lth/control/labcomm/LabCommEncoderChannel.java b/lib/java/se/lth/control/labcomm/EncoderChannel.java
similarity index 63%
rename from lib/java/se/lth/control/labcomm/LabCommEncoderChannel.java
rename to lib/java/se/lth/control/labcomm/EncoderChannel.java
index d9b163ef394bf6e80bc68b680440f152d6b5b4fa..e7c3e809ed710649ad18e47ef291fd3e38d89d29 100644
--- a/lib/java/se/lth/control/labcomm/LabCommEncoderChannel.java
+++ b/lib/java/se/lth/control/labcomm/EncoderChannel.java
@@ -5,61 +5,74 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
-public class LabCommEncoderChannel implements LabCommEncoder {
+public class EncoderChannel implements Encoder {
 
-  private LabCommWriter writer;
+  private Writer writer;
   private ByteArrayOutputStream bytes;
   private DataOutputStream data;
-  private LabCommEncoderRegistry registry;
+  private EncoderRegistry registry;
+  private int current_tag; 
 
-  public LabCommEncoderChannel(LabCommWriter writer, 
-			       boolean emitVersion) throws IOException {
+  public EncoderChannel(Writer writer) throws IOException {
     this.writer = writer;
     bytes = new ByteArrayOutputStream();
     data = new DataOutputStream(bytes);
-    registry = new LabCommEncoderRegistry();
-    if (emitVersion) {
-      encodeString(LabComm.VERSION);
-    }
-  }
-
-  public LabCommEncoderChannel(LabCommWriter writer) throws IOException {
-    this(writer, true);
-  }
+    registry = new EncoderRegistry();
 
-  public LabCommEncoderChannel(OutputStream writer, 
-			       boolean emitVersion) throws IOException {
-    this(new WriterWrapper(writer), emitVersion);
+    begin(Constant.VERSION);
+    encodeString(Constant.CURRENT_VERSION);
+    end(null);
   }
 
-  public LabCommEncoderChannel(OutputStream writer) throws IOException {
-    this(new WriterWrapper(writer), true);
+  public EncoderChannel(OutputStream writer) throws IOException {
+    this(new WriterWrapper(writer));
   }
 
-  public void register(LabCommDispatcher dispatcher) throws IOException {
+  public void register(SampleDispatcher dispatcher) throws IOException {
     int index = registry.add(dispatcher);
-    encodePacked32(LabComm.SAMPLE);
+    begin(Constant.SAMPLE);
     encodePacked32(index);
     encodeString(dispatcher.getName());
     byte[] signature = dispatcher.getSignature();
+    encodePacked32(signature.length);
     for (int i = 0 ; i < signature.length ; i++) {
       encodeByte(signature[i]);
     }
     end(null);
   }
 
-  public void begin(Class<? extends LabCommSample> c) throws IOException {
-    encodePacked32(registry.getTag(c));
+  private void begin(int tag) {
+    current_tag = tag;
+    bytes.reset();
+  }
+
+  public void begin(Class<? extends Sample> c) throws IOException {
+    begin(registry.getTag(c));
   }
 
-  public void end(Class<? extends LabCommSample> c) throws IOException {
+  public void end(Class<? extends Sample> c) throws IOException {
     data.flush();
-    //XXX when writer was a stream, it was probably a bit more GC efficient:
-    //bytes.writeTo(writer);
+    WritePacked32(writer, current_tag);
+    WritePacked32(writer, bytes.size());
     writer.write(bytes.toByteArray());
     bytes.reset();
   }
 
+  private void WritePacked32(Writer s, long value) throws IOException {
+    byte[] tmp1 = new byte[5];
+    byte[] tmp2 = new byte[1];
+    long v = value & 0xffffffff;
+    int i;
+    
+    for (i = 0 ; i == 0 || v != 0 ; i++, v = (v >> 7)) {
+      tmp1[i] = (byte)(v & 0x7f | (i!=0?0x80:0x00));
+    }
+    for (i = i - 1 ; i >= 0 ; i--) {
+      tmp2[0] = tmp1[i];
+      writer.write(tmp2);
+    }      
+  }
+
   public void encodeBoolean(boolean value) throws IOException{
     data.writeBoolean(value);
   }
diff --git a/lib/java/se/lth/control/labcomm/LabCommEncoderRegistry.java b/lib/java/se/lth/control/labcomm/EncoderRegistry.java
similarity index 66%
rename from lib/java/se/lth/control/labcomm/LabCommEncoderRegistry.java
rename to lib/java/se/lth/control/labcomm/EncoderRegistry.java
index a5e848d9de6ac60eadae133f0498fe675b8eb44e..cd0cf72f5f45ed9ccc3cb6ce1902c9c2e37333bf 100644
--- a/lib/java/se/lth/control/labcomm/LabCommEncoderRegistry.java
+++ b/lib/java/se/lth/control/labcomm/EncoderRegistry.java
@@ -3,19 +3,19 @@ package se.lth.control.labcomm;
 import java.io.IOException;
 import java.util.HashMap;
 
-public class LabCommEncoderRegistry {
+public class EncoderRegistry {
 
   public static class Entry {
     
-    private LabCommDispatcher dispatcher;
+    private SampleDispatcher dispatcher;
     private int index;
 
-    public Entry(LabCommDispatcher dispatcher, int index) {
+    public Entry(SampleDispatcher dispatcher, int index) {
       this.dispatcher = dispatcher;
       this.index = index;
     }
 
-    public LabCommDispatcher getDispatcher() {
+    public SampleDispatcher getDispatcher() {
       return dispatcher;
     }
 
@@ -25,14 +25,14 @@ public class LabCommEncoderRegistry {
 
   }
 
-  private int userIndex = LabComm.FIRST_USER_INDEX;
+  private int userIndex = Constant.FIRST_USER_INDEX;
   private HashMap<Class, Entry> byClass;
 
-  public LabCommEncoderRegistry() {
+  public EncoderRegistry() {
     byClass = new HashMap<Class, Entry>();
   }
 
-  public synchronized int add(LabCommDispatcher dispatcher) {
+  public synchronized int add(SampleDispatcher dispatcher) {
     Entry e = byClass.get(dispatcher.getSampleClass());
     if (e == null) {
       e = new Entry(dispatcher, userIndex);
@@ -42,7 +42,7 @@ public class LabCommEncoderRegistry {
     return e.getIndex();
   }
   
-  public int getTag(Class<? extends LabCommSample> sample) throws IOException {
+  public int getTag(Class<? extends Sample> sample) throws IOException {
     Entry e = byClass.get(sample);
     if (e == null) {
       throw new IOException("'" + 
@@ -52,4 +52,4 @@ public class LabCommEncoderRegistry {
     return e.index;
   }
 
-}
\ No newline at end of file
+}
diff --git a/lib/java/se/lth/control/labcomm/LabCommDispatcher.java b/lib/java/se/lth/control/labcomm/LabCommDispatcher.java
deleted file mode 100644
index 86d756c2ab30008c9db1b32c10c8e65df8684dd7..0000000000000000000000000000000000000000
--- a/lib/java/se/lth/control/labcomm/LabCommDispatcher.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package se.lth.control.labcomm;
-
-public interface LabCommDispatcher {
-    
-  public Class getSampleClass();
-    
-  public String getName();
-
-  public byte[] getSignature();
-
-  public void decodeAndHandle(LabCommDecoder decoder,
-			      LabCommHandler handler) throws Exception;
-
-}
-
diff --git a/lib/java/se/lth/control/labcomm/LabCommHandler.java b/lib/java/se/lth/control/labcomm/LabCommHandler.java
deleted file mode 100644
index d30a12f852b5d555924b36d68aea962000bd0e60..0000000000000000000000000000000000000000
--- a/lib/java/se/lth/control/labcomm/LabCommHandler.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package se.lth.control.labcomm;
-
-public interface LabCommHandler {
-}
\ No newline at end of file
diff --git a/lib/java/se/lth/control/labcomm/LabCommReader.java b/lib/java/se/lth/control/labcomm/Reader.java
similarity index 73%
rename from lib/java/se/lth/control/labcomm/LabCommReader.java
rename to lib/java/se/lth/control/labcomm/Reader.java
index 28d7d05c1d9680d172f6821136ead8f1b180fb75..1dd0dacd16ecab62bfb7e1de7ed30d082741c9ec 100644
--- a/lib/java/se/lth/control/labcomm/LabCommReader.java
+++ b/lib/java/se/lth/control/labcomm/Reader.java
@@ -1,6 +1,6 @@
 package se.lth.control.labcomm;
 
-public interface LabCommReader {
+public interface Reader {
 
   public void handle(byte[] data, int begin, int end);
 
diff --git a/lib/java/se/lth/control/labcomm/LabCommType.java b/lib/java/se/lth/control/labcomm/Sample.java
similarity index 53%
rename from lib/java/se/lth/control/labcomm/LabCommType.java
rename to lib/java/se/lth/control/labcomm/Sample.java
index 6cb84f67e0126d25f6ad3d38a76cc85e8b0d863e..8210e3a8efd5a407867a4de73ba27e314c604485 100644
--- a/lib/java/se/lth/control/labcomm/LabCommType.java
+++ b/lib/java/se/lth/control/labcomm/Sample.java
@@ -1,5 +1,5 @@
 package se.lth.control.labcomm;
 
-public interface LabCommType {
+public interface Sample {
 
 }
\ No newline at end of file
diff --git a/lib/java/se/lth/control/labcomm/SampleDispatcher.java b/lib/java/se/lth/control/labcomm/SampleDispatcher.java
new file mode 100644
index 0000000000000000000000000000000000000000..8051296a2104ddf07522d154686221f308934605
--- /dev/null
+++ b/lib/java/se/lth/control/labcomm/SampleDispatcher.java
@@ -0,0 +1,15 @@
+package se.lth.control.labcomm;
+
+public interface SampleDispatcher {
+    
+  public Class getSampleClass();
+    
+  public String getName();
+
+  public byte[] getSignature();
+
+  public void decodeAndHandle(Decoder decoder,
+			      SampleHandler handler) throws Exception;
+
+}
+
diff --git a/lib/java/se/lth/control/labcomm/SampleHandler.java b/lib/java/se/lth/control/labcomm/SampleHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..d03da88d64f8a23e795149bda5b7ed1080dd88e4
--- /dev/null
+++ b/lib/java/se/lth/control/labcomm/SampleHandler.java
@@ -0,0 +1,4 @@
+package se.lth.control.labcomm;
+
+public interface SampleHandler {
+}
diff --git a/lib/java/se/lth/control/labcomm/LabCommSample.java b/lib/java/se/lth/control/labcomm/SampleType.java
similarity index 50%
rename from lib/java/se/lth/control/labcomm/LabCommSample.java
rename to lib/java/se/lth/control/labcomm/SampleType.java
index 8ae824f8c1a94fee397ce6845f949e12da3242b5..f51ce99de5bbf360b8cd319387fd4dcb16b9904a 100644
--- a/lib/java/se/lth/control/labcomm/LabCommSample.java
+++ b/lib/java/se/lth/control/labcomm/SampleType.java
@@ -1,5 +1,5 @@
 package se.lth.control.labcomm;
 
-public interface LabCommSample {
+public interface SampleType {
 
-}
\ No newline at end of file
+}
diff --git a/lib/java/se/lth/control/labcomm/LabCommWriter.java b/lib/java/se/lth/control/labcomm/Writer.java
similarity index 78%
rename from lib/java/se/lth/control/labcomm/LabCommWriter.java
rename to lib/java/se/lth/control/labcomm/Writer.java
index 887c5471842bc8928d89bb469f463f111c835f69..2e015b0f4d94c0c916c76043178a2dda90403d86 100644
--- a/lib/java/se/lth/control/labcomm/LabCommWriter.java
+++ b/lib/java/se/lth/control/labcomm/Writer.java
@@ -2,7 +2,7 @@ package se.lth.control.labcomm;
 
 import java.io.IOException;
 
-public interface LabCommWriter {
+public interface Writer {
 
   public void write(byte[] data) throws IOException;
 
diff --git a/lib/java/se/lth/control/labcomm/WriterWrapper.java b/lib/java/se/lth/control/labcomm/WriterWrapper.java
index 0f7d1922e16cd2ce18cbfc6a8a19b09462679bc4..7c33137e31b309521a7526685dcdc3de6ef04b91 100644
--- a/lib/java/se/lth/control/labcomm/WriterWrapper.java
+++ b/lib/java/se/lth/control/labcomm/WriterWrapper.java
@@ -3,7 +3,7 @@ package se.lth.control.labcomm;
 import java.io.OutputStream;
 import java.io.IOException;
 
-class WriterWrapper implements LabCommWriter{
+class WriterWrapper implements Writer{
 
   private OutputStream os;
 
diff --git a/lib/java/se/lth/control/labcomm2006/LabComm.java b/lib/java/se/lth/control/labcomm2006/Constant.java
similarity index 97%
rename from lib/java/se/lth/control/labcomm2006/LabComm.java
rename to lib/java/se/lth/control/labcomm2006/Constant.java
index b83c391a485f57da9f4354d1bc97485671f2de7c..5c14ae5c81186486c17e7a6e7d9f4c97891a7bfa 100644
--- a/lib/java/se/lth/control/labcomm2006/LabComm.java
+++ b/lib/java/se/lth/control/labcomm2006/Constant.java
@@ -1,6 +1,6 @@
 package se.lth.control.labcomm2006;
 
-public class LabComm {
+public class Constant {
 
   public static final String VERSION = "LabComm2006";
 
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDecoder.java b/lib/java/se/lth/control/labcomm2006/Decoder.java
similarity index 78%
rename from lib/java/se/lth/control/labcomm2006/LabCommDecoder.java
rename to lib/java/se/lth/control/labcomm2006/Decoder.java
index 864e43e68e6b43d7a4b48b8ec2ae598ed2c0c645..0b442cb9026242c6617691f120f839505fde4a53 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommDecoder.java
+++ b/lib/java/se/lth/control/labcomm2006/Decoder.java
@@ -2,10 +2,10 @@ package se.lth.control.labcomm2006;
 
 import java.io.IOException;
 
-public interface LabCommDecoder {
+public interface Decoder {
   
-  public void register(LabCommDispatcher dispatcher, 
-		       LabCommHandler handler) throws IOException;
+  public void register(SampleDispatcher dispatcher, 
+		       SampleHandler handler) throws IOException;
   public boolean decodeBoolean() throws IOException;
   public byte decodeByte() throws IOException;
   public short decodeShort() throws IOException;
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java b/lib/java/se/lth/control/labcomm2006/DecoderChannel.java
similarity index 72%
rename from lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java
rename to lib/java/se/lth/control/labcomm2006/DecoderChannel.java
index d0767b03cc05b93863cc361095410c3d4468a1df..34acf506ffc7e6597a0bb12f1b3bb4c79874d8c4 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java
+++ b/lib/java/se/lth/control/labcomm2006/DecoderChannel.java
@@ -5,14 +5,14 @@ import java.io.DataInputStream;
 import java.io.InputStream;
 import java.io.IOException;
 
-public class LabCommDecoderChannel implements LabCommDecoder {
+public class DecoderChannel implements Decoder {
 
   private DataInputStream in;
-  private LabCommDecoderRegistry registry;
+  private DecoderRegistry registry;
 
-  public LabCommDecoderChannel(InputStream in) throws IOException {
+  public DecoderChannel(InputStream in) throws IOException {
     this.in = new DataInputStream(in);
-    registry = new LabCommDecoderRegistry();
+    registry = new DecoderRegistry();
   }
 
   public void runOne() throws Exception {
@@ -20,24 +20,23 @@ public class LabCommDecoderChannel implements LabCommDecoder {
     while (!done) {
       int tag = decodePacked32();
       switch (tag) {
-	case LabComm.TYPEDEF:
-	case LabComm.SAMPLE: {
+	case Constant.SAMPLE: {
 	  int index = decodePacked32();
 	  String name = decodeString();
 	  ByteArrayOutputStream signature = new ByteArrayOutputStream();
-	  collectFlatSignature(new LabCommEncoderChannel(signature, false));
+	  collectFlatSignature(new EncoderChannel(signature));
 	  registry.add(index, name, signature.toByteArray());
 	} break;
 	default: {
-	  LabCommDecoderRegistry.Entry e = registry.get(tag);
+	  DecoderRegistry.Entry e = registry.get(tag);
 	  if (e == null) {
 	    throw new IOException("Unhandled tag " + tag);
 	  }
-	  LabCommDispatcher d = e.getDispatcher();
+	  SampleDispatcher d = e.getDispatcher();
 	  if (d == null) {
 	    throw new IOException("No dispatcher for '" + e.getName() + "'");
 	  }
-	  LabCommHandler h = e.getHandler();
+	  SampleHandler h = e.getHandler();
 	  if (h == null) {
 	    throw new IOException("No handler for '" + e.getName() +"'");
 	  }
@@ -54,11 +53,11 @@ public class LabCommDecoderChannel implements LabCommDecoder {
     }
   }
 
-  private void collectFlatSignature(LabCommEncoder out) throws IOException {
+  private void collectFlatSignature(Encoder out) throws IOException {
     int type = decodePacked32();
     out.encodePacked32(type);
     switch (type) {
-      case LabComm.ARRAY: {
+      case Constant.ARRAY: {
 	int dimensions = decodePacked32();
 	out.encodePacked32(dimensions);
 	for (int i = 0 ; i < dimensions ; i++) {
@@ -66,7 +65,7 @@ public class LabCommDecoderChannel implements LabCommDecoder {
 	}
 	collectFlatSignature(out);
       } break;
-      case LabComm.STRUCT: {
+      case Constant.STRUCT: {
 	int fields = decodePacked32();
 	out.encodePacked32(fields);
 	for (int i = 0 ; i < fields ; i++) {
@@ -74,14 +73,14 @@ public class LabCommDecoderChannel implements LabCommDecoder {
 	  collectFlatSignature(out);
 	}
       } break;
-      case LabComm.BOOLEAN:
-      case LabComm.BYTE:
-      case LabComm.SHORT:
-      case LabComm.INT:
-      case LabComm.LONG:
-      case LabComm.FLOAT:
-      case LabComm.DOUBLE:
-      case LabComm.STRING: {
+      case Constant.BOOLEAN:
+      case Constant.BYTE:
+      case Constant.SHORT:
+      case Constant.INT:
+      case Constant.LONG:
+      case Constant.FLOAT:
+      case Constant.DOUBLE:
+      case Constant.STRING: {
       } break;
       default: {
 	throw new IOException("Unimplemented type=" + type);
@@ -90,8 +89,8 @@ public class LabCommDecoderChannel implements LabCommDecoder {
     out.end(null);
   }
 
-  public void register(LabCommDispatcher dispatcher, 
-                       LabCommHandler handler) throws IOException {
+  public void register(SampleDispatcher dispatcher, 
+                       SampleHandler handler) throws IOException {
     registry.add(dispatcher, handler);
   }
 
@@ -135,7 +134,7 @@ public class LabCommDecoderChannel implements LabCommDecoder {
   }
 
   /**
-     method for API harmonization with labcomm2013.
+     method for API harmonization with labcomm2014.
      Labcomm2006 encodes lengths etc as 32 bit ints.
   */
   public int decodePacked32() throws IOException {
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDecoderRegistry.java b/lib/java/se/lth/control/labcomm2006/DecoderRegistry.java
similarity index 84%
rename from lib/java/se/lth/control/labcomm2006/LabCommDecoderRegistry.java
rename to lib/java/se/lth/control/labcomm2006/DecoderRegistry.java
index a94bc6e3460b83386a1aafee8b84710c14c57784..8bce34d78b43fd2a8a3b2969debf5394e4c62b43 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommDecoderRegistry.java
+++ b/lib/java/se/lth/control/labcomm2006/DecoderRegistry.java
@@ -3,18 +3,18 @@ package se.lth.control.labcomm2006;
 import java.io.IOException;
 import java.util.HashMap;
 
-public class LabCommDecoderRegistry {
+public class DecoderRegistry {
 
   public static class Entry {
     
-    private LabCommDispatcher dispatcher;
-    private LabCommHandler handler;
+    private SampleDispatcher dispatcher;
+    private SampleHandler handler;
     private int index;
     private String name;
     private byte[] signature;
 
-    public Entry(LabCommDispatcher dispatcher,
-		 LabCommHandler handler) {
+    public Entry(SampleDispatcher dispatcher,
+		 SampleHandler handler) {
       this.dispatcher = dispatcher;
       this.name = dispatcher.getName();
       this.signature = dispatcher.getSignature();
@@ -27,19 +27,19 @@ public class LabCommDecoderRegistry {
       this.signature = signature;
     }
 
-    public LabCommDispatcher getDispatcher() {
+    public SampleDispatcher getDispatcher() {
       return dispatcher;
     }
 
-    public void setDispatcher(LabCommDispatcher dispatcher) {
+    public void setDispatcher(SampleDispatcher dispatcher) {
       this.dispatcher = dispatcher;
     }
 
-    public LabCommHandler getHandler() {
+    public SampleHandler getHandler() {
       return handler;
     }
 
-    public void setHandler(LabCommHandler handler) {
+    public void setHandler(SampleHandler handler) {
       this.handler = handler;
     }
 
@@ -89,13 +89,13 @@ public class LabCommDecoderRegistry {
   private HashMap<Class, Entry> byClass;
   private HashMap<Integer, Entry> byIndex;
 
-  public LabCommDecoderRegistry() {
+  public DecoderRegistry() {
     byClass = new HashMap<Class, Entry>();
     byIndex = new HashMap<Integer, Entry>();
   }
 
-  public synchronized void add(LabCommDispatcher dispatcher,
-			       LabCommHandler handler) throws IOException{
+  public synchronized void add(SampleDispatcher dispatcher,
+			       SampleHandler handler) throws IOException{
     Entry e = byClass.get(dispatcher.getSampleClass());
     if (e != null) {
       e.check(dispatcher.getName(), dispatcher.getSignature());
@@ -141,4 +141,4 @@ public class LabCommDecoderRegistry {
     return byIndex.get(Integer.valueOf(index));
   }
 
-}
\ No newline at end of file
+}
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommEncoder.java b/lib/java/se/lth/control/labcomm2006/Encoder.java
similarity index 71%
rename from lib/java/se/lth/control/labcomm2006/LabCommEncoder.java
rename to lib/java/se/lth/control/labcomm2006/Encoder.java
index 51c2223be4241053086715c8878fe37a8052cf62..eaf54b291b1196d34910690f0d3bc54451f90da6 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommEncoder.java
+++ b/lib/java/se/lth/control/labcomm2006/Encoder.java
@@ -2,11 +2,11 @@ package se.lth.control.labcomm2006;
 
 import java.io.IOException;
 
-public interface LabCommEncoder {
+public interface Encoder {
 
-  public void register(LabCommDispatcher dispatcher) throws IOException;
-  public void begin(Class<? extends LabCommSample> c) throws IOException;
-  public void end(Class<? extends LabCommSample> c) throws IOException;
+  public void register(SampleDispatcher dispatcher) throws IOException;
+  public void begin(Class<? extends Sample> c) throws IOException;
+  public void end(Class<? extends Sample> c) throws IOException;
   public void encodeBoolean(boolean value) throws IOException;
   public void encodeByte(byte value) throws IOException;
   public void encodeShort(short value) throws IOException;
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java b/lib/java/se/lth/control/labcomm2006/EncoderChannel.java
similarity index 63%
rename from lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java
rename to lib/java/se/lth/control/labcomm2006/EncoderChannel.java
index 6cd8804240b57698a23dbc117ded34118dd1dadd..b164754c5e76fbf40e530dcc2e0817b767327776 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java
+++ b/lib/java/se/lth/control/labcomm2006/EncoderChannel.java
@@ -5,40 +5,27 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
-public class LabCommEncoderChannel implements LabCommEncoder {
+public class EncoderChannel implements Encoder {
 
-  private LabCommWriter writer;
+  private Writer writer;
   private ByteArrayOutputStream bytes;
   private DataOutputStream data;
-  private LabCommEncoderRegistry registry;
+  private EncoderRegistry registry;
 
-  public LabCommEncoderChannel(LabCommWriter writer, 
-			       boolean emitVersion) throws IOException {
+  public EncoderChannel(Writer writer) throws IOException {
     this.writer = writer;
     bytes = new ByteArrayOutputStream();
     data = new DataOutputStream(bytes);
-    registry = new LabCommEncoderRegistry();
-    if (emitVersion) {
-        throw new IllegalArgumentException("Labcomm 2006 does not support emitVersion");
-    }
-  }
-
-  public LabCommEncoderChannel(LabCommWriter writer) throws IOException {
-    this(writer, false);
-  }
-
-  public LabCommEncoderChannel(OutputStream writer, 
-			       boolean emitVersion) throws IOException {
-    this(new WriterWrapper(writer), emitVersion);
+    registry = new EncoderRegistry();
   }
 
-  public LabCommEncoderChannel(OutputStream writer) throws IOException {
-    this(new WriterWrapper(writer), false);
+  public EncoderChannel(OutputStream writer) throws IOException {
+    this(new WriterWrapper(writer));
   }
 
-  public void register(LabCommDispatcher dispatcher) throws IOException {
+  public void register(SampleDispatcher dispatcher) throws IOException {
     int index = registry.add(dispatcher);
-    encodePacked32(LabComm.SAMPLE);
+    encodePacked32(Constant.SAMPLE);
     encodePacked32(index);
     encodeString(dispatcher.getName());
     byte[] signature = dispatcher.getSignature();
@@ -48,11 +35,11 @@ public class LabCommEncoderChannel implements LabCommEncoder {
     end(null);
   }
 
-  public void begin(Class<? extends LabCommSample> c) throws IOException {
+  public void begin(Class<? extends Sample> c) throws IOException {
     encodePacked32(registry.getTag(c));
   }
 
-  public void end(Class<? extends LabCommSample> c) throws IOException {
+  public void end(Class<? extends Sample> c) throws IOException {
     data.flush();
     //XXX when writer was a stream, it was probably a bit more GC efficient:
     //bytes.writeTo(writer);
@@ -94,7 +81,7 @@ public class LabCommEncoderChannel implements LabCommEncoder {
   }
 
   /**
-     method for API harmonization with labcomm2013.
+     method for API harmonization with labcomm2014.
      Labcomm2006 encodes lengths etc as 32 bit ints.
   */
   public void encodePacked32(long value) throws IOException {
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommEncoderRegistry.java b/lib/java/se/lth/control/labcomm2006/EncoderRegistry.java
similarity index 66%
rename from lib/java/se/lth/control/labcomm2006/LabCommEncoderRegistry.java
rename to lib/java/se/lth/control/labcomm2006/EncoderRegistry.java
index 2a5564e1d1ae394d26a2d107b7840053ba7b08aa..70f6eb72eedcacf99ec0e9b7e6d743281a3b6aa8 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommEncoderRegistry.java
+++ b/lib/java/se/lth/control/labcomm2006/EncoderRegistry.java
@@ -3,19 +3,19 @@ package se.lth.control.labcomm2006;
 import java.io.IOException;
 import java.util.HashMap;
 
-public class LabCommEncoderRegistry {
+public class EncoderRegistry {
 
   public static class Entry {
     
-    private LabCommDispatcher dispatcher;
+    private SampleDispatcher dispatcher;
     private int index;
 
-    public Entry(LabCommDispatcher dispatcher, int index) {
+    public Entry(SampleDispatcher dispatcher, int index) {
       this.dispatcher = dispatcher;
       this.index = index;
     }
 
-    public LabCommDispatcher getDispatcher() {
+    public SampleDispatcher getDispatcher() {
       return dispatcher;
     }
 
@@ -25,14 +25,14 @@ public class LabCommEncoderRegistry {
 
   }
 
-  private int userIndex = LabComm.FIRST_USER_INDEX;
+  private int userIndex = Constant.FIRST_USER_INDEX;
   private HashMap<Class, Entry> byClass;
 
-  public LabCommEncoderRegistry() {
+  public EncoderRegistry() {
     byClass = new HashMap<Class, Entry>();
   }
 
-  public synchronized int add(LabCommDispatcher dispatcher) {
+  public synchronized int add(SampleDispatcher dispatcher) {
     Entry e = byClass.get(dispatcher.getSampleClass());
     if (e == null) {
       e = new Entry(dispatcher, userIndex);
@@ -42,7 +42,7 @@ public class LabCommEncoderRegistry {
     return e.getIndex();
   }
   
-  public int getTag(Class<? extends LabCommSample> sample) throws IOException {
+  public int getTag(Class<? extends Sample> sample) throws IOException {
     Entry e = byClass.get(sample);
     if (e == null) {
       throw new IOException("'" + 
@@ -52,4 +52,4 @@ public class LabCommEncoderRegistry {
     return e.index;
   }
 
-}
\ No newline at end of file
+}
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommReader.java b/lib/java/se/lth/control/labcomm2006/Reader.java
similarity index 74%
rename from lib/java/se/lth/control/labcomm2006/LabCommReader.java
rename to lib/java/se/lth/control/labcomm2006/Reader.java
index 1c2561d048795d819974adc7c4ed9d1a30acbe22..62cdacfc94db0da24393036529b43c56b1d8c82c 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommReader.java
+++ b/lib/java/se/lth/control/labcomm2006/Reader.java
@@ -1,6 +1,6 @@
 package se.lth.control.labcomm2006;
 
-public interface LabCommReader {
+public interface Reader {
 
   public void handle(byte[] data, int begin, int end);
 
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommType.java b/lib/java/se/lth/control/labcomm2006/Sample.java
similarity index 55%
rename from lib/java/se/lth/control/labcomm2006/LabCommType.java
rename to lib/java/se/lth/control/labcomm2006/Sample.java
index 0722e6d2492dbf384712245c6f26f27d61af47b3..a20b06ad0803fadcc6f0ad74ae01732063f5f33d 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommType.java
+++ b/lib/java/se/lth/control/labcomm2006/Sample.java
@@ -1,5 +1,5 @@
 package se.lth.control.labcomm2006;
 
-public interface LabCommType {
+public interface Sample {
 
 }
\ No newline at end of file
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDispatcher.java b/lib/java/se/lth/control/labcomm2006/SampleDispatcher.java
similarity index 50%
rename from lib/java/se/lth/control/labcomm2006/LabCommDispatcher.java
rename to lib/java/se/lth/control/labcomm2006/SampleDispatcher.java
index 469627e5d73d52a3b3b3c8be10ddf5f7d5d98d15..f3acd50aff28b63e526ad090b81994c21491713f 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommDispatcher.java
+++ b/lib/java/se/lth/control/labcomm2006/SampleDispatcher.java
@@ -1,6 +1,6 @@
 package se.lth.control.labcomm2006;
 
-public interface LabCommDispatcher {
+public interface SampleDispatcher {
     
   public Class getSampleClass();
     
@@ -8,8 +8,8 @@ public interface LabCommDispatcher {
 
   public byte[] getSignature();
 
-  public void decodeAndHandle(LabCommDecoder decoder,
-			      LabCommHandler handler) throws Exception;
+  public void decodeAndHandle(Decoder decoder,
+			      SampleHandler handler) throws Exception;
 
 }
 
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommHandler.java b/lib/java/se/lth/control/labcomm2006/SampleHandler.java
similarity index 51%
rename from lib/java/se/lth/control/labcomm2006/LabCommHandler.java
rename to lib/java/se/lth/control/labcomm2006/SampleHandler.java
index 2880c19f7beea0914f0e39747644dff3356f7d09..046e3b4a21cf96871cd49b445ff9732bfd947ebd 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommHandler.java
+++ b/lib/java/se/lth/control/labcomm2006/SampleHandler.java
@@ -1,4 +1,4 @@
 package se.lth.control.labcomm2006;
 
-public interface LabCommHandler {
-}
\ No newline at end of file
+public interface SampleHandler {
+}
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommSample.java b/lib/java/se/lth/control/labcomm2006/SampleType.java
similarity index 52%
rename from lib/java/se/lth/control/labcomm2006/LabCommSample.java
rename to lib/java/se/lth/control/labcomm2006/SampleType.java
index d1dc1fff83d2343775c36e1c9dcb9e5b012ec728..932d0d91fd489616395e8314747f3d53c1d7e1f7 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommSample.java
+++ b/lib/java/se/lth/control/labcomm2006/SampleType.java
@@ -1,5 +1,5 @@
 package se.lth.control.labcomm2006;
 
-public interface LabCommSample {
+public interface SampleType {
 
-}
\ No newline at end of file
+}
diff --git a/lib/java/se/lth/control/labcomm2006/LabCommWriter.java b/lib/java/se/lth/control/labcomm2006/Writer.java
similarity index 78%
rename from lib/java/se/lth/control/labcomm2006/LabCommWriter.java
rename to lib/java/se/lth/control/labcomm2006/Writer.java
index e70e14280382596245c6b557c149ab698231cffa..e02b77d3412ff9f8692161e8e7b6b653f71c3605 100644
--- a/lib/java/se/lth/control/labcomm2006/LabCommWriter.java
+++ b/lib/java/se/lth/control/labcomm2006/Writer.java
@@ -2,7 +2,7 @@ package se.lth.control.labcomm2006;
 
 import java.io.IOException;
 
-public interface LabCommWriter {
+public interface Writer {
 
   public void write(byte[] data) throws IOException;
 
diff --git a/lib/java/se/lth/control/labcomm2006/WriterWrapper.java b/lib/java/se/lth/control/labcomm2006/WriterWrapper.java
index 4c96d88d81f2783080119ecd06f5deb451bc9341..b25c0d835c343ff9a3a12ca61a5ba22932fbe54f 100644
--- a/lib/java/se/lth/control/labcomm2006/WriterWrapper.java
+++ b/lib/java/se/lth/control/labcomm2006/WriterWrapper.java
@@ -3,7 +3,7 @@ package se.lth.control.labcomm2006;
 import java.io.OutputStream;
 import java.io.IOException;
 
-class WriterWrapper implements LabCommWriter{
+class WriterWrapper implements Writer{
 
   private OutputStream os;
 
diff --git a/lib/python/Makefile b/lib/python/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..7798ea9c77f5297ce46b92db52dce08cb5022453
--- /dev/null
+++ b/lib/python/Makefile
@@ -0,0 +1,5 @@
+clean:
+	find . -name '*.pyc' -exec rm {} \;
+
+distclean:
+	find . -name '*.pyc' -exec rm {} \;
diff --git a/lib/python/labcomm/LabComm.py b/lib/python/labcomm/LabComm.py
index ad9957982bcd37558660674abe67088a920baeea..9f854ec79eda69c8ce72382a0f5ccca5ffab2e5e 100644
--- a/lib/python/labcomm/LabComm.py
+++ b/lib/python/labcomm/LabComm.py
@@ -1,32 +1,56 @@
 #!/usr/bin/python
 #
-# All packets follows the following layout
+# LabComm2014 packet has the following layout
 #
 #   +----+----+----+----+
-#   | id              |
+#   | id                    (packed32)
+#   +----+----+----+----+
+#   | length                (packed32)
 #   +----+----+----+----+
 #   | data
 #   | ...
 #   +----+--
 #
-# Data layouts for packets
-#
-# TYPEDEF:
+# LabComm22014 SAMPLE:
 #
 #   +----+----+----+----+
-#   | id = 0x00000001   |
+#   | id = 0x02             (packed32)
 #   +----+----+----+----+
-#   | type number       |
+#   | length                (packed32)
+#   +----+----+----+----+
+#   | type number           (packed32)
 #   +----+----+----+----+
 #   | type name (UTF8)
 #   | ...
 #   +----+----+----+----+
-#   | type
+#   | signature length      (packed32)
+#   +----+----+----+----+
+#   | type signature
 #   | ...
 #   +----+--
 #
+# LabComm2014 User data:
 #
-# SAMPLE:
+#   +----+----+----+----+
+#   | id >= 0x00000040      (packed32)
+#   +----+----+----+----+
+#   | length                (packed32)
+#   +----+----+----+----+
+#   | user data
+#   | ...
+#   +----+--
+#   
+#
+# LabComm2006 packets has the following layout
+#
+#   +----+----+----+----+
+#   | id                |
+#   +----+----+----+----+
+#   | data
+#   | ...
+#   +----+--
+#
+# LabComm2006 SAMPLE:
 #
 #   +----+----+----+----+
 #   | id = 0x00000002   |
@@ -36,15 +60,15 @@
 #   | type name (UTF8)
 #   | ...
 #   +----+----+----+----+
-#   | type
+#   | type signature
 #   | ...
 #   +----+--
 #
 #
-# User data:
+# LabComm2006 User data:
 #
 #   +----+----+----+----+
-#   | id >= 0x00000060  |
+#   | id >= 0x00000040  |
 #   +----+----+----+----+
 #   | user data
 #   | ...
@@ -96,18 +120,15 @@
 import types
 import struct as packer
 
-#VERSION = "LabComm2013"
-
-# Version testing
-def sendVersionString(version):
-  return version == "LabComm2013" 
-
-def usePacked32(version):
-  return version == "LabComm2013"
+DEFAULT_VERSION = "LabComm2014"
 
-i_TYPEDEF = 0x01
+# Allowed packet tags
+i_VERSION = 0x01
 i_SAMPLE  = 0x02
+i_PRAGMA  = 0x3f
+i_USER    = 0x40 # ..0xffffffff
 
+# Predefined types
 i_ARRAY   = 0x10
 i_STRUCT  = 0x11
 
@@ -120,7 +141,27 @@ i_FLOAT   = 0x25
 i_DOUBLE  = 0x26
 i_STRING  = 0x27
 
-i_USER    = 0x40
+
+# Version testing
+def usePacketLength(version):
+    return version in [ None, "LabComm2014" ]
+
+class length_encoder:
+    def __init__(self, encoder):
+        self.encoder = encoder
+        self.version = encoder.version
+        self.data = ""
+
+    def write(self, data):
+        self.data += data
+
+    def __enter__(self):
+        return Encoder(self, None)
+
+    def __exit__(self, type, value, traceback):
+        if usePacketLength(self.version):
+             self.encoder.encode_packed32(len(self.data))
+        self.encoder.pack("%ds" % len(self.data), self.data)
 
 def indent(i, s):
     return ("\n%s" % (" " * i)).join(s.split("\n"))
@@ -263,15 +304,18 @@ class STRING(primitive):
 #
 # Aggregate types
 #
-class sample_or_typedef(object):
+class sample(object):
     def __init__(self, name, decl):
         self.name = name
         self.decl = decl
 
-    def encode_decl_tail(self, encoder):
-        encoder.encode_type_number(self)
-        encoder.encode_string(self.name)
-        encoder.encode_type_number(self.decl)
+    def encode_decl(self, encoder):
+        encoder.encode_type(i_SAMPLE)
+        with length_encoder(encoder) as e1:
+            e1.encode_type(encoder.decl_to_index[self])
+            e1.encode_string(self.name)
+            with length_encoder(e1) as e2:
+                self.decl.encode_decl(e2)
 
     def encode(self, encoder, object):
         self.decl.encode(encoder, object)
@@ -279,6 +323,8 @@ class sample_or_typedef(object):
     def decode_decl(self, decoder):
         index = decoder.decode_type_number()
         name = decoder.decode_string()
+        if usePacketLength(decoder.version):
+            length = decoder.decode_packed32()
         decl = decoder.decode_decl()
         result = self.__class__.__new__(self.__class__)
         result.__init__(name, decl)
@@ -294,24 +340,9 @@ class sample_or_typedef(object):
         return self.decl.new_instance()
 
     def __repr__(self):
-        return "'%s', %s" % (self.name, self.decl)
-
-class sample(sample_or_typedef):
-    def encode_decl(self, encoder):
-        encoder.encode_type(i_SAMPLE)
-        self.encode_decl_tail(encoder)
+        return "sample('%s', %s)" % (self.name, self.decl)
 
-    def __repr__(self):
-        return "labcomm.sample(%s)" % super(sample, self).__repr__()
-        
-class typedef(sample_or_typedef):
-    def encode_decl(self, encoder):
-        encoder.encode_type(i_TYPEDEF)
-        self.encode_decl_tail(encoder)
 
-    def __repr__(self):
-        return "labcomm.typedef(%s)" % super(typedef, self).__repr__()
-        
 class array(object):
     def __init__(self, indices, decl):
         self.indices = indices
@@ -482,7 +513,6 @@ class struct:
         return result
 
 SAMPLE = sample(None, None)
-TYPEDEF = typedef(None, None)
 
 ARRAY = array(None, None)
 STRUCT = struct({})
@@ -511,7 +541,6 @@ class Codec(object):
         self.predefined_types()
 
     def predefined_types(self):
-        self.add_decl(TYPEDEF, i_TYPEDEF)
         self.add_decl(SAMPLE, i_SAMPLE)
 
         self.add_decl(ARRAY, i_ARRAY)
@@ -553,11 +582,18 @@ class Codec(object):
         
 
 class Encoder(Codec):
-    def __init__(self, writer, version="LabComm2013"):
+    def __init__(self, writer, version=DEFAULT_VERSION):
         super(Encoder, self).__init__()
         self.writer = writer
         self.version = version
-        self.writer.start(self, self.version)
+        if self.version in [ "LabComm2014" ]:
+            self.encode_type(i_VERSION)
+            with length_encoder(self) as e:
+                e.encode_string(version)
+        elif self.version in [ None,  "LabComm2006" ]:
+            pass
+        else:
+            raise Exception("Unsupported labcomm version %s" % self.version)    
 
     def pack(self, format, *args):
         self.writer.write(packer.pack(format, *args))
@@ -573,7 +609,9 @@ class Encoder(Codec):
             name = self.type_to_name[object.__class__]
             decl = self.name_to_decl[name]
         self.encode_type_number(decl)
-        decl.encode(self, object)
+        with length_encoder(self) as e:
+            decl.encode(e, object)
+#        decl.encode(self, object)
         self.writer.mark()
 
     def encode_type_number(self, decl):
@@ -583,8 +621,7 @@ class Encoder(Codec):
             decl.encode_decl(self)
             
     def encode_packed32(self, v):
-        #if usePacked32(self.version) :
-        if self.version == "LabComm2013" :
+        if self.version in [ None, "LabComm2014" ]:
             v = v & 0xffffffff
             tmp = [ v & 0x7f ]
             v = v >> 7
@@ -634,11 +671,10 @@ class Encoder(Codec):
 #        self.pack("!i%ds" % len(s), len(s), s)
 
 class Decoder(Codec):
-    def __init__(self, reader, version="LabComm2013"):
+    def __init__(self, reader, version=DEFAULT_VERSION):
         super(Decoder, self).__init__()
         self.reader = reader
         self.version = version
-        self.reader.start(self, version)
         
     def unpack(self, format):
         size = packer.calcsize(format)
@@ -653,15 +689,27 @@ class Decoder(Codec):
         result = self.index_to_decl[index]
         if index < i_USER:
             result = result.decode_decl(self)
+        else:
+            raise Exception('Should not be used')
         return result
 
     def decode(self):
-        value = None
-        index = self.decode_type_number()
-        decl = self.index_to_decl[index]
-        if index == i_TYPEDEF or index == i_SAMPLE:
-            decl = decl.decode_decl(self)
+        while True:
+            index = self.decode_type_number()
+            if usePacketLength(self.version):
+                length = self.decode_packed32()
+            if index != i_VERSION:
+                break
+            else:
+                other_version = self.decode_string()  
+                if self.version != other_version:
+                    raise Exception("LabComm version mismatch %s != %s" %
+                                    (version, other_version))
+        if index == i_SAMPLE:
+            decl = self.index_to_decl[index].decode_decl(self)
+            value = None
         else:
+            decl = self.index_to_decl[index]
             value = decl.decode(self)
         self.reader.mark(value, decl)
         return (value, decl)
@@ -680,7 +728,7 @@ class Decoder(Codec):
         return result
     
     def decode_packed32(self):
-        if self.version == "LabComm2013" :
+        if self.version in [ "LabComm2013", "LabComm2014" ] :
             result = 0
             while True:
                 tmp = self.decode_byte()
diff --git a/lib/python/labcomm/StreamReader.py b/lib/python/labcomm/StreamReader.py
index b20983ad214f8005b0a995ddff1dce112b13870d..87e9a5945fffde9409ad890e4c9194442cb65f75 100644
--- a/lib/python/labcomm/StreamReader.py
+++ b/lib/python/labcomm/StreamReader.py
@@ -6,16 +6,6 @@ class StreamReader:
         self.stream = stream
         pass
 
-    def start(self, decoder, version):
-        self.version = version;
-        if labcomm.LabComm.sendVersionString(version):
-          other_version = decoder.decode_string()
-          if version != other_version:
-              raise Exception("LabComm version mismatch %s != %s" %
-                              (version, other_version))
-          pass
-        pass
-
     def read(self, count):
         result = self.stream.read(count)
         if len(result) == 0:
diff --git a/lib/python/labcomm/StreamWriter.py b/lib/python/labcomm/StreamWriter.py
index 759f56e8d9d7fb059da316329b54e3d0574ee349..a85c43d96b9d98de72f4a112720d5e23791df076 100644
--- a/lib/python/labcomm/StreamWriter.py
+++ b/lib/python/labcomm/StreamWriter.py
@@ -6,13 +6,6 @@ class StreamWriter:
         self.stream = stream
         pass
             
-    def start(self, encoder, version):
-        self.version = version;
-
-        if labcomm.LabComm.sendVersionString(version):
-          encoder.encode_string(version)
-          pass
-    
     def write(self, data):
         self.stream.write(data)
         pass
diff --git a/lib/python/labcomm/__init__.py b/lib/python/labcomm/__init__.py
index 52a5911bb58c90786bdf95d8f8cb27837e350407..9eee0b78b8797dcfb92e1d151cd39a0cb327c100 100644
--- a/lib/python/labcomm/__init__.py
+++ b/lib/python/labcomm/__init__.py
@@ -7,7 +7,6 @@ Decoder = labcomm.LabComm.Decoder
 Encoder = labcomm.LabComm.Encoder
 
 sample = labcomm.LabComm.sample
-typedef = labcomm.LabComm.typedef
 
 array = labcomm.LabComm.array
 struct = labcomm.LabComm.struct
diff --git a/test/relay_gen_cs.py b/test/relay_gen_cs.py
index 68fdc4de6db96a45ae1d75fc263fd3ebc498aafe..669f5f5b131a01b2161a77d6f04a3f102bb83f56 100755
--- a/test/relay_gen_cs.py
+++ b/test/relay_gen_cs.py
@@ -35,7 +35,7 @@ if __name__ == '__main__':
     result.append('  %s.Handler' % sample[-1][0])
     result.extend(split_match('^[^|]*\|(.*)$', """
       |{
-      |  LabCommEncoderChannel encoder;
+      |  EncoderChannel encoder;
     """))
     for func,arg in sample:
         if arg == 'void':
@@ -58,11 +58,11 @@ if __name__ == '__main__':
       |    FileStream InFile = new FileStream(InName,
       |                                       FileMode.Open,
       |                                       FileAccess.Read);
-      |    LabCommDecoderChannel d = new LabCommDecoderChannel(InFile);
+      |    DecoderChannel d = new DecoderChannel(InFile);
       |    FileStream OutFile = new FileStream(OutName,
       |                                        FileMode.OpenOrCreate,
       |                                        FileAccess.Write);
-      |    encoder = new LabCommEncoderChannel(OutFile);
+      |    encoder = new EncoderChannel(OutFile);
       |
     """))
     for func,arg in sample:
diff --git a/test/relay_gen_java.py b/test/relay_gen_java.py
index 93644bc2ed679087264766594acece7467f04eaf..40f584efa217f4903c7800b57396b5a6ad519632 100755
--- a/test/relay_gen_java.py
+++ b/test/relay_gen_java.py
@@ -26,8 +26,8 @@ if __name__ == '__main__':
       |import java.io.FileInputStream;
       |import java.io.FileOutputStream;
       |import java.io.IOException;
-      |import se.lth.control.labcomm.LabCommDecoderChannel;
-      |import se.lth.control.labcomm.LabCommEncoderChannel;
+      |import se.lth.control.labcomm.DecoderChannel;
+      |import se.lth.control.labcomm.EncoderChannel;
       |
       |public class java_relay implements
     """))
@@ -37,7 +37,7 @@ if __name__ == '__main__':
     result.append('  %s.Handler' % sample[-1][0])
     result.extend(split_match('^[^|]*\|(.*)$', """
       |{
-      |  LabCommEncoderChannel encoder;
+      |  EncoderChannel encoder;
     """))
     for func,arg in sample:
         if arg == 'void':
@@ -58,9 +58,9 @@ if __name__ == '__main__':
     result.extend(split_match('^[^|]*\|(.*)$', """
       |  public java_relay(String InName, String OutName) throws Exception {
       |    FileInputStream InFile = new FileInputStream(InName);
-      |    LabCommDecoderChannel d = new LabCommDecoderChannel(InFile);
+      |    DecoderChannel d = new DecoderChannel(InFile);
       |    FileOutputStream OutFile = new FileOutputStream(OutName);
-      |    encoder = new LabCommEncoderChannel(OutFile);
+      |    encoder = new EncoderChannel(OutFile);
       |
     """))
     for func,arg in sample:
diff --git a/test/test_encoder_decoder.py b/test/test_encoder_decoder.py
index 3818ab45a990ae13b34b119d153b114fca3c083a..f845bd69df1a6d3ae0c12168e781be900d491e9c 100755
--- a/test/test_encoder_decoder.py
+++ b/test/test_encoder_decoder.py
@@ -81,7 +81,7 @@ def generate(decl):
     elif decl.__class__ == labcomm.STRING:
         return ['string', u'sträng' ]
 
-    print decl
+    print>>sys.stderr, decl
     raise Exception("unhandled decl %s" % decl.__class__)
 
 def labcomm_compile(lc, name, args):
@@ -118,7 +118,7 @@ class Test:
         pass
 
     def run(self):
-        print 'Testing', self.program
+        print>>sys.stderr, 'Testing', self.program
         p = subprocess.Popen(self.program, 
                              stdin=subprocess.PIPE,
                              stdout=subprocess.PIPE)
@@ -132,8 +132,7 @@ class Test:
             encoder.add_decl(signature)
             pass
         for name,signature in self.signatures:
-            print "Checking", name,
-            sys.stdout.flush()
+            print>>sys.stderr, "Checking", name,
             for decl,value in generate(signature):
                 sys.stdout.write('.')
                 #print name,decl,value,value.__class__
@@ -144,7 +143,7 @@ class Test:
                     p.terminate()
                     exit(1)
                 pass
-            print
+            print>>sys.stderr
             pass
         p.stdin.close()
         if p.wait() != 0:
@@ -159,7 +158,7 @@ class Test:
                 value,decl = decoder.decode()
                 if value != None:
                     if value != self.expected:
-                        print "Coding error", value, self.expected, decl
+                        print>>sys.stderr, "Coding error", value, self.expected, decl
                         self.failed = True
                     self.next.release()
                 pass