diff --git a/Makefile b/Makefile
index f3ada298d04312c786d7e61a78fe18c9bb3adfe1..b0da325f95817792e5da25584c14c9ddf19f795d 100644
--- a/Makefile
+++ b/Makefile
@@ -28,19 +28,19 @@ TAR_RELEASE = $(RELEASE)
 ACGtk_DIR = $(shell basename `pwd`)
 
 clean:
-	jbuilder clean
+	dune clean
 	find . -name "*~" -exec rm -f {} \;
 
 set_log_level:
-#	find . -name "jbuild" -exec sed -i -e 's/-level \([^ ]*\)/-level TRACE/' {} \;
-	find . -name "jbuild" -exec sed -i -e 's/-level \([^ ]*\)/-level NONE/' {} \;
+#	find . -name "dune" -exec sed -i -e 's/-level \([^ ]*\)/-level TRACE/' {} \;
+	find . -name "dune" -exec sed -i -e 's/-level \([^ ]*\)/-level NONE/' {} \;
 
 
 install:
-	jbuilder install
+	dune install
 
 uninstall:
-	jbuilder uninstall
+	dune uninstall
 
 tar:
 	if test -d ../$(TAR_RELEASE) ; then rm ../$(TAR_RELEASE) ; fi
diff --git a/acgtk.opam b/acgtk.opam
deleted file mode 100644
index 59e1bd7fbb171df2735f4756c9459d7aa875cb19..0000000000000000000000000000000000000000
--- a/acgtk.opam
+++ /dev/null
@@ -1,33 +0,0 @@
-opam-version: "1.2"
-maintainer: "sylvain.pogodalla@inria.fr"
-
-build: [
-  ["jbuilder" "subst"] {pinned}
-# remove the -p to also build the local libraries: conflict with the
-# fact that some libraries are also part of the acgtkLib package
-#  ["jbuilder" "build" "-p" name "-j" jobs]
-  ["jbuilder" "build" "-j" jobs]
-]
-
-install: ["jbuilder" "install"]
-
-depends: [
-  "jbuilder" {build}
-  "dypgen"
-  "camlp4"
-  "bolt"
-  "ANSITerminal"
-  "cairo2"
-  "yojson"
-  "easy-format"
-  "ocf"
-]
-
-available: [ ocaml-version >= "4.03.0" ]
-
-dev-repo: "https://gitlab.inria.fr/ACG/dev/ACGtk.git"
-
-homepage: "http://acg.gforge.inria.fr/"
-license: "CeCILL"
-authors: ["Sylvain Pogodalla"]
-bug-reports: "sylvain.pogodalla@inria.fr"
diff --git a/acgtk.opam b/acgtk.opam
new file mode 120000
index 0000000000000000000000000000000000000000..4e0c64579395e6a4df325814a111f17c848d4312
--- /dev/null
+++ b/acgtk.opam
@@ -0,0 +1 @@
+opam-package/opam
\ No newline at end of file
diff --git a/acgtkLib.install b/acgtkLib.install
index ace11d51ce674505ba4c534352ce9b0bba436d13..973bfc5f9b36a6cb9a66eae9d34cbd0e538c5b3a 100644
--- a/acgtkLib.install
+++ b/acgtkLib.install
@@ -192,7 +192,6 @@ lib: [
 ]
 doc: [
   "_build/install/default/doc/acgtkLib/README.md"
-  "_build/install/default/doc/acgtkLib/README.html~"
   "_build/install/default/doc/acgtkLib/README-opam"
   "_build/install/default/doc/acgtkLib/README"
   "_build/install/default/doc/acgtkLib/LICENSE.md"
diff --git a/acgtkLib.opam b/acgtkLib.opam
index 4585ce6691c9a2b93d24f8a86919fd277c21dbd5..7902b35a0a6a29ea51a2dcd2c4135b544ddef153 100644
--- a/acgtkLib.opam
+++ b/acgtkLib.opam
@@ -2,12 +2,12 @@ opam-version: "1.2"
 maintainer: "sylvain.pogodalla@inria.fr"
 
 build: [
-  ["jbuilder" "subst"] {pinned}
-  ["jbuilder" "build" "-p" name "-j" jobs]
+  ["dune" "subst"] {pinned}
+  ["dune" "build" "-p" name "-j" jobs]
 ]
 
 depends: [
-  "jbuilder" {build}
+  "dune" {build}
   "dypgen"
   "camlp4"
   "bolt"
diff --git a/dune b/dune
new file mode 100644
index 0000000000000000000000000000000000000000..4fb86b6e6187bc6eed05354b0e09c30b97a94d33
--- /dev/null
+++ b/dune
@@ -0,0 +1,8 @@
+;; -*-lisp-*-
+
+(env
+ (release
+  (flags (:standard -w -58)))
+ (dev
+  (flags (:standard -w +42))))
+
diff --git a/dune-project b/dune-project
new file mode 100644
index 0000000000000000000000000000000000000000..b2559fa05819224b68defff22b919d0e146cc811
--- /dev/null
+++ b/dune-project
@@ -0,0 +1 @@
+(lang dune 1.0)
\ No newline at end of file
diff --git a/dune-workspace b/dune-workspace
new file mode 100644
index 0000000000000000000000000000000000000000..0cdaf265d03916906f87376f88aa2c5b0e0f8ba9
--- /dev/null
+++ b/dune-workspace
@@ -0,0 +1,3 @@
+(lang dune 1.0)
+
+(profile release)
\ No newline at end of file
diff --git a/emacs/dune b/emacs/dune
new file mode 100644
index 0000000000000000000000000000000000000000..a232f32f20bc45b8b920fb7f79b43f1c1871d8e6
--- /dev/null
+++ b/emacs/dune
@@ -0,0 +1,8 @@
+;; -*-lisp-*-
+
+(install
+ (package acgtk)
+ (section share_root)
+ (files (acg.el as emacs/site-lisp/acg.el))
+ )
+
diff --git a/emacs/jbuild b/emacs/jbuild
deleted file mode 100644
index 1b52927ad54b2170c4359d527d5a3b3b1e547fa8..0000000000000000000000000000000000000000
--- a/emacs/jbuild
+++ /dev/null
@@ -1,10 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-(install
- (
-  (package acgtk)
-  (section share_root)
-  (files ((acg.el as emacs/site-lisp/acg.el)))))
-
diff --git a/examples/dune b/examples/dune
new file mode 100644
index 0000000000000000000000000000000000000000..a9c621b09e5da172c42d946bef60c51f7336fbf2
--- /dev/null
+++ b/examples/dune
@@ -0,0 +1,25 @@
+;; -*-lisp-*-
+
+(install
+  (package acgtk)
+  (section share)
+  (files 
+   (anbncndn.acg as examples/anbncndn.acg)
+   (cfg.acg as examples/cfg.acg)
+   (config.json as examples/config.json)
+   (demo-script as examples/demo-script)
+   (Jean-regarde-telescope.acg as examples/Jean-regarde-telescope.acg)
+   (MK-lecture-example.acg as examples/MK-lecture-example.acg)
+   (montague.acg as examples/montague.acg)
+   (montague-fr.acg as examples/montague-fr.acg)
+   (montague-script as examples/montague-script)
+   (README as examples/README)
+   (README.md as examples/README.md)
+   (strings.acg as examples/strings.acg)
+   (tag.acg as examples/tag.acg)
+   (tag-fr.acg as examples/tag-fr.acg)
+   (tag-script as examples/tag-script)
+   ))
+
+
+
diff --git a/examples/jbuild b/examples/jbuild
deleted file mode 100644
index 0227b03b5063ce5e78bdc7f5bfbe5aa363bb0700..0000000000000000000000000000000000000000
--- a/examples/jbuild
+++ /dev/null
@@ -1,28 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-(install
- (
-  (package acgtk)
-  (section share)
-  (files (
-	  (anbncndn.acg as examples/anbncndn.acg)
-	  (cfg.acg as examples/cfg.acg)
-	  (config.json as examples/config.json)
-	  (demo-script as examples/demo-script)
-	  (Jean-regarde-telescope.acg as examples/Jean-regarde-telescope.acg)
-	  (MK-lecture-example.acg as examples/MK-lecture-example.acg)
-	  (montague.acg as examples/montague.acg)
-	  (montague-fr.acg as examples/montague-fr.acg)
-	  (montague-script as examples/montague-script)
-	  (README as examples/README)
-	  (README.md as examples/README.md)
-	  (strings.acg as examples/strings.acg)
-	  (tag.acg as examples/tag.acg)
-	  (tag-fr.acg as examples/tag-fr.acg)
-	  (tag-script as examples/tag-script)
-	  ))))
-
-
-
diff --git a/jbuild b/jbuild
deleted file mode 100644
index b40509e1dbdeb926b3adf39e009aa6052c7b80a9..0000000000000000000000000000000000000000
--- a/jbuild
+++ /dev/null
@@ -1,6 +0,0 @@
-#|(env
- (dev
-  (flags (:standard -w +42)))
- (release
-  (flags (:standard -58))))
-  |#
\ No newline at end of file
diff --git a/opam-package/opam b/opam-package/opam
index 59e1bd7fbb171df2735f4756c9459d7aa875cb19..8b7c36cb7d3eebf31462884ae15d7c04e1ebda78 100644
--- a/opam-package/opam
+++ b/opam-package/opam
@@ -2,17 +2,17 @@ opam-version: "1.2"
 maintainer: "sylvain.pogodalla@inria.fr"
 
 build: [
-  ["jbuilder" "subst"] {pinned}
+  ["dune" "subst"] {pinned}
 # remove the -p to also build the local libraries: conflict with the
 # fact that some libraries are also part of the acgtkLib package
-#  ["jbuilder" "build" "-p" name "-j" jobs]
-  ["jbuilder" "build" "-j" jobs]
+#  ["dune" "build" "-p" name "-j" jobs]
+  ["dune" "build" "-j" jobs]
 ]
 
-install: ["jbuilder" "install"]
+install: ["dune" "install"]
 
 depends: [
-  "jbuilder" {build}
+  "dune" {build}
   "dypgen"
   "camlp4"
   "bolt"
diff --git a/src/acg-data/acg_lexicon.mli b/src/acg-data/acg_lexicon.mli
index 05e03f2c1a0bba8fffa15f6290c21c3434b4fab4..dc447331056135d57b2b09ce35405bf61f811617 100644
--- a/src/acg-data/acg_lexicon.mli
+++ b/src/acg-data/acg_lexicon.mli
@@ -18,7 +18,6 @@
 (**************************************************************************)
 
 open Logic
-open Signature
 
 module Data_Lexicon : Interface.Lexicon_sig
   with
diff --git a/src/acg-data/dune b/src/acg-data/dune
new file mode 100644
index 0000000000000000000000000000000000000000..51f65ede056b3cd66d55c89f069ce017129a03c0
--- /dev/null
+++ b/src/acg-data/dune
@@ -0,0 +1,17 @@
+;; -*-lisp-*-
+
+;; This stanza declares the AcgData library
+(library
+ (name acgData)
+ (public_name acgtkLib.acgData)
+ (flags (:standard -w -58))
+ (preprocess (per_module
+	      ((action (system "%{bin:camlp4} -parser o -parser op -printer a -loc loc %{lib:bolt:bolt_pp.cmo} -level NONE %{input-file}"  ))
+	       reduction acg_lexicon type_system signature)
+	      ))
+ (libraries
+  logic ; internal library
+  datalogLib ; internal library
+  ))
+
+(documentation (package acgtk))
diff --git a/src/acg-data/error.ml b/src/acg-data/error.ml
index abfde933a963e54ea0feca13948670aefb601e44..56f8fcae09f53ef995a3442f05efa280acf26298 100644
--- a/src/acg-data/error.ml
+++ b/src/acg-data/error.ml
@@ -19,8 +19,6 @@
 
 open UtilsLib
 
-type position = Lexing.position
-    
 let update_loc lexbuf file =
   let pos = lexbuf.Lexing.lex_curr_p in
   let new_file = match file with
@@ -179,7 +177,7 @@ let version_error_to_string = function
 
 let warning_to_string w = 
   match w with
-    | Variable_or_constant (s,pos1,pos2) -> Printf.sprintf "\"%s\" is a variable here, but is also declared as constant in the signature" s
+    | Variable_or_constant (s,_,_) -> Printf.sprintf "\"%s\" is a variable here, but is also declared as constant in the signature" s
 	      
 let error_msg e input_file =
   let msg,location_msg =
@@ -195,7 +193,7 @@ let error_msg e input_file =
       | None -> msg
       | Some loc -> Printf.sprintf "File \"%s\", %s\n%s" input_file loc msg
 
-let dyp_error lexbuf input_file =
+let dyp_error lexbuf =
   let pos1=Lexing.lexeme_start_p lexbuf in
   let pos2=Lexing.lexeme_end_p lexbuf in
     match bad_infix_usage () with
@@ -205,7 +203,7 @@ let dyp_error lexbuf input_file =
 
 let emit_warning w input_file = 
   match w with
-    | Variable_or_constant (s,pos1,pos2) -> 
+    | Variable_or_constant (_,pos1,pos2) -> 
 	let msg = warning_to_string w in
 	let line2 = pos2.Lexing.pos_lnum in
 	let col2 = pos2.Lexing.pos_cnum - pos2.Lexing.pos_bol in
diff --git a/src/acg-data/error.mli b/src/acg-data/error.mli
index 87c981d1bf6068e4b9f5355ea683f7980bed1302..f45e92dd9de798fe1266e763449759ed0852f013 100644
--- a/src/acg-data/error.mli
+++ b/src/acg-data/error.mli
@@ -110,10 +110,10 @@ val unset_infix : unit -> unit
     while the file [filename] is being processed *)
 val error_msg : error -> string -> string
 
-(** [dyp_error lexbuf filename] returns an exception {!Error.Error} so
-    that it can be caught in a uniform way. [lexbuf] and [filename] are
+(** [dyp_error lexbuf] returns an exception {!Error.Error} so
+    that it can be caught in a uniform way. [lexbuf] is
     used to set correctly the location information of the parse error *)
-val dyp_error : Lexing.lexbuf -> string -> exn
+val dyp_error : Lexing.lexbuf -> exn
 
 (** [warnings_to_string filname ws] returns a string describing the
     warnings anf their location for the file [filename] *)
diff --git a/src/acg-data/jbuild b/src/acg-data/jbuild
deleted file mode 100644
index 90377650d5ede22ac956c63f789a355cc5987181..0000000000000000000000000000000000000000
--- a/src/acg-data/jbuild
+++ /dev/null
@@ -1,19 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-;; This stanza declares the AcgData library
-(library
- ((name acgData)
-  (public_name acgtkLib.acgData)
-  (flags (:standard -w -58))
-  (preprocess (per_module
-	       ((action (system "${bin:camlp4} -parser o -parser op -printer a -loc loc ${lib:bolt:bolt_pp.cmo} -level NONE ${<}"  ))
-		(reduction acg_lexicon type_system signature))
-	       ))
-  (libraries (
-	      logic ; internal library
-	      datalogLib ; internal library
-	      ))))
-
-(documentation ((package acgtk)))
diff --git a/src/acg-data/reduction.ml b/src/acg-data/reduction.ml
index d275ce6592b3088be31f11381027ddbf6df63e72..7bd7c1650e3de6cbc01a69757a11f809c8ca78b7 100644
--- a/src/acg-data/reduction.ml
+++ b/src/acg-data/reduction.ml
@@ -23,7 +23,8 @@ struct
       [obj_type=image_1 -> image_2 -> ... -> image_n]. Note that the
       list is in the {em reverse order} and that [abs_type] should be
       2nd order. *)
-  let map_types abs_type obj_type sg obj_sg=
+
+  let map_types abs_type obj_type sg  =
     let rec map_types_aux abs_type obj_type lst =
       LOG "Mapping (aux) type:%s" (Sg.type_to_string abs_type sg) LEVEL TRACE;
       LOG "On (aux):          %s" (Lambda.raw_type_to_string obj_type) LEVEL TRACE;
@@ -117,14 +118,14 @@ struct
       object signature of some ACG. *)
 
   let generate_and_add_rule
