{0x53, "applytype", "n",       -1, 1, 0, OP_STACK_ARGS},
 
 /* dummy instructions. Warning: these are not actually supported by flash */
+{0xfc, "__rethrow__", "",           0, 0, 0, OP_THROW|OP_INTERNAL},
 {0xfd, "__fallthrough__", "s",           0, 0, 0, OP_INTERNAL},
 {0xfe, "__continue__", "s",           0, 0, 0, OP_RETURN|OP_INTERNAL},
 {0xff, "__break__", "s",            0, 0, 0, OP_RETURN|OP_INTERNAL},
     free(codelookup);
 }
 
-code_t*code_find_start(code_t*c)
-{
-    while(c && c->prev) 
-        c=c->prev;
-    return c;
-}
-
 void code_free(code_t*c)
 {
-    c = code_find_start(c);
+    c = code_start(c);
     while(c) {
         code_t*next = c->next;
         opcode_t*op = opcode_get(c->opcode);
 
 void code_write(TAG*tag, code_t*code, pool_t*pool, abc_file_t*file)
 {
-    code = code_find_start(code);
+    code = code_start(code);
     int pos = 0;
     int length = 0;
     code_t*c = code;
 
 static currentstats_t* code_get_stats(code_t*code, abc_exception_list_t*exceptions) 
 {
-    code = code_find_start(code);
+    code = code_start(code);
     int num = 0;
     code_t*c = code;
     while(c) {
     }
 }
 
-int code_dump(code_t*c, abc_exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo)
+int code_dump(code_t*c)
+{
+    return code_dump2(c, 0, 0, "", stdout);
+}
+int code_dump2(code_t*c, abc_exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo)
 {
     abc_exception_list_t*e = exceptions;
-    c = code_find_start(c);
+    c = code_start(c);
     currentstats_t*stats =  code_get_stats(c, exceptions);
 
     int pos = 0;
                     int n = (ptroff_t)data;
                     fprintf(fo, "r%d", n);
                 } else if(*p == 'b') {
-                    int b = (ptroff_t)data;
-                    fprintf(fo, "%02x", b);
+                    int b = (signed char)(ptroff_t)data;
+                    fprintf(fo, "%d", b);
                 } else if(*p == 'j') {
                     if(c->branch)
                         fprintf(fo, "->%d", c->branch->pos);
                     if(l->def)
                         fprintf(fo, "default->%d", l->def->pos);
                     else
-                        fprintf(fo, "default->00000000", l->def->pos);
+                        fprintf(fo, "default->00000000");
                     code_list_t*t = l->targets;
                     while(t) {
                         if(t->code)
 {
     code_t*tmp = (code_t*)rfx_calloc(sizeof(code_t));
     tmp->opcode = op;
-    tmp->next = 0;
     if(atag) {
        tmp->prev = atag;
         tmp->next = atag->next;
+        if(tmp->next)
+            tmp->next->prev = tmp;
        atag->next = tmp;
     } else {
        tmp->prev = 0;
+        tmp->next = 0;
     }
     return tmp;
 }
         memcpy(n, c, sizeof(code_t));
 
         opcode_t*op = opcode_get(c->opcode);
-        if(c->branch) {
+        if(c->branch || c->opcode == OPCODE_LABEL) {
             fprintf(stderr, "Error: Can't duplicate branching code\n");
             return 0;
         }
 
 code_t* cut_last_push(code_t*c)
 {
+    assert(!c->next);
     while(c) {
         if(!c) break;
         opcode_t*op = opcode_get(c->opcode);
 
 code_t*add_opcode(code_t*atag, U8 op);
 
 code_t*code_parse(TAG*tag, int len, abc_file_t*file, pool_t*pool, codelookup_t**codelookup);
-int        code_dump(code_t*c, abc_exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo);
+int        code_dump(code_t*c);
+int        code_dump2(code_t*c, abc_exception_list_t*exceptions, abc_file_t*file, char*prefix, FILE*fo);
 void       code_write(TAG*tag, code_t*code, pool_t*pool, abc_file_t*file);
 void       code_free(code_t*c);
 code_t* code_atposition(codelookup_t*l, int pos);