-      ~abs_cst:(name,abs_t_type)
+      ~abs_cst:(_,abs_t_type)
       ~obj_princ_type:principle_type
       ~obj_typing_env:env
       prog
       ~abs_sig
       ~obj_sig =
     let rule_id,prog=Datalog.Program.get_fresh_rule_id prog in
-    let type_lst = map_types abs_t_type principle_type abs_sig obj_sig in
+    let type_lst = map_types abs_t_type principle_type abs_sig in
     match type_lst with
     | [] -> failwith "Bug: there should be a type correspondance"
     | (_,name,image)::tl ->
@@ -171,7 +172,7 @@ struct
   let edb_and_query ~obj_term ~obj_type ~obj_typing_env ~dist_type prog ~abs_sig ~obj_sig = 
     (* It makes the assumption that no constant has been
      previously defined or used in the program *)
-    let type_lst = map_types dist_type obj_type abs_sig obj_sig in
+    let type_lst = map_types dist_type obj_type abs_sig in
     match type_lst with
     | [] -> failwith "Bug: there should be a type correspondance"
     | [_,name,image] ->
@@ -188,7 +189,7 @@ struct
 	  ([],prog) in
       let prog=Datalog.Program.add_e_facts prog (e_facts,prog.Datalog.Program.const_table,prog.Datalog.Program.rule_id_gen) in
       build_predicate_w_cst_args (name,image) prog 
-    | (_,name,image)::tl -> failwith "Bug: querying non atomic types is not yet implemented"
+    | (_,_,_)::tl -> failwith "Bug: querying non atomic types is not yet implemented"
 		
 		
 end
diff --git a/src/acg-data/signature.mli b/src/acg-data/signature.mli
index 884cbc27d08dc870f3487c08d409930913008a84..53a60dcf85292361b35c8c3006fd6da54f05dddc 100644
--- a/src/acg-data/signature.mli
+++ b/src/acg-data/signature.mli
@@ -17,7 +17,6 @@
 (*                                                                        *)
 (**************************************************************************)
 
-open Logic.Abstract_syntax
 open Logic.Lambda
 
 (*
diff --git a/src/datalog.prover/dune b/src/datalog.prover/dune
new file mode 100644
index 0000000000000000000000000000000000000000..ec81d40bd22bd3dc8d6ddea27b6aeb7019d6f4cd
--- /dev/null
+++ b/src/datalog.prover/dune
@@ -0,0 +1,44 @@
+;; -*-lisp-*-
+
+(ocamllex db_lexer)
+(ocamlyacc db_parser)
+
+;; This stanza declares the DatalogLib
+(library
+ (name datalogLib)
+ (public_name acgtkLib.datalogLib)
+ (flags (:standard -w -58))
+ (preprocess (per_module
+	      (
+	       (action (system "%{bin:camlp4} -parser o -parser op -printer a -loc loc %{lib:bolt:bolt_pp.cmo} -level NONE %{input-file}"  ))
+	       datalog
+	       unionFind
+	       )
+	      )
+	     )
+ (modules (:standard db_parser db_lexer \ test db_test))
+ (libraries
+  bolt ; external libraries
+  str ; external libraries
+  ANSITerminal ; external libraries
+  utilsLib ; internal library
+  ))
+
+(executables
+ (names test db_test)
+  (modules test db_test)
+  (preprocess (per_module
+	       ((action (system "%{bin:camlp4} -parser o -parser op -printer a -loc loc %{lib:bolt:bolt_pp.cmo} -level NONE %{input-file}"  ))
+		db_test)
+	       ))
+  (libraries
+   threads
+   utilsLib
+   datalogLib
+   ))
+
+(alias
+ (name testbuild)
+ (deps test.exe db_test.exe))
+
+(documentation (package acgtk))
diff --git a/src/datalog.prover/jbuild b/src/datalog.prover/jbuild
deleted file mode 100644
index 72c1c0931f2c2dd1c3a59859fe65032af457105a..0000000000000000000000000000000000000000
--- a/src/datalog.prover/jbuild
+++ /dev/null
@@ -1,42 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-(ocamllex (db_lexer))
-(ocamlyacc (db_parser))
-
-;; This stanza declares the DatalogLib
-(library
- ((name datalogLib)
-  (public_name acgtkLib.datalogLib)
-  (flags (:standard -w -58))
-  (preprocess (per_module
-	       (
-		(action (system "${bin:camlp4} -parser o -parser op -printer a -loc loc ${lib:bolt:bolt_pp.cmo} -level NONE ${<}"  ))
-		(datalog unionFind)
-		)
-	       )
-	      )
-  (modules (:standard db_parser db_lexer \ test db_test))
-  (libraries (bolt ; external libraries
-	      str ; external libraries
-	      ANSITerminal ; external libraries
-	      utilsLib ; internal library
-	      ))))
-
-(executables
- ((names (test db_test))
-  (modules (test db_test))
-  (preprocess (per_module
-	       ((action (system "${bin:camlp4} -parser o -parser op -printer a -loc loc ${lib:bolt:bolt_pp.cmo} -level NONE ${<}"  ))
-		(db_test))
-	       ))
-  (libraries (threads
-	      utilsLib
-	      datalogLib))))
-
-(alias
- ((name testbuild)
-  (deps (test.exe db_test.exe))))
-
-(documentation ((package acgtk)))
diff --git a/src/datalog.prover/persistentArray.ml b/src/datalog.prover/persistentArray.ml
index 58fa71ee0ee3f47a4e9dfae0ad3d715016f55a01..450ffb7065af2c87b616599105385634588e2e6f 100644
--- a/src/datalog.prover/persistentArray.ml
+++ b/src/datalog.prover/persistentArray.ml
@@ -25,13 +25,14 @@ struct
 	  l in
       init length (fun i -> IntMap.find i map)
 
-  let rec get_v1 i t =
+(*  let rec get_v1 i t =
     match !t with
     | Arr a -> a.(i+1)
     | Diff (j,v,_) when j=i -> v
     | Diff (_,_,t') -> get_v1 i t'
     | Invalid -> raise Unaccessible
-
+ *)
+           
   let set_v1 i v t =
     match !t with
     | Arr a as n ->
@@ -61,7 +62,7 @@ struct
       end
     | Invalid -> raise Unaccessible
 
-  let rec get_aux i t =
+  let get_aux i t =
     match !t with
     | Arr a -> a.(i)
     | Diff (i,v,t') ->
diff --git a/src/datalog.solver/dune b/src/datalog.solver/dune
new file mode 100644
index 0000000000000000000000000000000000000000..1b04150a5dec882f6c19f99ed9b571f508df1180
--- /dev/null
+++ b/src/datalog.solver/dune
@@ -0,0 +1,12 @@
+;; -*-lisp-*-
+
+(executable
+ (name test)
+ (libraries
+  threads
+  utilsLib
+  logic))
+
+(alias
+ (name testbuild)
+ (deps test.exe))
diff --git a/src/datalog.solver/jbuild b/src/datalog.solver/jbuild
deleted file mode 100644
index fa03645a82b1f02a77c6293105ee0e926fabfa8c..0000000000000000000000000000000000000000
--- a/src/datalog.solver/jbuild
+++ /dev/null
@@ -1,13 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-(executable
- ((name test)
-  (libraries (threads
-	      utilsLib
-	      logic))))
-
-(alias
- ((name testbuild)
-  (deps (test.exe))))
diff --git a/src/grammars/data_parser.dyp b/src/grammars/data_parser.dyp
index b5cb6233cf47467e34658f0bf0bf9005240ef6a1..9bfb4d6c3523d2f60775941caad94f9b28bd91aa 100644
--- a/src/grammars/data_parser.dyp
+++ b/src/grammars/data_parser.dyp
@@ -570,7 +570,7 @@ sig_entries :
       let starting_parse_time = Sys.time () in
       let e = 
 	try (fst (List.hd (data ~global_data:override ~local_data:actual_env Data_lexer.lexer lexbuf))) with
-	  |  Dyp.Syntax_error -> raise (Error.dyp_error lexbuf filename) in
+	  |  Dyp.Syntax_error -> raise (Error.dyp_error lexbuf) in
       let ending_parse_time = Sys.time () in
       let () = Printf.printf "Done (required %.3f seconds).\n%!" (ending_parse_time -. starting_parse_time) in
       let () = match output with
@@ -612,7 +612,7 @@ let parse_term ?(output=false) t sg =
     let () = Data_lexer.set_to_term () in
     let abs_term,abs_type = 
       try fst (List.hd(term_alone ~global_data:false ~local_data:(Some (Signature sg)) Data_lexer.lexer lexbuf)) with
-      | Dyp.Syntax_error -> raise (Error.dyp_error lexbuf "stdin") in
+      | Dyp.Syntax_error -> raise (Error.dyp_error lexbuf) in
     let () = 
       match output with
       | true -> 
@@ -649,7 +649,7 @@ let parse_heterogenous_term  ?(output=false) t lex =
     let () = Data_lexer.set_to_term () in
     let obj_term,abs_type = 
       try fst (List.hd(heterogenous_term_and_type ~global_data:false ~local_data:(Some (Abs_and_obj (abs,obj))) Data_lexer.lexer lexbuf)) with
-      | Dyp.Syntax_error -> raise (Error.dyp_error lexbuf "stdin") in
+      | Dyp.Syntax_error -> raise (Error.dyp_error lexbuf) in
     let abs_type=Environment.Signature1.convert_type abs_type abs in
     let obj_type=Environment.Lexicon.interpret_type abs_type lex in
     let obj_term=Environment.Signature1.typecheck obj_term obj_type obj in
@@ -685,7 +685,7 @@ let parse_heterogenous_term  ?(output=false) t lex =
       try 
 	let () = Data_lexer.set_to_sig_entry () in
 	  try Some ((fst (List.hd(sig_entry ~global_data:false ~local_data:(Some (Signature sg)) Data_lexer.lexer lexbuf))) sg) with
-	    | Dyp.Syntax_error -> raise (Error.dyp_error lexbuf "stdin")
+	    | Dyp.Syntax_error -> raise (Error.dyp_error lexbuf)
       with
 	| Error.Error er -> 
 	  let () = pp_error er t in
@@ -698,7 +698,7 @@ let parse_heterogenous_term  ?(output=false) t lex =
       try 
 	let () = Data_lexer.set_to_lex_entry () in
 	  try Some ((fst (List.hd(lex_entry ~global_data:false ~local_data:(Some (Abs_and_obj (Environment.Lexicon.get_sig lex))) Data_lexer.lexer lexbuf))) lex) with
-	    | Dyp.Syntax_error -> raise (Error.dyp_error lexbuf "stdin")
+	    | Dyp.Syntax_error -> raise (Error.dyp_error lexbuf)
       with
 	| Error.Error er -> 
 	  let () = pp_error er t in
diff --git a/src/grammars/dune b/src/grammars/dune
new file mode 100644
index 0000000000000000000000000000000000000000..2f5683dde9bce728bc2310e5ab879053d9faffa3
--- /dev/null
+++ b/src/grammars/dune
@@ -0,0 +1,38 @@
+;; -*-lisp-*-
+
+(rule
+ (targets data_parser.ml)
+ (deps    (:input-file data_parser.dyp))
+ (action  (chdir %{project_root} (run %{bin:dypgen} --noemit-token-type --no-pp --no-obj-type --no-mli %{input-file})))
+ )
+
+(ocamllex data_lexer)
+
+;; This stanza declares the Grammar library
+(library
+ (name grammars)
+ (preprocess (per_module ((action  (system "%{bin:camlp4} -parser o -parser op -printer a -loc loc %{lib:bolt:bolt_pp.cmo} -level NONE %{input-file}"  ))
+			  entry)))
+  (flags (:standard -w -58))
+  (modules (:standard \ acgc interactive))
+  (libraries 
+   logic
+   acgData
+   )
+  )
+
+;; This declares the acgc executable implemented by acgc.ml
+(executable
+ (name acgc)
+ (public_name acgc)
+ (package acgtk)
+ (modules acgc)
+ (libraries
+  threads
+  logic
+  acgData
+  grammars
+  ))
+
+
+(documentation (package acgtkLib))
diff --git a/src/grammars/jbuild b/src/grammars/jbuild
deleted file mode 100644
index f4b5a43a494b53dc95c7174f9f01ab10d6567bf5..0000000000000000000000000000000000000000
--- a/src/grammars/jbuild
+++ /dev/null
@@ -1,39 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-(rule
- ((targets (data_parser.ml))
-  (deps    (data_parser.dyp))
-  (action  (chdir ${ROOT} (run ${bin:dypgen} --noemit-token-type --no-pp --no-obj-type --no-mli ${<}))))
- )
-
-(ocamllex (data_lexer))
-
-;; This stanza declares the Grammar library
-(library
- ((name grammars)
-  (preprocess (per_module ((action  (system "${bin:camlp4} -parser o -parser op -printer a -loc loc ${lib:bolt:bolt_pp.cmo} -level NONE ${<}"  ))(entry))))
-  (flags (:standard -w -58))
-  (modules (:standard \ acgc interactive))
-  (libraries (
-	      logic
-	      acgData
-   	      ))
-  ))
-
-;; This declares the acgc executable implemented by acgc.ml
-(executable
- ((name acgc)
-  (public_name acgc)
-  (package acgtk)
-  (modules acgc)
-  (libraries (
-	      threads
-	      logic
-	      acgData
-	      grammars
-	      ))))
-
-
-(documentation ((package acgtkLib)))
diff --git a/src/logic/dune b/src/logic/dune
new file mode 100644
index 0000000000000000000000000000000000000000..e9c827da7e91f76924a04f81a93bb9e1ea881707
--- /dev/null
+++ b/src/logic/dune
@@ -0,0 +1,32 @@
+;; -*-lisp-*-
+
+;; This declares the Logic libreary
+(library
+ (name logic)
+ (public_name acgtkLib.logic)
+ (flags (:standard -w -58))
+ (modules (:standard \ typeInference_test))
+ (preprocess (per_module
+	      ((action (system "%{bin:camlp4} -parser o -parser op -printer a -loc loc %{lib:bolt:bolt_pp.cmo} -level NONE %{input-file}"  ))
+	       typeInference
+	       varUnionFind))
+	     )
+ (libraries
+  dyp ; external library
+  ANSITerminal ; external library
+  utilsLib ; internal library
+  ))
+
+(executables
+ (names typeInference_test)
+ (modules typeInference_test)
+ (libraries
+  threads
+  utilsLib
+  logic))
+
+(alias
+ (name testbuild)
+ (deps typeInference_test.exe))
+
+(documentation (package acgtk))
diff --git a/src/logic/jbuild b/src/logic/jbuild
deleted file mode 100644
index e5b0107edba6fc1fa703086e9760ca92c58216e2..0000000000000000000000000000000000000000
--- a/src/logic/jbuild
+++ /dev/null
@@ -1,30 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-;; This declares the Logic libreary
-(library
- ((name logic)
-  (public_name acgtkLib.logic)
-  (flags (:standard -w -58))
-  (modules (:standard \ typeInference_test))
-  (preprocess (per_module
-	       ((action (system "${bin:camlp4} -parser o -parser op -printer a -loc loc ${lib:bolt:bolt_pp.cmo} -level NONE ${<}"  ))
-		(typeInference varUnionFind))
-	       ))
-  (libraries (dyp ; external library
-	      ANSITerminal ; external library
-	      utilsLib ; internal library
-	      ))))
-(executables
- ((names (typeInference_test))
-  (modules (typeInference_test))
-  (libraries (threads
-	      utilsLib
-	      logic))))
-
-(alias
- ((name testbuild)
-  (deps (typeInference_test.exe))))
-
-(documentation ((package acgtk)))
diff --git a/src/scripting/acg.ml b/src/scripting/acg.ml
index 2736eb47669140598913a084796a8928b043a031..3c54e298911e8901e47a21025e233b0bdc303898 100644
--- a/src/scripting/acg.ml
+++ b/src/scripting/acg.ml
@@ -1,5 +1,5 @@
 (**************************************************************************)
-(*                               g                                         *)
+(*                                                                        *)
 (*                 ACG development toolkit                                *)
 (*                                                                        *)
 (*                  Copyright 2008 INRIA                                  *)
diff --git a/src/scripting/dune b/src/scripting/dune
new file mode 100644
index 0000000000000000000000000000000000000000..a1017aa2ba6d51503366cdbc787fc2b4bde353ed
--- /dev/null
+++ b/src/scripting/dune
@@ -0,0 +1,44 @@
+;; -*-lisp-*-
+
+(rule
+ (targets script_parser.ml)
+ (deps    (:input-file script_parser.dyp))
+ (action  (chdir %{project_root} (run %{bin:dypgen} --noemit-token-type --no-pp --no-obj-type --no-mli %{input-file})))
+ )
+
+(ocamllex script_lexer)
+
+;; This stanza declares the scripting library
+(library
+ (name scripting)
+  (flags (:standard -w -58))
+  (modules (:standard \ acg io_test))
+  (libraries
+   threads
+   cairo2
+   ocf
+   utilsLib
+   acgData
+   grammars
+   ))
+
+
+;; This declares the acgc executable implemented by acg.ml
+(executable
+ (name acg)
+ (public_name acg)
+ (package acgtk)
+ (modules acg)
+ (flags (:standard -w -58))
+ (libraries
+  threads
+  cairo2
+  ocf
+  utilsLib
+  acgData
+  grammars
+  scripting
+  ))
+ 
+
+(documentation (package acgtk))
diff --git a/src/scripting/jbuild b/src/scripting/jbuild
deleted file mode 100644
index f0ea204d35faf091632877a69967a35d3df764f9..0000000000000000000000000000000000000000
--- a/src/scripting/jbuild
+++ /dev/null
@@ -1,47 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-(rule
- ((targets (script_parser.ml))
-  (deps    (script_parser.dyp))
-  (action  (chdir ${ROOT} (run ${bin:dypgen} --noemit-token-type --no-pp --no-obj-type --no-mli ${<}))))
- )
-
-(ocamllex (script_lexer))
-
-;; This stanza declares the scripting library
-(library
- ((name scripting)
-  (flags (:standard -w -58))
-  (modules (:standard \ acg io_test))
-  (libraries (
-	      threads
-	      cairo2
-	      ocf
-	      utilsLib
-	      acgData
-	      grammars
-	      ))
-  ))
-
-
-;; This declares the acgc executable implemented by acg.ml
-(executable
- ((name acg)
-  (public_name acg)
-  (package acgtk)
-  (modules acg)
-  (flags (:standard -w -58))
-  (libraries (
-	      threads
-	      cairo2
-	      ocf
-	      utilsLib
-	      acgData
-	      grammars
-	      scripting
-	      ))))
- 
-
-(documentation ((package acgtk)))
diff --git a/src/scripting/script_parser.dyp b/src/scripting/script_parser.dyp
index f9f1801aab28158d8e02bebafa5ba5c69efff723..7473c7717a1db7182c23d2b2a760762816cf063e 100644
--- a/src/scripting/script_parser.dyp
+++ b/src/scripting/script_parser.dyp
@@ -266,7 +266,7 @@ QUERY_HELP
       let () = Printf.printf "Parsing script file \"%s\"...\n%!" filename in
       let new_env=
 	try (fst (List.hd (zzcommands ~global_data:(F.should_wait (),verbose,includes,svg_output) ~local_data:(env,parse_file ~verbose ?svg_output)  Script_lexer.lexer lexbuf))) with
-	  |  Dyp.Syntax_error -> raise (AcgData.Error.dyp_error lexbuf filename) in
+	  |  Dyp.Syntax_error -> raise (AcgData.Error.dyp_error lexbuf) in
       let () = Printf.printf "Done.\n%!" in
 	new_env
     with
@@ -332,7 +332,7 @@ QUERY_HELP
   let new_env=
     try
       try (fst (List.hd (zzcommands ~global_data:(false,verbose,includes,svg_output) ~local_data:(env,parse_file ~verbose ?svg_output)  Script_lexer.lexer lexbuf))) with
-      |  Dyp.Syntax_error -> raise (AcgData.Error.dyp_error lexbuf "stdin")
+      |  Dyp.Syntax_error -> raise (AcgData.Error.dyp_error lexbuf)
     with
     | F.Stop -> env
     | Failure f when f="lexing: empty token" -> env
diff --git a/src/utils/dependencyManager.ml b/src/utils/dependencyManager.ml
index 7999304b60a1065479c4b43168aa4272dd2c350f..c1b0a92b452cc23b96c9a2e14fb7fedf34fe5131 100644
--- a/src/utils/dependencyManager.ml
+++ b/src/utils/dependencyManager.ml
@@ -12,7 +12,8 @@ module type Manager_sig =
   end
 
 
-module Make(O:sig type t val compare:t->t->int val to_string:t->string end) =
+(*module Make(O:sig type t val compare:t->t->int val to_string:t->string end) = *)
+module Make(O:Map.OrderedType) =
 struct
   module EltSet=Set.Make(O)
   module EltMap=Map.Make(O)
diff --git a/src/utils/dependencyManager.mli b/src/utils/dependencyManager.mli
index 73435b12f717648a31441e1f28cbdaa157f5de20..107616223a24f3534d22f00bfa5e03c5b810d44c 100644
--- a/src/utils/dependencyManager.mli
+++ b/src/utils/dependencyManager.mli
@@ -58,4 +58,5 @@ module type Manager_sig =
   end
 
 
-module Make(O:sig type t val compare:t->t->int val to_string:t->string end) : Manager_sig with type elt=O.t
+(*module Make(O:sig type t val compare:t->t->int val to_string:t->string end) : Manager_sig with type elt=O.t *)
+module Make(O:Map.OrderedType) : Manager_sig with type elt=O.t
diff --git a/src/utils/dune b/src/utils/dune
new file mode 100644
index 0000000000000000000000000000000000000000..a5586bfa333a176199a3c1da830ab2fb3ffde641
--- /dev/null
+++ b/src/utils/dune
@@ -0,0 +1,32 @@
+;; -*-lisp-*-
+
+;; This declares the utilsLib library
+(library
+ (name utilsLib)
+ (public_name acgtkLib.utilsLib)
+ (preprocess (per_module
+	      ((action (system "%{bin:camlp4} -parser o -parser op -printer a -loc loc %{lib:bolt:bolt_pp.cmo} -level NONE %{input-file}"))
+	       utils
+	       sharedForest)
+	      ))
+ (flags (:standard -w -58))
+ (modules (:standard \ test_sharedForest test_dependencyManager))
+ (libraries
+  bolt ; external libraries
+  str ; external libraries
+  ANSITerminal ; external libraries
+  ))
+
+(executables
+ (names test_sharedForest test_dependencyManager)
+ (libraries
+  threads
+  utilsLib)
+ (modules test_sharedForest test_dependencyManager)
+ )
+
+(alias
+ (name testbuild)
+ (deps test_sharedForest.exe test_dependencyManager.exe))
+
+(documentation (package acgtk))
diff --git a/src/utils/jbuild b/src/utils/jbuild
deleted file mode 100644
index 7f084c93b36a980ef1603d7d795b7893d036b446..0000000000000000000000000000000000000000
--- a/src/utils/jbuild
+++ /dev/null
@@ -1,34 +0,0 @@
-;; -*-lisp-*-
-
-(jbuild_version 1)
-
-;; This declares the utilsLib library
-(library
- ((name utilsLib)
-  (public_name acgtkLib.utilsLib)
-  (preprocess (per_module
-	       ((action (system "${bin:camlp4} -parser o -parser op -printer a -loc loc ${lib:bolt:bolt_pp.cmo} -level NONE ${<}"))
-		(utils sharedForest))
-;;	       ((action (system "sed -e \"s/DATE/$(date '+%Y%m%d')/g\" -e \"s/VERSION/$(cat ../../acgtk.version)/g\" ${<}"))
-;;	       	(version))
-	       ))
-  (flags (:standard -w -58))
-  (modules (:standard \ test_sharedForest test_dependencyManager))
-  (libraries (
-	      bolt ; external libraries
-	      str ; external libraries
-	      ANSITerminal ; external libraries
-	      ))))
-
-(executables
- ((names (test_sharedForest test_dependencyManager))
-  (libraries (threads
-	      utilsLib))
-  (modules (test_sharedForest test_dependencyManager))
-  ))
-
-(alias
- ((name testbuild)
-  (deps (test_sharedForest.exe test_dependencyManager.exe))))
-
-(documentation ((package acgtk)))
diff --git a/src/utils/sharedForest.ml b/src/utils/sharedForest.ml
index b527d7af6e42964e99d8e121d42547217fb0171c..ed81cfc308478fb7622f0f67c63bccb7d51e3bc2 100644
--- a/src/utils/sharedForest.ml
+++ b/src/utils/sharedForest.ml
@@ -308,7 +308,7 @@ struct
       
   let simple_tree (Node (v,_)) = SimpleTree (v,[])
     
-  let rec down (z,t) (zipper,b_t) depth resume=
+  let down (z,t) (zipper,b_t) depth resume=
     match t with
     | Node (_,[]) -> raise (Move_failure Down)
     | Node (v,forest::tl) ->