[libfolia] 52/53: Imported Upstream version 0.11

Joost van Baal joostvb at moszumanska.debian.org
Sat Sep 6 10:46:10 UTC 2014


This is an automated email from the git hooks/post-receive script.

joostvb pushed a commit to branch master
in repository libfolia.

commit 324b27a88ebb50860039b6c63c04797f8144236a
Author: Joost van Baal-Ilić <joostvb at nusku.mdcc.cx>
Date:   Sat Sep 6 12:29:54 2014 +0200

    Imported Upstream version 0.11
---
 AUTHORS                       |   12 +
 ChangeLog                     |  332 ++++++
 INSTALL                       |   12 +-
 Makefile.am                   |    2 +-
 Makefile.in                   |  356 ++++---
 NEWS                          |    9 +-
 aclocal.m4                    |  686 +++++++-----
 bootstrap => bootstrap.sh     |    6 +-
 compile                       |  347 +++++++
 config.guess                  |  184 ++--
 config.h.in                   |    3 +
 config.sub                    |  106 +-
 configure                     |  885 +++++++++-------
 configure.ac                  |   12 +-
 depcomp                       |  487 +++++----
 include/Makefile.in           |  275 ++---
 include/libfolia/Makefile.in  |  176 +++-
 include/libfolia/document.h   |   69 +-
 include/libfolia/folia.h      | 1322 ++++++++++++++----------
 include/libfolia/foliautils.h |  136 +--
 install-sh                    |   35 +-
 ltmain.sh                     |    4 +-
 m4/Makefile.in                |  101 +-
 missing                       |  414 +++-----
 src/Makefile.am               |    8 +-
 src/Makefile.in               |  702 +++++++++----
 src/document.cxx              |  436 +++++---
 src/folia.cxx                 | 2294 ++++++++++++++++++++++++++++-------------
 src/folialint.cxx             |    9 +-
 src/foliautils.cxx            |  376 ++++---
 src/simpletest.cxx            |   10 +-
 test-driver                   |  139 +++
 32 files changed, 6596 insertions(+), 3349 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 6c33ce9..ea08719 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,14 @@
+libfolia:
+
+Code, algorithm, and design contributions by:
+
 Ko van der Sloot
 Maarten van Gompel
+
+Contributors:
+
+People who contributed to libfolia by suggesting improvements, filing bug
+reports, asking the right questions etc.:
+
+Antal vd Bosch
+Erik Tjong Kim Sam
diff --git a/ChangeLog b/ChangeLog
index d2d5c2d..f0887df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,335 @@
+2014-05-26 14:34  sloot
+
+	* [r17259] include/libfolia/folia.h, include/libfolia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: noteref ==> ref
+
+2014-05-26 14:20  sloot
+
+	* [r17257] src/folia.cxx: a cell may contains entities
+
+2014-05-26 13:14  sloot
+
+	* [r17254] src/document.cxx: Don't exclude Note in sentence count
+
+2014-05-23 09:08  sloot
+
+	* [r17246] src/folia.cxx: fixed id handling in Note
+
+2014-05-22 15:41  sloot
+
+	* [r17243] COPYING: and reinstated
+
+2014-05-22 15:41  sloot
+
+	* [r17242] COPYING, src/foliautils.cxx: deleted COPYING (stupid
+	  soft link)
+
+2014-05-22 15:32  sloot
+
+	* [r17240] include/libfolia/folia.h, include/libfolia/foliautils.h,
+	  src/document.cxx, src/folia.cxx, src/foliautils.cxx: first
+	  implementation of Note en NoteReference
+
+2014-05-22 14:26  sloot
+
+	* [r17238] COPYING, include/libfolia/document.h,
+	  include/libfolia/folia.h, include/libfolia/foliautils.h,
+	  src/Makefile.am, src/document.cxx, src/folia.cxx,
+	  src/folialint.cxx, src/foliautils.cxx: added code for External
+	  and Note.
+	  Not completed yet
+
+2014-05-06 13:34  sloot
+
+	* [r17201] include/libfolia/document.h, src/document.cxx,
+	  src/folia.cxx: added an init procedure which MUST be called
+	  before running MT applications
+
+2014-04-30 10:47  sloot
+
+	* [r17174] COPYING, include/libfolia/folia.h, src/folia.cxx: added
+	  2 helper functions
+
+2014-04-30 10:38  sloot
+
+	* [r17172] Makefile.am: fixed 'make dist'
+
+2014-03-13 13:30  sloot
+
+	* [r17030] src/folia.cxx: allow nested Morphemes
+
+2014-02-05 10:31  sloot
+
+	* [r16921] src/document.cxx: 2 typos and a sanity check
+
+2014-01-06 10:01  sloot
+
+	* [r16816] include/libfolia/document.h, include/libfolia/folia.h,
+	  include/libfolia/foliautils.h, src/document.cxx, src/folia.cxx,
+	  src/folialint.cxx, src/foliautils.cxx, src/simpletest.cxx: Happy
+	  Newyear!
+
+2013-11-18 11:59  sloot
+
+	* [r16714] src/folia.cxx: fixed stupid bug. looping to 0 is
+	  difficult with unsigned ints.
+
+2013-10-28 15:44  sloot
+
+	* [r16655] include/libfolia/document.h, src/document.cxx: added
+	  code to handle 'non-standard' meta tags.
+
+2013-10-24 13:01  sloot
+
+	* [r16649] include/libfolia/folia.h, src/folia.cxx,
+	  src/foliautils.cxx: hacks to please the compiler
+
+2013-10-24 10:49  sloot
+
+	* [r16644] include/libfolia/folia.h, include/libfolia/foliautils.h:
+	  less warings on '-pedantic' compiler
+
+2013-10-17 12:13  sloot
+
+	* [r16613] bootstrap, bootstrap.sh, config.h.in, configure.ac:
+	  modernized
+
+2013-10-15 08:10  sloot
+
+	* [r16580] src/folia.cxx: no more Text in a List please!
+
+2013-08-19 08:57  sloot
+
+	* [r16458] src/folia.cxx: eeeeek
+
+2013-08-19 08:48  sloot
+
+	* [r16456] src/folia.cxx: refactored appending a bit. addable() now
+	  tests illegal reconnection of parents.
+
+2013-08-15 17:01  sloot
+
+	* [r16443] src/folia.cxx: added a test for 'empty' t nodes under
+	  <w>
+	  attempt also to check connecting a node twice.
+	  But this is difficult. Needs thinking
+
+2013-07-11 10:07  sloot
+
+	* [r16346] src/folia.cxx: fixed occurences problem
+
+2013-07-10 09:59  sloot
+
+	* [r16335] include/libfolia/document.h, include/libfolia/folia.h,
+	  src/document.cxx: fixed toktext()
+	  added convinient function
+
+2013-07-08 15:26  sloot
+
+	* [r16329] include/libfolia/folia.h, src/folia.cxx: fix. The ABI is
+	  borken :{
+
+2013-07-08 14:25  sloot
+
+	* [r16327] include/libfolia/folia.h, src/folia.cxx: keep fixing
+	  text() stuff
+
+2013-07-08 13:24  sloot
+
+	* [r16325] include/libfolia/folia.h, src/folia.cxx: fixing text()
+	  stuff. Quite a mess
+
+2013-07-04 16:46  sloot
+
+	* [r16313] include/libfolia/folia.h, src/folia.cxx: fix
+	  TextMarkupCorrection text()
+
+2013-07-04 15:48  sloot
+
+	* [r16311] src/document.cxx: version bumped!
+
+2013-07-04 15:32  sloot
+
+	* [r16310] include/libfolia/folia.h, src/folia.cxx: hmpff. stil
+	  small 'id' problem
+
+2013-07-04 15:08  sloot
+
+	* [r16309] include/libfolia/folia.h, include/libfolia/foliautils.h,
+	  src/document.cxx, src/folia.cxx, src/foliautils.cxx: totally
+	  reworked TextContent class, using extre <xml-text> pseudo nodes
+	  also better handle difference betweed xml:id and id attributes.
+	  Some cleanup is needed, but it works
+
+2013-07-03 15:10  mvgompel
+
+	* [r16302] src/foliautils.cxx: small patch, div-annotation should
+	  be division-annotation, documentation and libraries didn't match,
+	  now allowing both when reading to prevent issues
+
+2013-07-03 10:17  sloot
+
+	* [r16300] include/libfolia/folia.h, include/libfolia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: started implementing Markup
+
+2013-07-02 13:59  sloot
+
+	* [r16298] include/libfolia/folia.h, src/folia.cxx: some
+	  refactoring of text(). added a deeptext() as complement of
+	  stricttext()
+
+2013-07-01 15:53  sloot
+
+	* [r16289] include/libfolia/folia.h, src/Makefile.am,
+	  src/folia.cxx: attampt to repair gettextDelimitter in a ABI
+	  preserving way
+
+2013-07-01 13:02  sloot
+
+	* [r16288] include/libfolia/folia.h: unfix the last fix
+
+2013-07-01 12:43  sloot
+
+	* [r16287] include/libfolia/folia.h: small fix
+
+2013-06-27 14:06  sloot
+
+	* [r16277] src/document.cxx: small chage to avoid unexpected
+	  attribute order in metadata nodes
+
+2013-06-26 14:42  sloot
+
+	* [r16272] src/folia.cxx: smarter solution (and thread-safe)
+
+2013-06-26 09:18  sloot
+
+	* [r16266] include/libfolia/folia.h, src/folia.cxx: some
+	  refactoring to get things a bit more generic
+
+2013-06-25 12:17  sloot
+
+	* [r16263] include/libfolia/folia.h, src/folia.cxx: added
+	  isSubClass() functions to the interface
+
+2013-06-25 09:47  sloot
+
+	* [r16262] include/libfolia/folia.h, include/libfolia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: Some refactoring. More generic
+	  solution for Folia Class Hiearchy
+
+2013-06-24 09:49  sloot
+
+	* [r16259] include/libfolia/folia.h, include/libfolia/foliautils.h,
+	  src/folia.cxx, src/foliautils.cxx: changed and improved handling
+	  of XML comment nodes
+
+2013-06-20 15:51  sloot
+
+	* [r16257] src/document.cxx, src/folia.cxx: added experimental
+	  support for XML comment nodes
+
+2013-06-18 14:17  sloot
+
+	* [r16251] src/folia.cxx: clearer message
+
+2013-06-18 10:57  sloot
+
+	* [r16249] include/libfolia/folia.h, src/folia.cxx: xml:lang is
+	  unsupported now :{
+
+2013-06-18 10:37  sloot
+
+	* [r16248] include/libfolia/document.h, include/libfolia/folia.h,
+	  include/libfolia/foliautils.h, src/document.cxx, src/folia.cxx,
+	  src/foliautils.cxx: fixed a bug in document parsing (meta nodes
+	  were ignored)
+	  added lang node and LANG token annotation
+	  some provision for comment nodes added
+
+2013-06-17 14:01  sloot
+
+	* [r16241] src/document.cxx: oesp. 1 bit to optimistic about
+	  version
+
+2013-06-17 13:56  sloot
+
+	* [r16239] include/libfolia/folia.h, include/libfolia/foliautils.h,
+	  src/document.cxx, src/folia.cxx, src/foliautils.cxx: added table
+	  stuff
+
+2013-05-23 10:19  sloot
+
+	* [r16118] include/libfolia/folia.h, src/folia.cxx: implemented
+	  findspans().
+	  bit clumsy rethinking required
+
+2013-05-22 15:52  sloot
+
+	* [r16116] include/libfolia/folia.h, src/document.cxx,
+	  src/folia.cxx: some refactoring.
+	  also implemented findspan() and wref()
+
+2013-05-14 15:13  sloot
+
+	* [r16077] include/libfolia/document.h, src/document.cxx: let
+	  isDeclared ignore the date
+
+2013-05-14 13:30  sloot
+
+	* [r16076] include/libfolia/folia.h, src/folia.cxx: some
+	  refactoring to enable corrections for Str nodes
+
+2013-04-13 21:42  mvgompel
+
+	* [r15991] include/libfolia/folia.h: added
+	  FoliaElement::printable()
+
+2013-04-09 13:44  sloot
+
+	* [r15967] configure.ac: signal our needs
+
+2013-04-09 13:43  sloot
+
+	* [r15966] src/document.cxx: use new ticcutils stuff
+
+2013-04-08 15:47  sloot
+
+	* [r15960] src/document.cxx: added GZ support
+
+2013-04-08 14:27  sloot
+
+	* [r15957] configure.ac, src/document.cxx: added read/write of .bz2
+	  files
+
+2013-04-04 11:49  sloot
+
+	* [r15942] configure.ac: bump version after release
+
+2013-04-03 15:53  sloot
+
+	* [r15924] src/Makefile.am: increment current library version
+
+2013-04-03 13:52  sloot
+
+	* [r15909] include/Makefile.am, include/libfolia/document.h,
+	  include/libfolia/folia.h, src/document.cxx, src/folia.cxx,
+	  src/folialint.cxx, src/foliautils.cxx, src/simpletest.cxx: ok,
+	  reverted the plan to name the package 'folia'
+	  it is 'libfolia' now everywhere
+
+2013-04-03 13:45  sloot
+
+	* [r15908] include/libfolia/folia: hmm
+
+2013-04-03 13:43  sloot
+
+	* [r15907] configure.ac, include/folia, include/libfolia,
+	  include/libfolia/folia: rename dir
+
+2013-04-03 12:56  sloot
+
+	* [r15904] NEWS: news
+
 2013-04-03 08:50  sloot
 
 	* [r15893] include/folia/foliautils.h, src/document.cxx,
diff --git a/INSTALL b/INSTALL
index a1e89e1..2099840 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,7 +1,7 @@
 Installation Instructions
 *************************
 
-Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
+Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
 Inc.
 
    Copying and distribution of this file, with or without modification,
@@ -12,8 +12,8 @@ without warranty of any kind.
 Basic Installation
 ==================
 
-   Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package.  The following
+   Briefly, the shell command `./configure && make && make install'
+should configure, build, and install this package.  The following
 more-detailed instructions are generic; see the `README' file for
 instructions specific to this package.  Some packages provide this
 `INSTALL' file but do not implement all of the features documented
@@ -309,9 +309,10 @@ causes the specified `gcc' to be used as the C compiler (unless it is
 overridden in the site shell script).
 
 Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug.  Until the bug is fixed you can use this workaround:
+an Autoconf limitation.  Until the limitation is lifted, you can use
+this workaround:
 
-     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+     CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
 
 `configure' Invocation
 ======================
@@ -367,4 +368,3 @@ operates.
 
 `configure' also accepts some other, not widely useful, options.  Run
 `configure --help' for more details.
-
diff --git a/Makefile.am b/Makefile.am
index c8f8b31..ccef7c8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ ACLOCAL_AMFLAGS = -I m4 --install
 
 SUBDIRS = src include m4
 
-EXTRA_DIST = bootstrap AUTHORS TODO NEWS folia.pc.in
+EXTRA_DIST = bootstrap.sh AUTHORS TODO NEWS folia.pc.in
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = folia.pc
diff --git a/Makefile.in b/Makefile.in
index 8029cff..6c3e6b2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -19,6 +18,51 @@
 # $URL: https://ilk.uvt.nl/svn/trunk/sources/ucto/trunk/Makefile.am $
 
 VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -38,11 +82,12 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = .
-DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
-	$(srcdir)/folia.pc.in $(top_srcdir)/configure AUTHORS COPYING \
-	ChangeLog INSTALL NEWS TODO config.guess config.sub depcomp \
-	install-sh ltmain.sh missing
+DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
+	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/configure $(am__configure_deps) \
+	$(srcdir)/config.h.in $(srcdir)/folia.pc.in COPYING TODO \
+	compile config.guess config.sub depcomp install-sh missing \
+	ltmain.sh
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_icu_check.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -57,15 +102,33 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES = folia.pc
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 SOURCES =
 DIST_SOURCES =
-RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
-	html-recursive info-recursive install-data-recursive \
-	install-dvi-recursive install-exec-recursive \
-	install-html-recursive install-info-recursive \
-	install-pdf-recursive install-ps-recursive install-recursive \
-	installcheck-recursive installdirs-recursive pdf-recursive \
-	ps-recursive uninstall-recursive
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+	ctags-recursive dvi-recursive html-recursive info-recursive \
+	install-data-recursive install-dvi-recursive \
+	install-exec-recursive install-html-recursive \
+	install-info-recursive install-pdf-recursive \
+	install-ps-recursive install-recursive installcheck-recursive \
+	installdirs-recursive pdf-recursive ps-recursive \
+	tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -97,11 +160,33 @@ am__installdirs = "$(DESTDIR)$(pkgconfigdir)"
 DATA = $(pkgconfig_DATA)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
-AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
-	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
-	distdir dist dist-all distcheck
+am__recursive_targets = \
+  $(RECURSIVE_TARGETS) \
+  $(RECURSIVE_CLEAN_TARGETS) \
+  $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+	cscope distdir dist dist-all distcheck
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
+	$(LISP)config.h.in
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
@@ -112,6 +197,7 @@ am__remove_distdir = \
       && rm -rf "$(distdir)" \
       || { sleep 5 && rm -rf "$(distdir)"; }; \
   else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
 am__relativize = \
   dir0=`pwd`; \
   sed_first='s,^\([^/]*\)/.*$$,\1,'; \
@@ -139,12 +225,14 @@ am__relativize = \
   reldir="$$dir2"
 DIST_ARCHIVES = $(distdir).tar.gz
 GZIP_ENV = --best
+DIST_TARGETS = dist-gzip
 distuninstallcheck_listfiles = find . -type f -print
 am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
   | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
 distcleancheck_listfiles = find . -type f -print
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -190,7 +278,6 @@ LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
@@ -279,7 +366,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 ACLOCAL_AMFLAGS = -I m4 --install
 SUBDIRS = src include m4
-EXTRA_DIST = bootstrap AUTHORS TODO NEWS folia.pc.in
+EXTRA_DIST = bootstrap.sh AUTHORS TODO NEWS folia.pc.in
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = folia.pc
 all: config.h
@@ -322,8 +409,8 @@ $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 $(am__aclocal_m4_deps):
 
 config.h: stamp-h1
-	@if test ! -f $@; then rm -f stamp-h1; else :; fi
-	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
+	@test -f $@ || rm -f stamp-h1
+	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
 
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
@@ -348,8 +435,11 @@ distclean-libtool:
 	-rm -f libtool config.lt
 install-pkgconfigDATA: $(pkgconfig_DATA)
 	@$(NORMAL_INSTALL)
-	test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
 	@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \
+	fi; \
 	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  echo "$$d$$p"; \
@@ -366,22 +456,25 @@ uninstall-pkgconfigDATA:
 	dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
 
 # This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-#     (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-$(RECURSIVE_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+#     (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+	@fail=; \
+	if $(am__make_keepgoing); then \
+	  failcom='fail=yes'; \
+	else \
+	  failcom='exit 1'; \
+	fi; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	for subdir in $$list; do \
 	  echo "Making $$target in $$subdir"; \
 	  if test "$$subdir" = "."; then \
 	    dot_seen=yes; \
@@ -396,57 +489,12 @@ $(RECURSIVE_TARGETS):
 	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 	fi; test -z "$$fail"
 
-$(RECURSIVE_CLEAN_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	dot_seen=no; \
-	case "$@" in \
-	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-	  *) list='$(SUBDIRS)' ;; \
-	esac; \
-	rev=''; for subdir in $$list; do \
-	  if test "$$subdir" = "."; then :; else \
-	    rev="$$subdir $$rev"; \
-	  fi; \
-	done; \
-	rev="$$rev ."; \
-	target=`echo $@ | sed s/-recursive//`; \
-	for subdir in $$rev; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
-	done && test -z "$$fail"
-tags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
-	done
-ctags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
-	done
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
@@ -462,12 +510,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
-	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -479,15 +522,11 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -496,9 +535,31 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscope: cscope.files
+	test ! -s cscope.files \
+	  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+	-rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
 
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
@@ -534,13 +595,10 @@ distdir: $(DISTFILES)
 	done
 	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
-	    test -d "$(distdir)/$$subdir" \
-	    || $(MKDIR_P) "$(distdir)/$$subdir" \
-	    || exit 1; \
-	  fi; \
-	done
-	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
+	    $(am__make_dryrun) \
+	      || test -d "$(distdir)/$$subdir" \
+	      || $(MKDIR_P) "$(distdir)/$$subdir" \
+	      || exit 1; \
 	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
 	    $(am__relativize); \
 	    new_distdir=$$reldir; \
@@ -569,40 +627,42 @@ distdir: $(DISTFILES)
 	|| chmod -R a+r "$(distdir)"
 dist-gzip: distdir
 	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-bzip2: distdir
 	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-lzip: distdir
 	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
-	$(am__remove_distdir)
-
-dist-lzma: distdir
-	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-xz: distdir
 	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
+	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-shar: distdir
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
 dist-zip: distdir
 	-rm -f $(distdir).zip
 	zip -rq $(distdir).zip $(distdir)
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 
-dist dist-all: distdir
-	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
-	$(am__remove_distdir)
+dist dist-all:
+	$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+	$(am__post_remove_distdir)
 
 # This target untars the dist file and tries a VPATH configuration.  Then
 # it guarantees that the distribution is self-contained by making another
@@ -613,8 +673,6 @@ distcheck: dist
 	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
 	*.tar.bz2*) \
 	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
-	*.tar.lzma*) \
-	  lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
 	*.tar.lz*) \
 	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
 	*.tar.xz*) \
@@ -626,18 +684,19 @@ distcheck: dist
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac
-	chmod -R a-w $(distdir); chmod a+w $(distdir)
-	mkdir $(distdir)/_build
-	mkdir $(distdir)/_inst
+	chmod -R a-w $(distdir)
+	chmod u+w $(distdir)
+	mkdir $(distdir)/_build $(distdir)/_inst
 	chmod a-w $(distdir)
 	test -d $(distdir)/_build || exit 0; \
 	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 	  && am__cwd=`pwd` \
 	  && $(am__cd) $(distdir)/_build \
-	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	  && ../configure \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
+	    --srcdir=.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -660,7 +719,7 @@ distcheck: dist
 	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
 	  && cd "$$am__cwd" \
 	  || exit 1
-	$(am__remove_distdir)
+	$(am__post_remove_distdir)
 	@(echo "$(distdir) archives ready for distribution: "; \
 	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
 	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
@@ -798,25 +857,24 @@ ps-am:
 
 uninstall-am: uninstall-pkgconfigDATA
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
-	ctags-recursive install-am install-strip tags-recursive
-
-.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
-	all all-am am--refresh check check-am clean clean-generic \
-	clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
-	dist-gzip dist-lzip dist-lzma dist-shar dist-tarZ dist-xz \
-	dist-zip distcheck distclean distclean-generic distclean-hdr \
-	distclean-libtool distclean-tags distcleancheck distdir \
-	distuninstallcheck dvi dvi-am html html-am info info-am \
-	install install-am install-data install-data-am install-dvi \
-	install-dvi-am install-exec install-exec-am install-html \
-	install-html-am install-info install-info-am install-man \
-	install-pdf install-pdf-am install-pkgconfigDATA install-ps \
-	install-ps-am install-strip installcheck installcheck-am \
-	installdirs installdirs-am maintainer-clean \
+.MAKE: $(am__recursive_targets) all install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+	am--refresh check check-am clean clean-cscope clean-generic \
+	clean-libtool cscope cscopelist-am ctags ctags-am dist \
+	dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
+	dist-xz dist-zip distcheck distclean distclean-generic \
+	distclean-hdr distclean-libtool distclean-tags distcleancheck \
+	distdir distuninstallcheck dvi dvi-am html html-am info \
+	info-am install install-am install-data install-data-am \
+	install-dvi install-dvi-am install-exec install-exec-am \
+	install-html install-html-am install-info install-info-am \
+	install-man install-pdf install-pdf-am install-pkgconfigDATA \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
-	uninstall uninstall-am uninstall-pkgconfigDATA
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+	uninstall-am uninstall-pkgconfigDATA
 
 
 ChangeLog: NEWS
diff --git a/NEWS b/NEWS
index 1d143a2..856c202 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+0.11 2014-06-xx
+  * now implements nodes like: Ref, Note, External
+  * several bug fixes
+  * better MT safe
+
 0.10
   * some XML stuff is moved to ticcutils
   * also use some other goodies form ticcutils
@@ -5,7 +10,7 @@
     (follwing the FoLiA 0.9 specs)
   * a lot of code improvement too, including some bug fixes
 
-0.9 
+0.9
   * lost in tranistion
 
 0.8 2012-03-29
@@ -24,7 +29,7 @@
   * 0.4 is lost in space
   * rather extensive rework. API and ABI changed.
     More to do, but releasing now is desirable
- 
+
 0.3 2011-11-02
 [Ko van der Sloot]
   * Get ready for first (beta) release as a package
diff --git a/aclocal.m4 b/aclocal.m4
index cef13c0..06cd71a 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,8 +1,7 @@
-# generated automatically by aclocal 1.11.3 -*- Autoconf -*-
+# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
-# Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -12,33 +11,31 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
-[m4_warning([this file was generated for autoconf 2.68.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
-To do so, use the procedure documented by the package, typically `autoreconf'.])])
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
-
 # AM_AUTOMAKE_VERSION(VERSION)
 # ----------------------------
 # Automake X.Y traces this macro to ensure aclocal.m4 has been
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.11'
+[am__api_version='1.14'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.11.3], [],
+m4_if([$1], [1.14.1], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -54,24 +51,22 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.11.3])dnl
+[AM_AUTOMAKE_VERSION([1.14.1])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
-
 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
-# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
-# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
 #
 # Of course, Automake must honor this variable whenever it calls a
 # tool from the auxiliary directory.  The problem is that $srcdir (and
@@ -90,7 +85,7 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 #
 # The reason of the latter failure is that $top_srcdir and $ac_aux_dir
 # are both prefixed by $srcdir.  In an in-source build this is usually
-# harmless because $srcdir is `.', but things will broke when you
+# harmless because $srcdir is '.', but things will broke when you
 # start a VPATH build or use an absolute $srcdir.
 #
 # So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
@@ -116,22 +111,19 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 9
-
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
 # Define a conditional.
 AC_DEFUN([AM_CONDITIONAL],
-[AC_PREREQ(2.52)dnl
- ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
 AC_SUBST([$1_TRUE])dnl
 AC_SUBST([$1_FALSE])dnl
 _AM_SUBST_NOTMAKE([$1_TRUE])dnl
@@ -150,16 +142,14 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009,
-# 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 12
 
-# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
 # will think it sees a *use*, and therefore will trigger all it's
 # C support machinery.  Also note that it means that autoscan, seeing
@@ -169,7 +159,7 @@ fi])])
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
 # We try a few techniques and use that to set a single cache variable.
 #
 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
@@ -182,12 +172,13 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
 AC_REQUIRE([AM_DEP_TRACK])dnl
 
-ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
-       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
-       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
-       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
-       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
-                   [depcc="$$1"   am_compiler_list=])
+m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
+      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
+      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
+      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                    [depcc="$$1"   am_compiler_list=])
 
 AC_CACHE_CHECK([dependency style of $depcc],
                [am_cv_$1_dependencies_compiler_type],
@@ -195,8 +186,8 @@ AC_CACHE_CHECK([dependency style of $depcc],
   # We make a subdir and do the tests there.  Otherwise we can end up
   # making bogus files that we don't know about and never remove.  For
   # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
   rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -236,16 +227,16 @@ AC_CACHE_CHECK([dependency style of $depcc],
     : > sub/conftest.c
     for i in 1 2 3 4 5 6; do
       echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
     # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
     am__obj=sub/conftest.${OBJEXT-o}
     am__minus_obj="-o $am__obj"
     case $depmode in
@@ -254,8 +245,8 @@ AC_CACHE_CHECK([dependency style of $depcc],
       test "$am__universal" = false || continue
       ;;
     nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
       if test "x$enable_dependency_tracking" = xyes; then
 	continue
       else
@@ -263,7 +254,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
       fi
       ;;
     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
+      # This compiler won't grok '-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
       am__obj=conftest.${OBJEXT-o}
@@ -311,7 +302,7 @@ AM_CONDITIONAL([am__fastdep$1], [
 # AM_SET_DEPDIR
 # -------------
 # Choose a directory name for dependency files.
-# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
 AC_DEFUN([AM_SET_DEPDIR],
 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
@@ -321,9 +312,13 @@ AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
 # AM_DEP_TRACK
 # ------------
 AC_DEFUN([AM_DEP_TRACK],
-[AC_ARG_ENABLE(dependency-tracking,
-[  --disable-dependency-tracking  speeds up one-time build
-  --enable-dependency-tracking   do not reject slow dependency extractors])
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+  [--enable-dependency-tracking],
+  [do not reject slow dependency extractors])
+AS_HELP_STRING(
+  [--disable-dependency-tracking],
+  [speeds up one-time build])])
 if test "x$enable_dependency_tracking" != xno; then
   am_depcomp="$ac_aux_dir/depcomp"
   AMDEPBACKSLASH='\'
@@ -338,20 +333,18 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-#serial 5
 
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 [{
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # Older Autoconf quotes --file arguments for eval, but not when files
   # are listed without --file.  Let's play safe and only enable the eval
   # if we detect the quoting.
   case $CONFIG_FILES in
@@ -364,7 +357,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
     # Strip MF so we end up with the name of the file.
     mf=`echo "$mf" | sed -e 's/:.*$//'`
     # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named `Makefile.in', but
+    # We used to match only the files named 'Makefile.in', but
     # some people rename them; so instead we look at the file content.
     # Grep'ing the first line is not enough: some people post-process
     # each Makefile.in and add a new line on top of each file to say so.
@@ -376,21 +369,19 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
       continue
     fi
     # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running `make'.
+    # from the Makefile without running 'make'.
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
+    test -z "$am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # When using ansi2knr, U may be empty or an underscore; expand it
-    U=`sed -n 's/^U = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the
     # simplest approach to changing $(DEPDIR) to its actual value in the
     # expansion.
     for file in `sed -n "
       s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
       # Make sure the directory exists.
       test -f "$dirpart/$file" && continue
       fdir=`AS_DIRNAME(["$file"])`
@@ -408,7 +399,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 # This macro should only be invoked once -- use via AC_REQUIRE.
 #
 # This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each `.P' file that we will
+# is enabled.  FIXME.  This creates each '.P' file that we will
 # need in order to bootstrap the dependency handling code.
 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 [AC_CONFIG_COMMANDS([depfiles],
@@ -418,18 +409,21 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 16
-
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
 
+dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
+m4_define([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[_AM_PROG_CC_C_O
+])
+
 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
 # AM_INIT_AUTOMAKE([OPTIONS])
 # -----------------------------------------------
@@ -442,7 +436,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 # arguments mandatory, and then we can depend on a new Autoconf
 # release and drop the old call support.
 AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.62])dnl
+[AC_PREREQ([2.65])dnl
 dnl Autoconf wants to disallow AM_ names.  We explicitly allow
 dnl the ones we care about.
 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
@@ -471,31 +465,40 @@ AC_SUBST([CYGPATH_W])
 # Define the identity of the package.
 dnl Distinguish between old-style and new-style calls.
 m4_ifval([$2],
-[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+[AC_DIAGNOSE([obsolete],
+             [$0: two- and three-arguments forms are deprecated.])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
  AC_SUBST([PACKAGE], [$1])dnl
  AC_SUBST([VERSION], [$2])],
 [_AM_SET_OPTIONS([$1])dnl
 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
-m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+m4_if(
+  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+  [ok:ok],,
   [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
  AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
  AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
 
 _AM_IF_OPTION([no-define],,
-[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
- AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
 
 # Some tools Automake needs.
 AC_REQUIRE([AM_SANITY_CHECK])dnl
 AC_REQUIRE([AC_ARG_PROGRAM])dnl
-AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
-AM_MISSING_PROG(AUTOCONF, autoconf)
-AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
-AM_MISSING_PROG(AUTOHEADER, autoheader)
-AM_MISSING_PROG(MAKEINFO, makeinfo)
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
 AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
 AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
-AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
@@ -506,34 +509,78 @@ _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
 			     [_AM_PROG_TAR([v7])])])
 _AM_IF_OPTION([no-dependencies],,
 [AC_PROVIDE_IFELSE([AC_PROG_CC],
-		  [_AM_DEPENDENCIES(CC)],
-		  [define([AC_PROG_CC],
-			  defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+		  [_AM_DEPENDENCIES([CC])],
+		  [m4_define([AC_PROG_CC],
+			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_CXX],
-		  [_AM_DEPENDENCIES(CXX)],
-		  [define([AC_PROG_CXX],
-			  defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+		  [_AM_DEPENDENCIES([CXX])],
+		  [m4_define([AC_PROG_CXX],
+			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_OBJC],
-		  [_AM_DEPENDENCIES(OBJC)],
-		  [define([AC_PROG_OBJC],
-			  defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+		  [_AM_DEPENDENCIES([OBJC])],
+		  [m4_define([AC_PROG_OBJC],
+			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+		  [_AM_DEPENDENCIES([OBJCXX])],
+		  [m4_define([AC_PROG_OBJCXX],
+			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
 ])
-_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
-dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
-dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
-dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
 AC_CONFIG_COMMANDS_PRE(dnl
 [m4_provide_if([_AM_COMPILER_EXEEXT],
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
-])
 
-dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes.  So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+  cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present.  This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake at gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message.  This
+can help us improve future automake versions.
+
+END
+  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+    echo 'Configuration will proceed anyway, since you have set the' >&2
+    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+    echo >&2
+  else
+    cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+  fi
+fi])
+
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
 dnl mangled by Autoconf and run in a shell conditional statement.
 m4_define([_AC_COMPILER_EXEEXT],
 m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
 
-
 # When config.status generates a header, we must update the stamp-h file.
 # This file resides in the same directory as the config header
 # that is generated.  The stamp files are numbered to have different names.
@@ -555,15 +602,12 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
-
 # AM_PROG_INSTALL_SH
 # ------------------
 # Define $install_sh.
@@ -577,16 +621,14 @@ if test x"${install_sh}" != xset; then
     install_sh="\${SHELL} $am_aux_dir/install-sh"
   esac
 fi
-AC_SUBST(install_sh)])
+AC_SUBST([install_sh])])
 
-# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2003-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 2
-
 # Check whether the underlying file-system supports filenames
 # with a leading dot.  For instance MS-DOS doesn't.
 AC_DEFUN([AM_SET_LEADING_DOT],
@@ -602,14 +644,12 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
-
 # AM_MAKE_INCLUDE()
 # -----------------
 # Check to see how make treats includes.
@@ -627,7 +667,7 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# Ignore all kinds of additional output from `make'.
+# Ignore all kinds of additional output from 'make'.
 case `$am_make -s -f confmf 2> /dev/null` in #(
 *the\ am__doit\ target*)
   am__include=include
@@ -654,15 +694,12 @@ rm -f confinc confmf
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 6
-
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
 AC_DEFUN([AM_MISSING_PROG],
@@ -670,11 +707,10 @@ AC_DEFUN([AM_MISSING_PROG],
 $1=${$1-"${am_missing_run}$2"}
 AC_SUBST($1)])
 
-
 # AM_MISSING_HAS_RUN
 # ------------------
-# Define MISSING if not defined so far and test if it supports --run.
-# If it does, set am_missing_run to use it, otherwise, to nothing.
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
 AC_DEFUN([AM_MISSING_HAS_RUN],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 AC_REQUIRE_AUX_FILE([missing])dnl
@@ -687,54 +723,22 @@ if test x"${MISSING+set}" != xset; then
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
 else
   am_missing_run=
-  AC_MSG_WARN([`missing' script is too old or missing])
+  AC_MSG_WARN(['missing' script is too old or missing])
 fi
 ])
 
-# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation,
-# Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 1
-
-# AM_PROG_MKDIR_P
-# ---------------
-# Check for `mkdir -p'.
-AC_DEFUN([AM_PROG_MKDIR_P],
-[AC_PREREQ([2.60])dnl
-AC_REQUIRE([AC_PROG_MKDIR_P])dnl
-dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
-dnl while keeping a definition of mkdir_p for backward compatibility.
-dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
-dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
-dnl Makefile.ins that do not define MKDIR_P, so we do our own
-dnl adjustment using top_builddir (which is defined more often than
-dnl MKDIR_P).
-AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
-case $mkdir_p in
-  [[\\/$]]* | ?:[[\\/]]*) ;;
-  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
-])
-
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 5
-
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
 AC_DEFUN([_AM_MANGLE_OPTION],
@@ -744,7 +748,7 @@ AC_DEFUN([_AM_MANGLE_OPTION],
 # --------------------
 # Set option NAME.  Presently that only means defining a flag for this option.
 AC_DEFUN([_AM_SET_OPTION],
-[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
 
 # _AM_SET_OPTIONS(OPTIONS)
 # ------------------------
@@ -758,24 +762,82 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_CC_C_O
+# ---------------
+# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
+# to automatically call this.
+AC_DEFUN([_AM_PROG_CC_C_O],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+AC_LANG_PUSH([C])dnl
+AC_CACHE_CHECK(
+  [whether $CC understands -c and -o together],
+  [am_cv_prog_cc_c_o],
+  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+  # Make sure it works both with $CC and with simple cc.
+  # Following AC_PROG_CC_C_O, we do the test twice because some
+  # compilers refuse to overwrite an existing .o file with -o,
+  # though they will create one.
+  am_cv_prog_cc_c_o=yes
+  for am_i in 1 2; do
+    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
+         && test -f conftest2.$ac_objext; then
+      : OK
+    else
+      am_cv_prog_cc_c_o=no
+      break
+    fi
+  done
+  rm -f core conftest*
+  unset am_i])
+if test "$am_cv_prog_cc_c_o" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+AC_LANG_POP([C])])
+
+# For backward compatibility.
+AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
-# Free Software Foundation, Inc.
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 5
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   (exit $ac_status); }])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
 # AM_SANITY_CHECK
 # ---------------
 AC_DEFUN([AM_SANITY_CHECK],
 [AC_MSG_CHECKING([whether build environment is sane])
-# Just in case
-sleep 1
-echo timestamp > conftest.file
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
@@ -786,32 +848,40 @@ case `pwd` in
 esac
 case $srcdir in
   *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
-    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
 esac
 
-# Do `set' in a subshell so we don't clobber the current shell's
+# Do 'set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-   if test "$[*]" = "X"; then
-      # -L didn't work.
-      set X `ls -t "$srcdir/configure" conftest.file`
-   fi
-   rm -f conftest.file
-   if test "$[*]" != "X $srcdir/configure conftest.file" \
-      && test "$[*]" != "X conftest.file $srcdir/configure"; then
-
-      # If neither matched, then we have a broken ls.  This can happen
-      # if, for instance, CONFIG_SHELL is bash and it inherits a
-      # broken ls alias from the environment.  This has actually
-      # happened.  Such a system could not be considered "sane".
-      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
-alias in your environment])
-   fi
-
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$[*]" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$[*]" != "X $srcdir/configure conftest.file" \
+	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment])
+     fi
+     if test "$[2]" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
    test "$[2]" = conftest.file
    )
 then
@@ -821,46 +891,118 @@ else
    AC_MSG_ERROR([newly created file is older than distributed files!
 Check your system clock])
 fi
-AC_MSG_RESULT(yes)])
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+  [AC_MSG_CHECKING([that generated files are newer than configure])
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
 
-# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+  [--enable-silent-rules],
+  [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+  [--disable-silent-rules],
+  [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+   [am_cv_make_support_nested_variables],
+   [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+  dnl Using '$V' instead of '$(V)' breaks IRIX make.
+  AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
 # AM_PROG_INSTALL_STRIP
 # ---------------------
-# One issue with vendor `install' (even GNU) is that you can't
+# One issue with vendor 'install' (even GNU) is that you can't
 # specify the program used to strip binaries.  This is especially
 # annoying in cross-compiling environments, where the build's strip
 # is unlikely to handle the host's binaries.
 # Fortunately install-sh will honor a STRIPPROG variable, so we
-# always use install-sh in `make install-strip', and initialize
+# always use install-sh in "make install-strip", and initialize
 # STRIPPROG with the value of the STRIP variable (set by the user).
 AC_DEFUN([AM_PROG_INSTALL_STRIP],
 [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
 # tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
 if test "$cross_compiling" != no; then
   AC_CHECK_TOOL([STRIP], [strip], :)
 fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 3
-
 # _AM_SUBST_NOTMAKE(VARIABLE)
 # ---------------------------
 # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
@@ -874,18 +1016,16 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2013 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 2
-
 # _AM_PROG_TAR(FORMAT)
 # --------------------
 # Check how to create a tarball in format FORMAT.
-# FORMAT should be one of `v7', `ustar', or `pax'.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
 #
 # Substitute a variable $(am__tar) that is a command
 # writing to stdout a FORMAT-tarball containing the directory
@@ -895,76 +1035,114 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 # Substitute a variable $(am__untar) that extract such
 # a tarball read from stdin.
 #     $(am__untar) < result.tar
+#
 AC_DEFUN([_AM_PROG_TAR],
 [# Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AC_SUBST([AMTAR], ['$${TAR-tar}'])
-m4_if([$1], [v7],
-     [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
-     [m4_case([$1], [ustar],, [pax],,
-              [m4_fatal([Unknown tar format])])
-AC_MSG_CHECKING([how to create a $1 tar archive])
-# Loop over all known methods to create a tar archive until one works.
+
+# We'll loop over all known methods to create a tar archive until one works.
 _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
-_am_tools=${am_cv_prog_tar_$1-$_am_tools}
-# Do not fold the above two line into one, because Tru64 sh and
-# Solaris sh will not grok spaces in the rhs of `-'.
-for _am_tool in $_am_tools
-do
-  case $_am_tool in
-  gnutar)
-    for _am_tar in tar gnutar gtar;
-    do
-      AM_RUN_LOG([$_am_tar --version]) && break
-    done
-    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
-    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
-    am__untar="$_am_tar -xf -"
-    ;;
-  plaintar)
-    # Must skip GNU tar: if it does not support --format= it doesn't create
-    # ustar tarball either.
-    (tar --version) >/dev/null 2>&1 && continue
-    am__tar='tar chf - "$$tardir"'
-    am__tar_='tar chf - "$tardir"'
-    am__untar='tar xf -'
-    ;;
-  pax)
-    am__tar='pax -L -x $1 -w "$$tardir"'
-    am__tar_='pax -L -x $1 -w "$tardir"'
-    am__untar='pax -r'
-    ;;
-  cpio)
-    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
-    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
-    am__untar='cpio -i -H $1 -d'
-    ;;
-  none)
-    am__tar=false
-    am__tar_=false
-    am__untar=false
-    ;;
-  esac
 
-  # If the value was cached, stop now.  We just wanted to have am__tar
-  # and am__untar set.
-  test -n "${am_cv_prog_tar_$1}" && break
+m4_if([$1], [v7],
+  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+
+  [m4_case([$1],
+    [ustar],
+     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+      # There is notably a 21 bits limit for the UID and the GID.  In fact,
+      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+      # and bug#13588).
+      am_max_uid=2097151 # 2^21 - 1
+      am_max_gid=$am_max_uid
+      # The $UID and $GID variables are not portable, so we need to resort
+      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
+      # below are definitely unexpected, so allow the users to see them
+      # (that is, avoid stderr redirection).
+      am_uid=`id -u || echo unknown`
+      am_gid=`id -g || echo unknown`
+      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+      if test $am_uid -le $am_max_uid; then
+         AC_MSG_RESULT([yes])
+      else
+         AC_MSG_RESULT([no])
+         _am_tools=none
+      fi
+      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+      if test $am_gid -le $am_max_gid; then
+         AC_MSG_RESULT([yes])
+      else
+        AC_MSG_RESULT([no])
+        _am_tools=none
+      fi],
+
+  [pax],
+    [],
+
+  [m4_fatal([Unknown tar format])])
+
+  AC_MSG_CHECKING([how to create a $1 tar archive])
+
+  # Go ahead even if we have the value already cached.  We do so because we
+  # need to set the values for the 'am__tar' and 'am__untar' variables.
+  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+
+  for _am_tool in $_am_tools; do
+    case $_am_tool in
+    gnutar)
+      for _am_tar in tar gnutar gtar; do
+        AM_RUN_LOG([$_am_tar --version]) && break
+      done
+      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+      am__untar="$_am_tar -xf -"
+      ;;
+    plaintar)
+      # Must skip GNU tar: if it does not support --format= it doesn't create
+      # ustar tarball either.
+      (tar --version) >/dev/null 2>&1 && continue
+      am__tar='tar chf - "$$tardir"'
+      am__tar_='tar chf - "$tardir"'
+      am__untar='tar xf -'
+      ;;
+    pax)
+      am__tar='pax -L -x $1 -w "$$tardir"'
+      am__tar_='pax -L -x $1 -w "$tardir"'
+      am__untar='pax -r'
+      ;;
+    cpio)
+      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+      am__untar='cpio -i -H $1 -d'
+      ;;
+    none)
+      am__tar=false
+      am__tar_=false
+      am__untar=false
+      ;;
+    esac
 
-  # tar/untar a dummy directory, and stop if the command works
-  rm -rf conftest.dir
-  mkdir conftest.dir
-  echo GrepMe > conftest.dir/file
-  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    # If the value was cached, stop now.  We just wanted to have am__tar
+    # and am__untar set.
+    test -n "${am_cv_prog_tar_$1}" && break
+
+    # tar/untar a dummy directory, and stop if the command works.
+    rm -rf conftest.dir
+    mkdir conftest.dir
+    echo GrepMe > conftest.dir/file
+    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    rm -rf conftest.dir
+    if test -s conftest.tar; then
+      AM_RUN_LOG([$am__untar <conftest.tar])
+      AM_RUN_LOG([cat conftest.dir/file])
+      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+    fi
+  done
   rm -rf conftest.dir
-  if test -s conftest.tar; then
-    AM_RUN_LOG([$am__untar <conftest.tar])
-    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
-  fi
-done
-rm -rf conftest.dir
 
-AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
-AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
 AC_SUBST([am__tar])
 AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
diff --git a/bootstrap b/bootstrap.sh
similarity index 97%
rename from bootstrap
rename to bootstrap.sh
index 395ae1f..5b0ae8a 100644
--- a/bootstrap
+++ b/bootstrap.sh
@@ -22,7 +22,7 @@ automake=automake
 aclocal=aclocal
 
 # if you want to autogenerate a ChangeLog form svn:
-# 
+#
 #  svn2cl, a python script, as used in the GNU Enterprise project.
 #    By jcater (Jason Cater), contributions by reinhard (Reinhard Müller).
 #    Get it from
@@ -46,7 +46,7 @@ aclocal=aclocal
    found=false
    for d in $acdirs
    do
-      if test -f ${d}ac_define_dir.m4
+      if test -f ${d}pkg.m4
       then
          found=true
          break
@@ -75,7 +75,7 @@ fi
 
 if $aclocal --version|head -1 |grep ' 1\.[4-8]'; then
     echo "aclocal 1.4-1.8 is active. You should use aclocal 1.9 or later"
-    if test -f /etc/debian_version; then	
+    if test -f /etc/debian_version; then
         echo " sudo apt-get install aclocal1.9"
         echo " sudo update-alternatives --config aclocal"
     fi
diff --git a/compile b/compile
new file mode 100755
index 0000000..531136b
--- /dev/null
+++ b/compile
@@ -0,0 +1,347 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand '-c -o'.
+
+scriptversion=2012-10-14.11; # UTC
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey at cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake at gnu.org> or send patches to
+# <automake-patches at gnu.org>.
+
+nl='
+'
+
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent tools from complaining about whitespace usage.
+IFS=" ""	$nl"
+
+file_conv=
+
+# func_file_conv build_file lazy
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts. If the determined conversion
+# type is listed in (the comma separated) LAZY, no conversion will
+# take place.
+func_file_conv ()
+{
+  file=$1
+  case $file in
+    / | /[!/]*) # absolute file, and not a UNC file
+      if test -z "$file_conv"; then
+	# lazily determine how to convert abs files
+	case `uname -s` in
+	  MINGW*)
+	    file_conv=mingw
+	    ;;
+	  CYGWIN*)
+	    file_conv=cygwin
+	    ;;
+	  *)
+	    file_conv=wine
+	    ;;
+	esac
+      fi
+      case $file_conv/,$2, in
+	*,$file_conv,*)
+	  ;;
+	mingw/*)
+	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+	  ;;
+	cygwin/*)
+	  file=`cygpath -m "$file" || echo "$file"`
+	  ;;
+	wine/*)
+	  file=`winepath -w "$file" || echo "$file"`
+	  ;;
+      esac
+      ;;
+  esac
+}
+
+# func_cl_dashL linkdir
+# Make cl look for libraries in LINKDIR
+func_cl_dashL ()
+{
+  func_file_conv "$1"
+  if test -z "$lib_path"; then
+    lib_path=$file
+  else
+    lib_path="$lib_path;$file"
+  fi
+  linker_opts="$linker_opts -LIBPATH:$file"
+}
+
+# func_cl_dashl library
+# Do a library search-path lookup for cl
+func_cl_dashl ()
+{
+  lib=$1
+  found=no
+  save_IFS=$IFS
+  IFS=';'
+  for dir in $lib_path $LIB
+  do
+    IFS=$save_IFS
+    if $shared && test -f "$dir/$lib.dll.lib"; then
+      found=yes
+      lib=$dir/$lib.dll.lib
+      break
+    fi
+    if test -f "$dir/$lib.lib"; then
+      found=yes
+      lib=$dir/$lib.lib
+      break
+    fi
+    if test -f "$dir/lib$lib.a"; then
+      found=yes
+      lib=$dir/lib$lib.a
+      break
+    fi
+  done
+  IFS=$save_IFS
+
+  if test "$found" != yes; then
+    lib=$lib.lib
+  fi
+}
+
+# func_cl_wrapper cl arg...
+# Adjust compile command to suit cl
+func_cl_wrapper ()
+{
+  # Assume a capable shell
+  lib_path=
+  shared=:
+  linker_opts=
+  for arg
+  do
+    if test -n "$eat"; then
+      eat=
+    else
+      case $1 in
+	-o)
+	  # configure might choose to run compile as 'compile cc -o foo foo.c'.
+	  eat=1
+	  case $2 in
+	    *.o | *.[oO][bB][jJ])
+	      func_file_conv "$2"
+	      set x "$@" -Fo"$file"
+	      shift
+	      ;;
+	    *)
+	      func_file_conv "$2"
+	      set x "$@" -Fe"$file"
+	      shift
+	      ;;
+	  esac
+	  ;;
+	-I)
+	  eat=1
+	  func_file_conv "$2" mingw
+	  set x "$@" -I"$file"
+	  shift
+	  ;;
+	-I*)
+	  func_file_conv "${1#-I}" mingw
+	  set x "$@" -I"$file"
+	  shift
+	  ;;
+	-l)
+	  eat=1
+	  func_cl_dashl "$2"
+	  set x "$@" "$lib"
+	  shift
+	  ;;
+	-l*)
+	  func_cl_dashl "${1#-l}"
+	  set x "$@" "$lib"
+	  shift
+	  ;;
+	-L)
+	  eat=1
+	  func_cl_dashL "$2"
+	  ;;
+	-L*)
+	  func_cl_dashL "${1#-L}"
+	  ;;
+	-static)
+	  shared=false
+	  ;;
+	-Wl,*)
+	  arg=${1#-Wl,}
+	  save_ifs="$IFS"; IFS=','
+	  for flag in $arg; do
+	    IFS="$save_ifs"
+	    linker_opts="$linker_opts $flag"
+	  done
+	  IFS="$save_ifs"
+	  ;;
+	-Xlinker)
+	  eat=1
+	  linker_opts="$linker_opts $2"
+	  ;;
+	-*)
+	  set x "$@" "$1"
+	  shift
+	  ;;
+	*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
+	  func_file_conv "$1"
+	  set x "$@" -Tp"$file"
+	  shift
+	  ;;
+	*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
+	  func_file_conv "$1" mingw
+	  set x "$@" "$file"
+	  shift
+	  ;;
+	*)
+	  set x "$@" "$1"
+	  shift
+	  ;;
+      esac
+    fi
+    shift
+  done
+  if test -n "$linker_opts"; then
+    linker_opts="-link$linker_opts"
+  fi
+  exec "$@" $linker_opts
+  exit 1
+}
+
+eat=
+
+case $1 in
+  '')
+     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand '-c -o'.
+Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file 'INSTALL'.
+
+Report bugs to <bug-automake at gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "compile $scriptversion"
+    exit $?
+    ;;
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+    func_cl_wrapper "$@"      # Doesn't return...
+    ;;
+esac
+
+ofile=
+cfile=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+	# configure might choose to run compile as 'compile cc -o foo foo.c'.
+	# So we strip '-o arg' only if arg is an object.
+	eat=1
+	case $2 in
+	  *.o | *.obj)
+	    ofile=$2
+	    ;;
+	  *)
+	    set x "$@" -o "$2"
+	    shift
+	    ;;
+	esac
+	;;
+      *.c)
+	cfile=$1
+	set x "$@" "$1"
+	shift
+	;;
+      *)
+	set x "$@" "$1"
+	shift
+	;;
+    esac
+  fi
+  shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+  # If no '-o' option was seen then we might have been invoked from a
+  # pattern rule where we don't need one.  That is ok -- this is a
+  # normal compilation that the losing compiler can handle.  If no
+  # '.c' file was seen then we are probably linking.  That is also
+  # ok.
+  exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use '[/\\:.-]' here to ensure that we don't use the same name
+# that we are using for the .o file.  Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
+while true; do
+  if mkdir "$lockdir" >/dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+  test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/config.guess b/config.guess
index d622a44..b79252d 100755
--- a/config.guess
+++ b/config.guess
@@ -1,14 +1,12 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011, 2012 Free Software Foundation, Inc.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2012-02-10'
+timestamp='2013-06-10'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -22,19 +20,17 @@ timestamp='2012-02-10'
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner.  Please send patches (context
-# diff format) to <config-patches at gnu.org> and include a ChangeLog
-# entry.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
 #
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
+# Originally written by Per Bothner.
 #
 # You can get the latest version of this script from:
 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+
 
 me=`echo "$0" | sed -e 's,.*/,,'`
 
@@ -54,9 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright 1992-2013 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -138,6 +132,27 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+	# If the system lacks a compiler, then just pick glibc.
+	# We could probably try harder.
+	LIBC=gnu
+
+	eval $set_cc_for_build
+	cat <<-EOF > $dummy.c
+	#include <features.h>
+	#if defined(__UCLIBC__)
+	LIBC=uclibc
+	#elif defined(__dietlibc__)
+	LIBC=dietlibc
+	#else
+	LIBC=gnu
+	#endif
+	EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	;;
+esac
+
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
@@ -200,6 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
 	echo "${machine}-${os}${release}"
 	exit ;;
+    *:Bitrig:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+	exit ;;
     *:OpenBSD:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
 	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
@@ -302,7 +321,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit ;;
-    arm:riscos:*:*|arm:RISCOS:*:*)
+    arm*:riscos:*:*|arm*:RISCOS:*:*)
 	echo arm-unknown-riscos
 	exit ;;
     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@@ -801,6 +820,9 @@ EOF
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
 	exit ;;
+    *:MINGW64*:*)
+	echo ${UNAME_MACHINE}-pc-mingw64
+	exit ;;
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
@@ -852,21 +874,21 @@ EOF
 	exit ;;
     *:GNU:*:*)
 	# the GNU system
-	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 	exit ;;
     *:GNU/*:*:*)
 	# other systems with GNU libc and userland
-	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
 	exit ;;
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
     aarch64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     aarch64_be:Linux:*:*)
 	UNAME_MACHINE=aarch64_be
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     alpha:Linux:*:*)
 	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -879,59 +901,54 @@ EOF
 	  EV68*) UNAME_MACHINE=alphaev68 ;;
 	esac
 	objdump --private-headers /bin/sh | grep -q ld.so.1
-	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    arc:Linux:*:* | arceb:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     arm*:Linux:*:*)
 	eval $set_cc_for_build
 	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
 	    | grep -q __ARM_EABI__
 	then
-	    echo ${UNAME_MACHINE}-unknown-linux-gnu
+	    echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	else
 	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
 		| grep -q __ARM_PCS_VFP
 	    then
-		echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
 	    else
-		echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
+		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
 	    fi
 	fi
 	exit ;;
     avr32*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     cris:Linux:*:*)
-	echo ${UNAME_MACHINE}-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
     crisv32:Linux:*:*)
-	echo ${UNAME_MACHINE}-axis-linux-gnu
+	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 	exit ;;
     frv:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     hexagon:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     i*86:Linux:*:*)
-	LIBC=gnu
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#ifdef __dietlibc__
-	LIBC=dietlibc
-	#endif
-EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
-	echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
 	exit ;;
     ia64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     m32r*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     m68*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     mips:Linux:*:* | mips64:Linux:*:*)
 	eval $set_cc_for_build
@@ -950,54 +967,63 @@ EOF
 	#endif
 EOF
 	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
-	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 	;;
+    or1k:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
     or32:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     padre:Linux:*:*)
-	echo sparc-unknown-linux-gnu
+	echo sparc-unknown-linux-${LIBC}
 	exit ;;
     parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-unknown-linux-gnu
+	echo hppa64-unknown-linux-${LIBC}
 	exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
 	# Look for CPU level
 	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
-	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
-	  *)    echo hppa-unknown-linux-gnu ;;
+	  PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+	  PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+	  *)    echo hppa-unknown-linux-${LIBC} ;;
 	esac
 	exit ;;
     ppc64:Linux:*:*)
-	echo powerpc64-unknown-linux-gnu
+	echo powerpc64-unknown-linux-${LIBC}
 	exit ;;
     ppc:Linux:*:*)
-	echo powerpc-unknown-linux-gnu
+	echo powerpc-unknown-linux-${LIBC}
+	exit ;;
+    ppc64le:Linux:*:*)
+	echo powerpc64le-unknown-linux-${LIBC}
+	exit ;;
+    ppcle:Linux:*:*)
+	echo powerpcle-unknown-linux-${LIBC}
 	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
-	echo ${UNAME_MACHINE}-ibm-linux
+	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
 	exit ;;
     sh64*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     sh*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     tile*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     vax:Linux:*:*)
-	echo ${UNAME_MACHINE}-dec-linux-gnu
+	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 	exit ;;
     x86_64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     xtensa*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 	exit ;;
     i*86:DYNIX/ptx:4*:*)
 	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1201,6 +1227,9 @@ EOF
     BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
 	echo i586-pc-haiku
 	exit ;;
+    x86_64:Haiku:*:*)
+	echo x86_64-unknown-haiku
+	exit ;;
     SX-4:SUPER-UX:*:*)
 	echo sx4-nec-superux${UNAME_RELEASE}
 	exit ;;
@@ -1227,19 +1256,21 @@ EOF
 	exit ;;
     *:Darwin:*:*)
 	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-	case $UNAME_PROCESSOR in
-	    i386)
-		eval $set_cc_for_build
-		if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-		  if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		      (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-		      grep IS_64BIT_ARCH >/dev/null
-		  then
-		      UNAME_PROCESSOR="x86_64"
-		  fi
-		fi ;;
-	    unknown) UNAME_PROCESSOR=powerpc ;;
-	esac
+	eval $set_cc_for_build
+	if test "$UNAME_PROCESSOR" = unknown ; then
+	    UNAME_PROCESSOR=powerpc
+	fi
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		case $UNAME_PROCESSOR in
+		    i386) UNAME_PROCESSOR=x86_64 ;;
+		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
+		esac
+	    fi
+	fi
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
@@ -1256,7 +1287,7 @@ EOF
     NEO-?:NONSTOP_KERNEL:*:*)
 	echo neo-tandem-nsk${UNAME_RELEASE}
 	exit ;;
-    NSE-?:NONSTOP_KERNEL:*:*)
+    NSE-*:NONSTOP_KERNEL:*:*)
 	echo nse-tandem-nsk${UNAME_RELEASE}
 	exit ;;
     NSR-?:NONSTOP_KERNEL:*:*)
@@ -1330,9 +1361,6 @@ EOF
 	exit ;;
 esac
 
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
 eval $set_cc_for_build
 cat >$dummy.c <<EOF
 #ifdef _SEQUENT_
diff --git a/config.h.in b/config.h.in
index 9bffbfb..1fecbed 100644
--- a/config.h.in
+++ b/config.h.in
@@ -9,6 +9,9 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
+/* Define to 1 if you have the `localtime_r' function. */
+#undef HAVE_LOCALTIME_R
+
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
diff --git a/config.sub b/config.sub
index c894da4..9633db7 100755
--- a/config.sub
+++ b/config.sub
@@ -1,24 +1,18 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011, 2012 Free Software Foundation, Inc.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2012-02-10'
+timestamp='2013-08-10'
 
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
@@ -26,11 +20,12 @@ timestamp='2012-02-10'
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
 # configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
+# the same distribution terms that you use for the rest of that
+# program.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
 
 
-# Please send patches to <config-patches at gnu.org>.  Submit a context
-# diff and a properly formatted GNU ChangeLog entry.
+# Please send patches with a ChangeLog entry to config-patches at gnu.org.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
@@ -73,9 +68,7 @@ Report bugs and patches to <config-patches at gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-Free Software Foundation, Inc.
+Copyright 1992-2013 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -123,7 +116,7 @@ esac
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
-  linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
   knetbsd*-gnu* | netbsd*-gnu* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
@@ -156,7 +149,7 @@ case $os in
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis | -knuth | -cray | -microblaze)
+	-apple | -axis | -knuth | -cray | -microblaze*)
 		os=
 		basic_machine=$1
 		;;
@@ -225,6 +218,12 @@ case $os in
 	-isc*)
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
+	-lynx*178)
+		os=-lynxos178
+		;;
+	-lynx*5)
+		os=-lynxos5
+		;;
 	-lynx*)
 		os=-lynxos
 		;;
@@ -253,10 +252,12 @@ case $basic_machine in
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
-        | be32 | be64 \
+	| arc | arceb \
+	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+	| avr | avr32 \
+	| be32 | be64 \
 	| bfin \
-	| c4x | clipper \
+	| c4x | c8051 | clipper \
 	| d10v | d30v | dlx | dsp16xx \
 	| epiphany \
 	| fido | fr30 | frv \
@@ -267,7 +268,7 @@ case $basic_machine in
 	| le32 | le64 \
 	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-	| maxq | mb | microblaze | mcore | mep | metag \
+	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -285,16 +286,17 @@ case $basic_machine in
 	| mipsisa64r2 | mipsisa64r2el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipsr5900 | mipsr5900el \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
 	| moxie \
 	| mt \
 	| msp430 \
 	| nds32 | nds32le | nds32be \
-	| nios | nios2 \
+	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
 	| open8 \
-	| or32 \
+	| or1k | or32 \
 	| pdp10 | pdp11 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
@@ -364,13 +366,13 @@ case $basic_machine in
 	| aarch64-* | aarch64_be-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
 	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
-	| clipper-* | craynv-* | cydra-* \
+	| c8051-* | clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
@@ -383,7 +385,8 @@ case $basic_machine in
 	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+	| microblaze-* | microblazeel-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
@@ -401,12 +404,13 @@ case $basic_machine in
 	| mipsisa64r2-* | mipsisa64r2el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipsr5900-* | mipsr5900el-* \
 	| mipstx39-* | mipstx39el-* \
 	| mmix-* \
 	| mt-* \
 	| msp430-* \
 	| nds32-* | nds32le-* | nds32be-* \
-	| nios-* | nios2-* \
+	| nios-* | nios2-* | nios2eb-* | nios2el-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| open8-* \
 	| orion-* \
@@ -782,11 +786,15 @@ case $basic_machine in
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
-	microblaze)
+	microblaze*)
 		basic_machine=microblaze-xilinx
 		;;
+	mingw64)
+		basic_machine=x86_64-pc
+		os=-mingw64
+		;;
 	mingw32)
-		basic_machine=i386-pc
+		basic_machine=i686-pc
 		os=-mingw32
 		;;
 	mingw32ce)
@@ -822,7 +830,7 @@ case $basic_machine in
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
 	msys)
-		basic_machine=i386-pc
+		basic_machine=i686-pc
 		os=-msys
 		;;
 	mvs)
@@ -1013,7 +1021,11 @@ case $basic_machine in
 		basic_machine=i586-unknown
 		os=-pw32
 		;;
-	rdos)
+	rdos | rdos64)
+		basic_machine=x86_64-pc
+		os=-rdos
+		;;
+	rdos32)
 		basic_machine=i386-pc
 		os=-rdos
 		;;
@@ -1340,21 +1352,21 @@ case $os in
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
 	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
-	      | -sym* | -kopensolaris* \
+	      | -sym* | -kopensolaris* | -plan9* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
 	      | -aos* | -aros* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-	      | -openbsd* | -solidbsd* \
+	      | -bitrig* | -openbsd* | -solidbsd* \
 	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-android* \
-	      | -linux-newlib* | -linux-uclibc* \
+	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@@ -1486,9 +1498,6 @@ case $os in
 	-aros*)
 		os=-aros
 		;;
-	-kaos*)
-		os=-kaos
-		;;
 	-zvmoe)
 		os=-zvmoe
 		;;
@@ -1537,6 +1546,12 @@ case $basic_machine in
 	c4x-* | tic4x-*)
 		os=-coff
 		;;
+	c8051-*)
+		os=-elf
+		;;
+	hexagon-*)
+		os=-elf
+		;;
 	tic54x-*)
 		os=-coff
 		;;
@@ -1577,6 +1592,9 @@ case $basic_machine in
 	mips*-*)
 		os=-elf
 		;;
+	or1k-*)
+		os=-elf
+		;;
 	or32-*)
 		os=-coff
 		;;
diff --git a/configure b/configure
index 92f7ab1..38f8ae7 100755
--- a/configure
+++ b/configure
@@ -1,13 +1,11 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for libfolia 0.10.
+# Generated by GNU Autoconf 2.69 for libfolia 0.11.
 #
 # Report bugs to <timbl at uvt.nl>.
 #
 #
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -136,6 +134,31 @@ export LANGUAGE
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
@@ -169,7 +192,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -222,21 +246,25 @@ IFS=$as_save_IFS
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-	# neutralization value for shells without unset; and this also
-	# works around shells that cannot unset nonexistent variables.
-	# Preserve -v and -x to the replacement shell.
-	BASH_ENV=/dev/null
-	ENV=/dev/null
-	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-	export CONFIG_SHELL
-	case $- in # ((((
-	  *v*x* | *x*v* ) as_opts=-vx ;;
-	  *v* ) as_opts=-v ;;
-	  *x* ) as_opts=-x ;;
-	  * ) as_opts= ;;
-	esac
-	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
 fi
 
     if test x$as_have_required = xno; then :
@@ -338,6 +366,14 @@ $as_echo X"$as_dir" |
 
 
 } # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -459,6 +495,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
   chmod +x "$as_me.lineno" ||
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -493,16 +533,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -514,28 +554,8 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -569,8 +589,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='libfolia'
 PACKAGE_TARNAME='libfolia'
-PACKAGE_VERSION='0.10'
-PACKAGE_STRING='libfolia 0.10'
+PACKAGE_VERSION='0.11'
+PACKAGE_STRING='libfolia 0.11'
 PACKAGE_BUGREPORT='timbl at uvt.nl'
 PACKAGE_URL=''
 
@@ -630,7 +650,6 @@ XML2_CFLAGS
 PKG_CONFIG_LIBDIR
 PKG_CONFIG_PATH
 PKG_CONFIG
-LIBTOOL_DEPS
 CXXCPP
 CPP
 OTOOL64
@@ -639,6 +658,7 @@ LIPO
 NMEDIT
 DSYMUTIL
 MANIFEST_TOOL
+RANLIB
 ac_ct_AR
 AR
 DLLTOOL
@@ -667,7 +687,6 @@ build_vendor
 build_cpu
 build
 LIBTOOL
-RANLIB
 am__fastdepCXX_FALSE
 am__fastdepCXX_TRUE
 CXXDEPMODE
@@ -685,6 +704,10 @@ CPPFLAGS
 LDFLAGS
 CXXFLAGS
 CXX
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
 am__untar
 am__tar
 AMTAR
@@ -749,6 +772,7 @@ SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
+enable_silent_rules
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1235,8 +1259,6 @@ target=$target_alias
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1322,7 +1344,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libfolia 0.10 to adapt to many kinds of systems.
+\`configure' configures libfolia 0.11 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1392,7 +1414,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libfolia 0.10:";;
+     short | recursive ) echo "Configuration of libfolia 0.11:";;
    esac
   cat <<\_ACEOF
 
@@ -1400,8 +1422,12 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --disable-dependency-tracking  speeds up one-time build
-  --enable-dependency-tracking   do not reject slow dependency extractors
+  --enable-silent-rules   less verbose build output (undo: "make V=1")
+  --disable-silent-rules  verbose build output (undo: "make V=0")
+  --enable-dependency-tracking
+                          do not reject slow dependency extractors
+  --disable-dependency-tracking
+                          speeds up one-time build
   --enable-shared[=PKGS]  build shared libraries [default=yes]
   --enable-static[=PKGS]  build static libraries [default=yes]
   --enable-fast-install[=PKGS]
@@ -1511,10 +1537,10 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libfolia configure 0.10
-generated by GNU Autoconf 2.68
+libfolia configure 0.11
+generated by GNU Autoconf 2.69
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1628,7 +1654,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1888,7 +1914,7 @@ $as_echo "$ac_try_echo"; } >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1960,12 +1986,79 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_cxx_check_type
+
+# ac_fn_cxx_check_func LINENO FUNC VAR
+# ------------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_cxx_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_cxx_check_func
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libfolia $as_me 0.10, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+It was created by libfolia $as_me 0.11, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 
@@ -2312,7 +2405,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-am__api_version='1.11'
+am__api_version='1.14'
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@@ -2380,7 +2473,7 @@ case $as_dir/ in #((
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
 	  if test $ac_prog = install &&
 	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
@@ -2438,9 +2531,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
 $as_echo_n "checking whether build environment is sane... " >&6; }
-# Just in case
-sleep 1
-echo timestamp > conftest.file
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
@@ -2451,32 +2541,40 @@ case `pwd` in
 esac
 case $srcdir in
   *[\\\"\#\$\&\'\`$am_lf\ \	]*)
-    as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+    as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
 esac
 
-# Do `set' in a subshell so we don't clobber the current shell's
+# Do 'set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-   if test "$*" = "X"; then
-      # -L didn't work.
-      set X `ls -t "$srcdir/configure" conftest.file`
-   fi
-   rm -f conftest.file
-   if test "$*" != "X $srcdir/configure conftest.file" \
-      && test "$*" != "X conftest.file $srcdir/configure"; then
-
-      # If neither matched, then we have a broken ls.  This can happen
-      # if, for instance, CONFIG_SHELL is bash and it inherits a
-      # broken ls alias from the environment.  This has actually
-      # happened.  Such a system could not be considered "sane".
-      as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
-alias in your environment" "$LINENO" 5
-   fi
-
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$*" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$*" != "X $srcdir/configure conftest.file" \
+	&& test "$*" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment" "$LINENO" 5
+     fi
+     if test "$2" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
    test "$2" = conftest.file
    )
 then
@@ -2488,6 +2586,16 @@ Check your system clock" "$LINENO" 5
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+
+rm -f conftest.file
+
 test "$program_prefix" != NONE &&
   program_transform_name="s&^&$program_prefix&;$program_transform_name"
 # Use a double $ so make ignores it.
@@ -2510,12 +2618,12 @@ if test x"${MISSING+set}" != xset; then
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
-  am_missing_run="$MISSING --run "
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
 else
   am_missing_run=
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
-$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
 fi
 
 if test x"${install_sh}" != xset; then
@@ -2527,10 +2635,10 @@ if test x"${install_sh}" != xset; then
   esac
 fi
 
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'.  However `strip' might not be the right
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
 # tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
+# will honor the 'STRIP' environment variable to overrule this program.
 if test "$cross_compiling" != no; then
   if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
@@ -2549,7 +2657,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_STRIP="${ac_tool_prefix}strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2589,7 +2697,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_STRIP="strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2640,7 +2748,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_prog in mkdir gmkdir; do
 	 for ac_exec_ext in '' $ac_executable_extensions; do
-	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
 	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
 	     'mkdir (GNU coreutils) '* | \
 	     'mkdir (coreutils) '* | \
@@ -2669,12 +2777,6 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
 $as_echo "$MKDIR_P" >&6; }
 
-mkdir_p="$MKDIR_P"
-case $mkdir_p in
-  [\\/$]* | ?:[\\/]*) ;;
-  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
-esac
-
 for ac_prog in gawk mawk nawk awk
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -2693,7 +2795,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AWK="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2757,6 +2859,45 @@ else
 fi
 rmdir .tst 2>/dev/null
 
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=1;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+    AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
 if test "`cd $srcdir && pwd`" != "`pwd`"; then
   # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
   # is not polluted with repeated "-I."
@@ -2779,7 +2920,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libfolia'
- VERSION='0.10'
+ VERSION='0.11'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2807,12 +2948,22 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
 
 MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+mkdir_p='$(MKDIR_P)'
+
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
 # Always define AMTAR for backward compatibility.  Yes, it's still used
 # in the wild :-(  We should find a proper way to deprecate it ...
 AMTAR='$${TAR-tar}'
 
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar  pax cpio none'
+
 am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
@@ -2820,6 +2971,48 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes.  So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+  cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present.  This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake at gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message.  This
+can help us improve future automake versions.
+
+END
+  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+    echo 'Configuration will proceed anyway, since you have set the' >&2
+    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+    echo >&2
+  else
+    cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+    as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
+  fi
+fi
+
 
 ac_config_headers="$ac_config_headers config.h"
 
@@ -2860,7 +3053,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2904,7 +3097,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CXX="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3357,7 +3550,7 @@ am__quote=
 _am_result=none
 # First try GNU make style include.
 echo "include confinc" > confmf
-# Ignore all kinds of additional output from `make'.
+# Ignore all kinds of additional output from 'make'.
 case `$am_make -s -f confmf 2> /dev/null` in #(
 *the\ am__doit\ target*)
   am__include=include
@@ -3413,8 +3606,8 @@ else
   # We make a subdir and do the tests there.  Otherwise we can end up
   # making bogus files that we don't know about and never remove.  For
   # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
   rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -3449,16 +3642,16 @@ else
     : > sub/conftest.c
     for i in 1 2 3 4 5 6; do
       echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
     # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
     am__obj=sub/conftest.${OBJEXT-o}
     am__minus_obj="-o $am__obj"
     case $depmode in
@@ -3467,8 +3660,8 @@ else
       test "$am__universal" = false || continue
       ;;
     nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
       if test "x$enable_dependency_tracking" = xyes; then
 	continue
       else
@@ -3476,7 +3669,7 @@ else
       fi
       ;;
     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
+      # This compiler won't grok '-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
       am__obj=conftest.${OBJEXT-o}
@@ -3535,98 +3728,6 @@ if $cxx_flags_were_set; then
   CXXFLAGS=$CXXFLAGS
 fi
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_RANLIB" = x; then
-    RANLIB=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    RANLIB=$ac_ct_RANLIB
-  fi
-else
-  RANLIB="$ac_cv_prog_RANLIB"
-fi
-
 # use libtool
 case `pwd` in
   *\ * | *\	*)
@@ -3815,7 +3916,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3855,7 +3956,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3908,7 +4009,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3949,7 +4050,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
@@ -4007,7 +4108,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4051,7 +4152,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4247,8 +4348,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -4333,6 +4433,65 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
+$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
+if ${am_cv_prog_cc_c_o+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+  # Make sure it works both with $CC and with simple cc.
+  # Following AC_PROG_CC_C_O, we do the test twice because some
+  # compilers refuse to overwrite an existing .o file with -o,
+  # though they will create one.
+  am_cv_prog_cc_c_o=yes
+  for am_i in 1 2; do
+    if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
+   ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); } \
+         && test -f conftest2.$ac_objext; then
+      : OK
+    else
+      am_cv_prog_cc_c_o=no
+      break
+    fi
+  done
+  rm -f core conftest*
+  unset am_i
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+$as_echo "$am_cv_prog_cc_c_o" >&6; }
+if test "$am_cv_prog_cc_c_o" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
 depcc="$CC"   am_compiler_list=
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
@@ -4344,8 +4503,8 @@ else
   # We make a subdir and do the tests there.  Otherwise we can end up
   # making bogus files that we don't know about and never remove.  For
   # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
   rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -4380,16 +4539,16 @@ else
     : > sub/conftest.c
     for i in 1 2 3 4 5 6; do
       echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
     done
     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
     # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
     am__obj=sub/conftest.${OBJEXT-o}
     am__minus_obj="-o $am__obj"
     case $depmode in
@@ -4398,8 +4557,8 @@ else
       test "$am__universal" = false || continue
       ;;
     nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
       if test "x$enable_dependency_tracking" = xyes; then
 	continue
       else
@@ -4407,7 +4566,7 @@ else
       fi
       ;;
     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok `-c -o', but also, the minuso test has
+      # This compiler won't grok '-c -o', but also, the minuso test has
       # not run yet.  These depmodes are late enough in the game, and
       # so weak that their functioning should not be impacted.
       am__obj=conftest.${OBJEXT-o}
@@ -4483,7 +4642,7 @@ do
     for ac_prog in sed gsed; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+      as_fn_executable_p "$ac_path_SED" || continue
 # Check for GNU ac_path_SED and select it if it is found.
   # Check for GNU $ac_path_SED
 case `"$ac_path_SED" --version 2>&1` in
@@ -4559,7 +4718,7 @@ do
     for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+      as_fn_executable_p "$ac_path_GREP" || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
@@ -4625,7 +4784,7 @@ do
     for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+      as_fn_executable_p "$ac_path_EGREP" || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -4692,7 +4851,7 @@ do
     for ac_prog in fgrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
+      as_fn_executable_p "$ac_path_FGREP" || continue
 # Check for GNU ac_path_FGREP and select it if it is found.
   # Check for GNU $ac_path_FGREP
 case `"$ac_path_FGREP" --version 2>&1` in
@@ -4948,7 +5107,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4992,7 +5151,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5411,7 +5570,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5451,7 +5610,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OBJDUMP="objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5757,7 +5916,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5797,7 +5956,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DLLTOOL="dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5901,7 +6060,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5945,7 +6104,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6070,7 +6229,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_STRIP="${ac_tool_prefix}strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6110,7 +6269,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_STRIP="strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6169,7 +6328,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6209,7 +6368,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_RANLIB="ranlib"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6844,7 +7003,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6884,7 +7043,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6964,7 +7123,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7004,7 +7163,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7056,7 +7215,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7096,7 +7255,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_NMEDIT="nmedit"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7148,7 +7307,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7188,7 +7347,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_LIPO="lipo"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7240,7 +7399,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7280,7 +7439,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OTOOL="otool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7332,7 +7491,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7372,7 +7531,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OTOOL64="otool64"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15081,60 +15240,60 @@ else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-#include <stdbool.h>
-#ifndef bool
- "error: bool is not defined"
-#endif
-#ifndef false
- "error: false is not defined"
-#endif
-#if false
- "error: false is not 0"
-#endif
-#ifndef true
- "error: true is not defined"
-#endif
-#if true != 1
- "error: true is not 1"
-#endif
-#ifndef __bool_true_false_are_defined
- "error: __bool_true_false_are_defined is not defined"
-#endif
-
-	struct s { _Bool s: 1; _Bool t; } s;
-
-	char a[true == 1 ? 1 : -1];
-	char b[false == 0 ? 1 : -1];
-	char c[__bool_true_false_are_defined == 1 ? 1 : -1];
-	char d[(bool) 0.5 == true ? 1 : -1];
-	/* See body of main program for 'e'.  */
-	char f[(_Bool) 0.0 == false ? 1 : -1];
-	char g[true];
-	char h[sizeof (_Bool)];
-	char i[sizeof s.t];
-	enum { j = false, k = true, l = false * true, m = true * 256 };
-	/* The following fails for
-	   HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
-	_Bool n[m];
-	char o[sizeof n == m * sizeof n[0] ? 1 : -1];
-	char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
-	/* Catch a bug in an HP-UX C compiler.  See
-	   http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
-	   http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
-	 */
-	_Bool q = true;
-	_Bool *pq = &q;
+             #include <stdbool.h>
+             #ifndef bool
+              "error: bool is not defined"
+             #endif
+             #ifndef false
+              "error: false is not defined"
+             #endif
+             #if false
+              "error: false is not 0"
+             #endif
+             #ifndef true
+              "error: true is not defined"
+             #endif
+             #if true != 1
+              "error: true is not 1"
+             #endif
+             #ifndef __bool_true_false_are_defined
+              "error: __bool_true_false_are_defined is not defined"
+             #endif
+
+             struct s { _Bool s: 1; _Bool t; } s;
+
+             char a[true == 1 ? 1 : -1];
+             char b[false == 0 ? 1 : -1];
+             char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+             char d[(bool) 0.5 == true ? 1 : -1];
+             /* See body of main program for 'e'.  */
+             char f[(_Bool) 0.0 == false ? 1 : -1];
+             char g[true];
+             char h[sizeof (_Bool)];
+             char i[sizeof s.t];
+             enum { j = false, k = true, l = false * true, m = true * 256 };
+             /* The following fails for
+                HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+             _Bool n[m];
+             char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+             char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+             /* Catch a bug in an HP-UX C compiler.  See
+                http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+                http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+              */
+             _Bool q = true;
+             _Bool *pq = &q;
 
 int
 main ()
 {
 
-	bool e = &s;
-	*pq |= q;
-	*pq |= ! q;
-	/* Refer to every declared value, to avoid compiler optimizations.  */
-	return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
-		+ !m + !n + !o + !p + !q + !pq);
+             bool e = &s;
+             *pq |= q;
+             *pq |= ! q;
+             /* Refer to every declared value, to avoid compiler optimizations.  */
+             return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+                     + !m + !n + !o + !p + !q + !pq);
 
   ;
   return 0;
@@ -15149,7 +15308,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
 $as_echo "$ac_cv_header_stdbool_h" >&6; }
-ac_fn_cxx_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
+   ac_fn_cxx_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
 if test "x$ac_cv_type__Bool" = xyes; then :
 
 cat >>confdefs.h <<_ACEOF
@@ -15159,6 +15318,7 @@ _ACEOF
 
 fi
 
+
 if test $ac_cv_header_stdbool_h = yes; then
 
 $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
@@ -15220,6 +15380,17 @@ fi
 
 
 # Checks for library functions.
+for ac_func in localtime_r
+do :
+  ac_fn_cxx_check_func "$LINENO" "localtime_r" "ac_cv_func_localtime_r"
+if test "x$ac_cv_func_localtime_r" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LOCALTIME_R 1
+_ACEOF
+
+fi
+done
+
 
 
 
@@ -15248,7 +15419,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15291,7 +15462,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15475,7 +15646,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_ICU_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -15610,12 +15781,12 @@ if test -n "$ticcutils_CFLAGS"; then
     pkg_cv_ticcutils_CFLAGS="$ticcutils_CFLAGS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ticcutils >= 0.4 \""; } >&5
-  ($PKG_CONFIG --exists --print-errors "ticcutils >= 0.4 ") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ticcutils >= 0.5 \""; } >&5
+  ($PKG_CONFIG --exists --print-errors "ticcutils >= 0.5 ") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_ticcutils_CFLAGS=`$PKG_CONFIG --cflags "ticcutils >= 0.4 " 2>/dev/null`
+  pkg_cv_ticcutils_CFLAGS=`$PKG_CONFIG --cflags "ticcutils >= 0.5 " 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -15627,12 +15798,12 @@ if test -n "$ticcutils_LIBS"; then
     pkg_cv_ticcutils_LIBS="$ticcutils_LIBS"
  elif test -n "$PKG_CONFIG"; then
     if test -n "$PKG_CONFIG" && \
-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ticcutils >= 0.4 \""; } >&5
-  ($PKG_CONFIG --exists --print-errors "ticcutils >= 0.4 ") 2>&5
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ticcutils >= 0.5 \""; } >&5
+  ($PKG_CONFIG --exists --print-errors "ticcutils >= 0.5 ") 2>&5
   ac_status=$?
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
-  pkg_cv_ticcutils_LIBS=`$PKG_CONFIG --libs "ticcutils >= 0.4 " 2>/dev/null`
+  pkg_cv_ticcutils_LIBS=`$PKG_CONFIG --libs "ticcutils >= 0.5 " 2>/dev/null`
 		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
@@ -15653,14 +15824,14 @@ else
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        ticcutils_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ticcutils >= 0.4 " 2>&1`
+	        ticcutils_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ticcutils >= 0.5 " 2>&1`
         else
-	        ticcutils_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ticcutils >= 0.4 " 2>&1`
+	        ticcutils_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ticcutils >= 0.5 " 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$ticcutils_PKG_ERRORS" >&5
 
-	as_fn_error $? "Package requirements (ticcutils >= 0.4 ) were not met:
+	as_fn_error $? "Package requirements (ticcutils >= 0.5 ) were not met:
 
 $ticcutils_PKG_ERRORS
 
@@ -15693,7 +15864,7 @@ $as_echo "yes" >&6; }
 
 fi
 CXXFLAGS="$CXXFLAGS $ticcutils_CFLAGS"
-LIBS="$LIBS $ticcutils_LIBS"
+LIBS="$ticcutils_LIBS $LIBS"
 
 
 ac_config_files="$ac_config_files Makefile folia.pc m4/Makefile src/Makefile include/Makefile include/libfolia/Makefile"
@@ -15807,6 +15978,14 @@ LIBOBJS=$ac_libobjs
 LTLIBOBJS=$ac_ltlibobjs
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
+$as_echo_n "checking that generated files are newer than configure... " >&6; }
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
+$as_echo "done" >&6; }
  if test -n "$EXEEXT"; then
   am__EXEEXT_TRUE=
   am__EXEEXT_FALSE='#'
@@ -16125,16 +16304,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -16194,28 +16373,16 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -16236,8 +16403,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libfolia $as_me 0.10, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+This file was extended by libfolia $as_me 0.11, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -16302,11 +16469,11 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libfolia config.status 0.10
-configured by $0, generated by GNU Autoconf 2.68,
+libfolia config.status 0.11
+configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -16397,7 +16564,7 @@ fi
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
@@ -17413,7 +17580,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
   case $ac_file$ac_mode in
     "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
-  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # Older Autoconf quotes --file arguments for eval, but not when files
   # are listed without --file.  Let's play safe and only enable the eval
   # if we detect the quoting.
   case $CONFIG_FILES in
@@ -17426,7 +17593,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
     # Strip MF so we end up with the name of the file.
     mf=`echo "$mf" | sed -e 's/:.*$//'`
     # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named `Makefile.in', but
+    # We used to match only the files named 'Makefile.in', but
     # some people rename them; so instead we look at the file content.
     # Grep'ing the first line is not enough: some people post-process
     # each Makefile.in and add a new line on top of each file to say so.
@@ -17460,21 +17627,19 @@ $as_echo X"$mf" |
       continue
     fi
     # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running `make'.
+    # from the Makefile without running 'make'.
     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
     test -z "$DEPDIR" && continue
     am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "am__include" && continue
+    test -z "$am__include" && continue
     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # When using ansi2knr, U may be empty or an underscore; expand it
-    U=`sed -n 's/^U = //p' < "$mf"`
     # Find all dependency output files, they are included files with
     # $(DEPDIR) in their names.  We invoke sed twice because it is the
     # simplest approach to changing $(DEPDIR) to its actual value in the
     # expansion.
     for file in `sed -n "
       s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
       # Make sure the directory exists.
       test -f "$dirpart/$file" && continue
       fdir=`$as_dirname -- "$file" ||
diff --git a/configure.ac b/configure.ac
index c4023ed..cd83805 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
 # $URL: https://ilk.uvt.nl/svn/sources/ucto/trunk/configure.ac $
 
 AC_PREREQ(2.59)
-AC_INIT([libfolia], [0.10], [timbl at uvt.nl])
+AC_INIT([libfolia], [0.11], [timbl at uvt.nl])
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([configure.ac])
 AC_CONFIG_MACRO_DIR([m4])
@@ -24,10 +24,9 @@ if $cxx_flags_were_set; then
   CXXFLAGS=$CXXFLAGS
 fi
 
-AC_PROG_RANLIB
 # use libtool
 AC_PROG_LIBTOOL
-AC_SUBST([LIBTOOL_DEPS])
+LT_INIT
 
 # when running tests, use CXX
 AC_LANG([C++])
@@ -42,6 +41,7 @@ AC_C_INLINE
 AC_TYPE_SIZE_T
 
 # Checks for library functions.
+AC_CHECK_FUNCS([localtime_r])
 
 PKG_PROG_PKG_CONFIG
 PKG_CHECK_MODULES([XML2], [libxml-2.0 >= 2.6.16] )
@@ -78,15 +78,15 @@ if test "x$PKG_CONFIG_PATH" = x; then
      export PKG_CONFIG_PATH=""
 fi
 AC_ARG_WITH(ticcutils,
-       [  --with-ticcutils=DIR       use ticcutils installed in <DIR>; 
+       [  --with-ticcutils=DIR       use ticcutils installed in <DIR>;
                note that you can install ticcutils in a non-default directory with
                ./configure --prefix=<DIR> in the ticcutils installation directory],
        [PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$withval/lib/pkgconfig"],
        [PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$prefix/lib/pkgconfig"])
 #  AC_MSG_NOTICE( [pkg-config search path: $PKG_CONFIG_PATH] )
-PKG_CHECK_MODULES([ticcutils], [ticcutils >= 0.4] )
+PKG_CHECK_MODULES([ticcutils], [ticcutils >= 0.5] )
 CXXFLAGS="$CXXFLAGS $ticcutils_CFLAGS"
-LIBS="$LIBS $ticcutils_LIBS"
+LIBS="$ticcutils_LIBS $LIBS"
 
 
 AC_OUTPUT([
diff --git a/depcomp b/depcomp
index bd0ac08..4ebd5b3 100755
--- a/depcomp
+++ b/depcomp
@@ -1,10 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2011-12-04.11; # UTC
+scriptversion=2013-05-30.07; # UTC
 
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
-# 2011 Free Software Foundation, Inc.
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -28,9 +27,9 @@ scriptversion=2011-12-04.11; # UTC
 
 case $1 in
   '')
-     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
-     exit 1;
-     ;;
+    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
+    exit 1;
+    ;;
   -h | --h*)
     cat <<\EOF
 Usage: depcomp [--help] [--version] PROGRAM [ARGS]
@@ -40,8 +39,8 @@ as side-effects.
 
 Environment variables:
   depmode     Dependency tracking mode.
-  source      Source file read by `PROGRAMS ARGS'.
-  object      Object file output by `PROGRAMS ARGS'.
+  source      Source file read by 'PROGRAMS ARGS'.
+  object      Object file output by 'PROGRAMS ARGS'.
   DEPDIR      directory where to store dependencies.
   depfile     Dependency file to output.
   tmpdepfile  Temporary file to use when outputting dependencies.
@@ -57,6 +56,66 @@ EOF
     ;;
 esac
 
+# Get the directory component of the given path, and save it in the
+# global variables '$dir'.  Note that this directory component will
+# be either empty or ending with a '/' character.  This is deliberate.
+set_dir_from ()
+{
+  case $1 in
+    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
+      *) dir=;;
+  esac
+}
+
+# Get the suffix-stripped basename of the given path, and save it the
+# global variable '$base'.
+set_base_from ()
+{
+  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
+}
+
+# If no dependency file was actually created by the compiler invocation,
+# we still have to create a dummy depfile, to avoid errors with the
+# Makefile "include basename.Plo" scheme.
+make_dummy_depfile ()
+{
+  echo "#dummy" > "$depfile"
+}
+
+# Factor out some common post-processing of the generated depfile.
+# Requires the auxiliary global variable '$tmpdepfile' to be set.
+aix_post_process_depfile ()
+{
+  # If the compiler actually managed to produce a dependency file,
+  # post-process it.
+  if test -f "$tmpdepfile"; then
+    # Each line is of the form 'foo.o: dependency.h'.
+    # Do two passes, one to just change these to
+    #   $object: dependency.h
+    # and one to simply output
+    #   dependency.h:
+    # which is needed to avoid the deleted-header problem.
+    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
+      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
+    } > "$depfile"
+    rm -f "$tmpdepfile"
+  else
+    make_dummy_depfile
+  fi
+}
+
+# A tabulation character.
+tab='	'
+# A newline character.
+nl='
+'
+# Character ranges might be problematic outside the C locale.
+# These definitions help.
+upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+lower=abcdefghijklmnopqrstuvwxyz
+digits=0123456789
+alpha=${upper}${lower}
+
 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
   echo "depcomp: Variables source, object and depmode must be set" 1>&2
   exit 1
@@ -69,6 +128,9 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
 
 rm -f "$tmpdepfile"
 
+# Avoid interferences from the environment.
+gccflag= dashmflag=
+
 # Some modes work just like other modes, but use different flags.  We
 # parameterize here, but still list the modes in the big case below,
 # to make depend.m4 easier to write.  Note that we *cannot* use a case
@@ -80,26 +142,32 @@ if test "$depmode" = hp; then
 fi
 
 if test "$depmode" = dashXmstdout; then
-   # This is just like dashmstdout with a different argument.
-   dashmflag=-xM
-   depmode=dashmstdout
+  # This is just like dashmstdout with a different argument.
+  dashmflag=-xM
+  depmode=dashmstdout
 fi
 
 cygpath_u="cygpath -u -f -"
 if test "$depmode" = msvcmsys; then
-   # This is just like msvisualcpp but w/o cygpath translation.
-   # Just convert the backslash-escaped backslashes to single forward
-   # slashes to satisfy depend.m4
-   cygpath_u='sed s,\\\\,/,g'
-   depmode=msvisualcpp
+  # This is just like msvisualcpp but w/o cygpath translation.
+  # Just convert the backslash-escaped backslashes to single forward
+  # slashes to satisfy depend.m4
+  cygpath_u='sed s,\\\\,/,g'
+  depmode=msvisualcpp
 fi
 
 if test "$depmode" = msvc7msys; then
-   # This is just like msvc7 but w/o cygpath translation.
-   # Just convert the backslash-escaped backslashes to single forward
-   # slashes to satisfy depend.m4
-   cygpath_u='sed s,\\\\,/,g'
-   depmode=msvc7
+  # This is just like msvc7 but w/o cygpath translation.
+  # Just convert the backslash-escaped backslashes to single forward
+  # slashes to satisfy depend.m4
+  cygpath_u='sed s,\\\\,/,g'
+  depmode=msvc7
+fi
+
+if test "$depmode" = xlc; then
+  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
+  gccflag=-qmakedep=gcc,-MF
+  depmode=gcc
 fi
 
 case "$depmode" in
@@ -122,8 +190,7 @@ gcc3)
   done
   "$@"
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -131,13 +198,17 @@ gcc3)
   ;;
 
 gcc)
+## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
+## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
+## (see the conditional assignment to $gccflag above).
 ## There are various ways to get dependency output from gcc.  Here's
 ## why we pick this rather obscure method:
 ## - Don't want to use -MD because we'd like the dependencies to end
 ##   up in a subdir.  Having to rename by hand is ugly.
 ##   (We might end up doing this anyway to support other compilers.)
 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-##   -MM, not -M (despite what the docs say).
+##   -MM, not -M (despite what the docs say).  Also, it might not be
+##   supported by the other compilers which use the 'gcc' depmode.
 ## - Using -M directly means running the compiler twice (even worse
 ##   than renaming).
   if test -z "$gccflag"; then
@@ -145,33 +216,31 @@ gcc)
   fi
   "$@" -Wp,"$gccflag$tmpdepfile"
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
+  # The second -e expression handles DOS-style file names with drive
+  # letters.
   sed -e 's/^[^:]*: / /' \
       -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
+## This next piece of magic avoids the "deleted header file" problem.
 ## The problem is that when a header file which appears in a .P file
 ## is deleted, the dependency causes make to die (because there is
 ## typically no way to rebuild the header).  We avoid this by adding
 ## dummy dependencies for each header file.  Too bad gcc doesn't do
 ## this for us directly.
-  tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'.  On the theory
+## Some versions of gcc put a space before the ':'.  On the theory
 ## that the space means something, we add a space to the output as
 ## well.  hp depmode also adds that space, but also prefixes the VPATH
 ## to the object.  Take care to not repeat it in the output.
 ## Some versions of the HPUX 10.20 sed can't process this invocation
 ## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
-      | sed -e 's/$/ :/' >> "$depfile"
+  tr ' ' "$nl" < "$tmpdepfile" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -189,8 +258,7 @@ sgi)
     "$@" -MDupdate "$tmpdepfile"
   fi
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -198,43 +266,41 @@ sgi)
 
   if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
     echo "$object : \\" > "$depfile"
-
     # Clip off the initial element (the dependent).  Don't try to be
     # clever and replace this with sed code, as IRIX sed won't handle
     # lines with more than a fixed number of characters (4096 in
     # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
-    # the IRIX cc adds comments like `#:fec' to the end of the
+    # the IRIX cc adds comments like '#:fec' to the end of the
     # dependency line.
-    tr ' ' '
-' < "$tmpdepfile" \
-    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
-    tr '
-' ' ' >> "$depfile"
+    tr ' ' "$nl" < "$tmpdepfile" \
+      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
+      | tr "$nl" ' ' >> "$depfile"
     echo >> "$depfile"
-
     # The second pass generates a dummy entry for each header file.
-    tr ' ' '
-' < "$tmpdepfile" \
-   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
-   >> "$depfile"
+    tr ' ' "$nl" < "$tmpdepfile" \
+      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+      >> "$depfile"
   else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
+    make_dummy_depfile
   fi
   rm -f "$tmpdepfile"
   ;;
 
+xlc)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
 aix)
   # The C for AIX Compiler uses -M and outputs the dependencies
   # in a .u file.  In older versions, this file always lives in the
-  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # current directory.  Also, the AIX compiler puts '$object:' at the
   # start of each line; $object doesn't have directory information.
   # Version 6 uses the directory in both cases.
-  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
-  test "x$dir" = "x$object" && dir=
-  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  set_dir_from "$object"
+  set_base_from "$object"
   if test "$libtool" = yes; then
     tmpdepfile1=$dir$base.u
     tmpdepfile2=$base.u
@@ -247,9 +313,7 @@ aix)
     "$@" -M
   fi
   stat=$?
-
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
     exit $stat
   fi
@@ -258,44 +322,100 @@ aix)
   do
     test -f "$tmpdepfile" && break
   done
-  if test -f "$tmpdepfile"; then
-    # Each line is of the form `foo.o: dependent.h'.
-    # Do two passes, one to just change these to
-    # `$object: dependent.h' and one to simply `dependent.h:'.
-    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-    # That's a tab and a space in the [].
-    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
-  else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
+  aix_post_process_depfile
+  ;;
+
+tcc)
+  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
+  # FIXME: That version still under development at the moment of writing.
+  #        Make that this statement remains true also for stable, released
+  #        versions.
+  # It will wrap lines (doesn't matter whether long or short) with a
+  # trailing '\', as in:
+  #
+  #   foo.o : \
+  #    foo.c \
+  #    foo.h \
+  #
+  # It will put a trailing '\' even on the last line, and will use leading
+  # spaces rather than leading tabs (at least since its commit 0394caf7
+  # "Emit spaces for -MD").
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile"
+    exit $stat
   fi
+  rm -f "$depfile"
+  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
+  # We have to change lines of the first kind to '$object: \'.
+  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
+  # And for each line of the second kind, we have to emit a 'dep.h:'
+  # dummy dependency, to avoid the deleted-header problem.
+  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
-icc)
-  # Intel's C compiler understands `-MD -MF file'.  However on
-  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
-  # ICC 7.0 will fill foo.d with something like
-  #    foo.o: sub/foo.c
-  #    foo.o: sub/foo.h
-  # which is wrong.  We want:
-  #    sub/foo.o: sub/foo.c
-  #    sub/foo.o: sub/foo.h
-  #    sub/foo.c:
-  #    sub/foo.h:
-  # ICC 7.1 will output
+## The order of this option in the case statement is important, since the
+## shell code in configure will try each of these formats in the order
+## listed in this file.  A plain '-MD' option would be understood by many
+## compilers, so we must ensure this comes after the gcc and icc options.
+pgcc)
+  # Portland's C compiler understands '-MD'.
+  # Will always output deps to 'file.d' where file is the root name of the
+  # source file under compilation, even if file resides in a subdirectory.
+  # The object file name does not affect the name of the '.d' file.
+  # pgcc 10.2 will output
   #    foo.o: sub/foo.c sub/foo.h
-  # and will wrap long lines using \ :
+  # and will wrap long lines using '\' :
   #    foo.o: sub/foo.c ... \
   #     sub/foo.h ... \
   #     ...
+  set_dir_from "$object"
+  # Use the source, not the object, to determine the base name, since
+  # that's sadly what pgcc will do too.
+  set_base_from "$source"
+  tmpdepfile=$base.d
+
+  # For projects that build the same source file twice into different object
+  # files, the pgcc approach of using the *source* file root name can cause
+  # problems in parallel builds.  Use a locking strategy to avoid stomping on
+  # the same $tmpdepfile.
+  lockdir=$base.d-lock
+  trap "
+    echo '$0: caught signal, cleaning up...' >&2
+    rmdir '$lockdir'
+    exit 1
+  " 1 2 13 15
+  numtries=100
+  i=$numtries
+  while test $i -gt 0; do
+    # mkdir is a portable test-and-set.
+    if mkdir "$lockdir" 2>/dev/null; then
+      # This process acquired the lock.
+      "$@" -MD
+      stat=$?
+      # Release the lock.
+      rmdir "$lockdir"
+      break
+    else
+      # If the lock is being held by a different process, wait
+      # until the winning process is done or we timeout.
+      while test -d "$lockdir" && test $i -gt 0; do
+        sleep 1
+        i=`expr $i - 1`
+      done
+    fi
+    i=`expr $i - 1`
+  done
+  trap - 1 2 13 15
+  if test $i -le 0; then
+    echo "$0: failed to acquire lock after $numtries attempts" >&2
+    echo "$0: check lockdir '$lockdir'" >&2
+    exit 1
+  fi
 
-  "$@" -MD -MF "$tmpdepfile"
-  stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -307,8 +427,8 @@ icc)
   sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
   # Some versions of the HPUX 10.20 sed can't process this invocation
   # correctly.  Breaking it into two sed invocations is a workaround.
-  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
-    sed -e 's/$/ :/' >> "$depfile"
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -319,9 +439,8 @@ hp2)
   # 'foo.d', which lands next to the object file, wherever that
   # happens to be.
   # Much of this is similar to the tru64 case; see comments there.
-  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
-  test "x$dir" = "x$object" && dir=
-  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+  set_dir_from  "$object"
+  set_base_from "$object"
   if test "$libtool" = yes; then
     tmpdepfile1=$dir$base.d
     tmpdepfile2=$dir.libs/$base.d
@@ -332,8 +451,7 @@ hp2)
     "$@" +Maked
   fi
   stat=$?
-  if test $stat -eq 0; then :
-  else
+  if test $stat -ne 0; then
      rm -f "$tmpdepfile1" "$tmpdepfile2"
      exit $stat
   fi
@@ -343,77 +461,61 @@ hp2)
     test -f "$tmpdepfile" && break
   done
   if test -f "$tmpdepfile"; then
-    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
-    # Add `dependent.h:' lines.
+    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add 'dependent.h:' lines.
     sed -ne '2,${
-	       s/^ *//
-	       s/ \\*$//
-	       s/$/:/
-	       p
-	     }' "$tmpdepfile" >> "$depfile"
+               s/^ *//
+               s/ \\*$//
+               s/$/:/
+               p
+             }' "$tmpdepfile" >> "$depfile"
   else
-    echo "#dummy" > "$depfile"
+    make_dummy_depfile
   fi
   rm -f "$tmpdepfile" "$tmpdepfile2"
   ;;
 
 tru64)
-   # The Tru64 compiler uses -MD to generate dependencies as a side
-   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
-   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
-   # dependencies in `foo.d' instead, so we check for that too.
-   # Subdirectories are respected.
-   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
-   test "x$dir" = "x$object" && dir=
-   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
-   if test "$libtool" = yes; then
-      # With Tru64 cc, shared objects can also be used to make a
-      # static library.  This mechanism is used in libtool 1.4 series to
-      # handle both shared and static libraries in a single compilation.
-      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
-      #
-      # With libtool 1.5 this exception was removed, and libtool now
-      # generates 2 separate objects for the 2 libraries.  These two
-      # compilations output dependencies in $dir.libs/$base.o.d and
-      # in $dir$base.o.d.  We have to check for both files, because
-      # one of the two compilations can be disabled.  We should prefer
-      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
-      # automatically cleaned when .libs/ is deleted, while ignoring
-      # the former would cause a distcleancheck panic.
-      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
-      tmpdepfile2=$dir$base.o.d          # libtool 1.5
-      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
-      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
-      "$@" -Wc,-MD
-   else
-      tmpdepfile1=$dir$base.o.d
-      tmpdepfile2=$dir$base.d
-      tmpdepfile3=$dir$base.d
-      tmpdepfile4=$dir$base.d
-      "$@" -MD
-   fi
-
-   stat=$?
-   if test $stat -eq 0; then :
-   else
-      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
-      exit $stat
-   fi
-
-   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
-   do
-     test -f "$tmpdepfile" && break
-   done
-   if test -f "$tmpdepfile"; then
-      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-      # That's a tab and a space in the [].
-      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
-   else
-      echo "#dummy" > "$depfile"
-   fi
-   rm -f "$tmpdepfile"
-   ;;
+  # The Tru64 compiler uses -MD to generate dependencies as a side
+  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
+  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+  # dependencies in 'foo.d' instead, so we check for that too.
+  # Subdirectories are respected.
+  set_dir_from  "$object"
+  set_base_from "$object"
+
+  if test "$libtool" = yes; then
+    # Libtool generates 2 separate objects for the 2 libraries.  These
+    # two compilations output dependencies in $dir.libs/$base.o.d and
+    # in $dir$base.o.d.  We have to check for both files, because
+    # one of the two compilations can be disabled.  We should prefer
+    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+    # automatically cleaned when .libs/ is deleted, while ignoring
+    # the former would cause a distcleancheck panic.
+    tmpdepfile1=$dir$base.o.d          # libtool 1.5
+    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
+    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
+    "$@" -Wc,-MD
+  else
+    tmpdepfile1=$dir$base.d
+    tmpdepfile2=$dir$base.d
+    tmpdepfile3=$dir$base.d
+    "$@" -MD
+  fi
+
+  stat=$?
+  if test $stat -ne 0; then
+    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+    exit $stat
+  fi
+
+  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+  do
+    test -f "$tmpdepfile" && break
+  done
+  # Same post-processing that is required for AIX mode.
+  aix_post_process_depfile
+  ;;
 
 msvc7)
   if test "$libtool" = yes; then
@@ -424,8 +526,7 @@ msvc7)
   "$@" $showIncludes > "$tmpdepfile"
   stat=$?
   grep -v '^Note: including file: ' "$tmpdepfile"
-  if test "$stat" = 0; then :
-  else
+  if test $stat -ne 0; then
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -443,14 +544,15 @@ msvc7)
   p
 }' | $cygpath_u | sort -u | sed -n '
 s/ /\\ /g
-s/\(.*\)/	\1 \\/p
+s/\(.*\)/'"$tab"'\1 \\/p
 s/.\(.*\) \\/\1:/
 H
 $ {
-  s/.*/	/
+  s/.*/'"$tab"'/
   G
   p
 }' >> "$depfile"
+  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
   rm -f "$tmpdepfile"
   ;;
 
@@ -478,7 +580,7 @@ dashmstdout)
     shift
   fi
 
-  # Remove `-o $object'.
+  # Remove '-o $object'.
   IFS=" "
   for arg
   do
@@ -498,18 +600,18 @@ dashmstdout)
   done
 
   test -z "$dashmflag" && dashmflag=-M
-  # Require at least two characters before searching for `:'
+  # Require at least two characters before searching for ':'
   # in the target name.  This is to cope with DOS-style filenames:
-  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
   "$@" $dashmflag |
-    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
   rm -f "$depfile"
   cat < "$tmpdepfile" > "$depfile"
-  tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this sed invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  tr ' ' "$nl" < "$tmpdepfile" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -562,11 +664,12 @@ makedepend)
   # makedepend may prepend the VPATH from the source file name to the object.
   # No need to regex-escape $object, excess matching of '.' is harmless.
   sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
-  sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process the last invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed '1,2d' "$tmpdepfile" \
+    | tr ' ' "$nl" \
+    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+    | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile" "$tmpdepfile".bak
   ;;
 
@@ -583,7 +686,7 @@ cpp)
     shift
   fi
 
-  # Remove `-o $object'.
+  # Remove '-o $object'.
   IFS=" "
   for arg
   do
@@ -602,10 +705,10 @@ cpp)
     esac
   done
 
-  "$@" -E |
-    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
-    sed '$ s: \\$::' > "$tmpdepfile"
+  "$@" -E \
+    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+    | sed '$ s: \\$::' > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
   cat < "$tmpdepfile" >> "$depfile"
@@ -637,23 +740,23 @@ msvisualcpp)
       shift
       ;;
     "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
-	set fnord "$@"
-	shift
-	shift
-	;;
+        set fnord "$@"
+        shift
+        shift
+        ;;
     *)
-	set fnord "$@" "$arg"
-	shift
-	shift
-	;;
+        set fnord "$@" "$arg"
+        shift
+        shift
+        ;;
     esac
   done
   "$@" -E 2>/dev/null |
   sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
-  echo "	" >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
+  echo "$tab" >> "$depfile"
   sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
diff --git a/include/Makefile.in b/include/Makefile.in
index 37432de..6aaff72 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -17,6 +16,51 @@
 
 #AUTOMAKE_OPTIONS = foreign 
 VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -36,7 +80,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = include
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_icu_check.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -49,20 +93,58 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 SOURCES =
 DIST_SOURCES =
-RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
-	html-recursive info-recursive install-data-recursive \
-	install-dvi-recursive install-exec-recursive \
-	install-html-recursive install-info-recursive \
-	install-pdf-recursive install-ps-recursive install-recursive \
-	installcheck-recursive installdirs-recursive pdf-recursive \
-	ps-recursive uninstall-recursive
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+	ctags-recursive dvi-recursive html-recursive info-recursive \
+	install-data-recursive install-dvi-recursive \
+	install-exec-recursive install-html-recursive \
+	install-info-recursive install-pdf-recursive \
+	install-ps-recursive install-recursive installcheck-recursive \
+	installdirs-recursive pdf-recursive ps-recursive \
+	tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
-AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
-	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+am__recursive_targets = \
+  $(RECURSIVE_TARGETS) \
+  $(RECURSIVE_CLEAN_TARGETS) \
+  $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
 	distdir
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
@@ -94,6 +176,7 @@ am__relativize = \
   reldir="$$dir2"
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -139,7 +222,6 @@ LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
@@ -268,22 +350,25 @@ clean-libtool:
 	-rm -rf .libs _libs
 
 # This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-#     (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-$(RECURSIVE_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+#     (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+	@fail=; \
+	if $(am__make_keepgoing); then \
+	  failcom='fail=yes'; \
+	else \
+	  failcom='exit 1'; \
+	fi; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	for subdir in $$list; do \
 	  echo "Making $$target in $$subdir"; \
 	  if test "$$subdir" = "."; then \
 	    dot_seen=yes; \
@@ -298,57 +383,12 @@ $(RECURSIVE_TARGETS):
 	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 	fi; test -z "$$fail"
 
-$(RECURSIVE_CLEAN_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	dot_seen=no; \
-	case "$@" in \
-	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-	  *) list='$(SUBDIRS)' ;; \
-	esac; \
-	rev=''; for subdir in $$list; do \
-	  if test "$$subdir" = "."; then :; else \
-	    rev="$$subdir $$rev"; \
-	  fi; \
-	done; \
-	rev="$$rev ."; \
-	target=`echo $@ | sed s/-recursive//`; \
-	for subdir in $$rev; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
-	done && test -z "$$fail"
-tags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
-	done
-ctags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
-	done
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
@@ -364,12 +404,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -381,15 +416,11 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -398,6 +429,21 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -434,13 +480,10 @@ distdir: $(DISTFILES)
 	done
 	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
-	    test -d "$(distdir)/$$subdir" \
-	    || $(MKDIR_P) "$(distdir)/$$subdir" \
-	    || exit 1; \
-	  fi; \
-	done
-	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
+	    $(am__make_dryrun) \
+	      || test -d "$(distdir)/$$subdir" \
+	      || $(MKDIR_P) "$(distdir)/$$subdir" \
+	      || exit 1; \
 	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
 	    $(am__relativize); \
 	    new_distdir=$$reldir; \
@@ -561,22 +604,20 @@ ps-am:
 
 uninstall-am:
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
-	install-am install-strip tags-recursive
-
-.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
-	all all-am check check-am clean clean-generic clean-libtool \
-	ctags ctags-recursive distclean distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs installdirs-am maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
-	uninstall uninstall-am
+.MAKE: $(am__recursive_targets) install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
+	check-am clean clean-generic clean-libtool cscopelist-am ctags \
+	ctags-am distclean distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	installdirs-am maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+	ps ps-am tags tags-am uninstall uninstall-am
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/include/libfolia/Makefile.in b/include/libfolia/Makefile.in
index 7dd0581..71e772e 100644
--- a/include/libfolia/Makefile.in
+++ b/include/libfolia/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -16,6 +15,51 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -35,8 +79,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = include/libfolia
-DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(pkginclude_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_icu_check.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -49,8 +93,25 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 SOURCES =
 DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -80,11 +141,29 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(pkgincludedir)"
 HEADERS = $(pkginclude_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -130,7 +209,6 @@ LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
@@ -259,8 +337,11 @@ clean-libtool:
 	-rm -rf .libs _libs
 install-pkgincludeHEADERS: $(pkginclude_HEADERS)
 	@$(NORMAL_INSTALL)
-	test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
 	@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \
+	fi; \
 	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  echo "$$d$$p"; \
@@ -276,26 +357,15 @@ uninstall-pkgincludeHEADERS:
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 	dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -307,15 +377,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -324,6 +390,21 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -463,18 +544,19 @@ uninstall-am: uninstall-pkgincludeHEADERS
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libtool ctags distclean distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-pkgincludeHEADERS install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags uninstall uninstall-am uninstall-pkgincludeHEADERS
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libtool cscopelist-am ctags ctags-am distclean \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-pkgincludeHEADERS install-ps \
+	install-ps-am install-strip installcheck installcheck-am \
+	installdirs maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+	ps ps-am tags tags-am uninstall uninstall-am \
+	uninstall-pkgincludeHEADERS
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/include/libfolia/document.h b/include/libfolia/document.h
index e6233d9..58c8d50 100644
--- a/include/libfolia/document.h
+++ b/include/libfolia/document.h
@@ -1,11 +1,11 @@
 /*
-  $Id: document.h 15909 2013-04-03 13:52:24Z sloot $
+  $Id: document.h 17512 2014-08-14 09:48:42Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/libfolia/document.h $
 
-  Copyright (c) 1998 - 2013
+  Copyright (c) 1998 - 2014
   ILK   - Tilburg University
   CLiPS - University of Antwerp
- 
+
   This file is part of libfolia
 
   libfolia is free software; you can redistribute it and/or modify
@@ -40,15 +40,17 @@
 #include "libfolia/foliautils.h"
 
 namespace folia {
+  void initMT();
+
   extern const std::string NSFOLIA;
 
   class Pattern {
     friend std::ostream& operator<<( std::ostream&, const Pattern& );
   public:
-    Pattern( const std::vector<std::string>&, 
+    Pattern( const std::vector<std::string>&,
 	     const ElementType = BASE,
 	     const std::string& = "" );
-    Pattern( const std::vector<std::string>&, 
+    Pattern( const std::vector<std::string>&,
 	     const std::string& );
     ~Pattern();
     bool match( const UnicodeString& , size_t&, int&, bool&, bool& ) const;
@@ -73,7 +75,7 @@ namespace folia {
 
   class Document {
     friend bool operator==( const Document&, const Document& );
-    friend std::ostream& operator<<( std::ostream&, const Document& );
+    friend std::ostream& operator<<( std::ostream&, const Document * );
   public:
     Document();
     Document( const std::string& );
@@ -91,7 +93,12 @@ namespace folia {
     }
     int size() const;
     FoliaElement* doc() const { return foliadoc; }
-    FoliaElement* addNode( ElementType, const KWargs& );
+    Text* addText( const KWargs& );
+    Text* addText( Text * );
+    FoliaElement* append( Text *t ){
+      // almost backward compatible
+      return addText(t);
+    };
     void addStyle( const std::string&, const std::string& );
     void replaceStyle( const std::string&, const std::string& );
     std::vector<Paragraph*> paragraphs() const;
@@ -111,47 +118,51 @@ namespace folia {
     std::string toXml( const std::string& ="", bool = false ) const;
     MetaDataType metadatatype() const { return _metadatatype; };
     std::string metadatafile() const { return _metadatafile; };
+    void set_metadata( const std::string& type, const std::string& value );
+    const std::string get_metadata( const std::string& type ) const;
 
-    FoliaElement *append( FoliaElement* );
-
-    void addDocIndex( FoliaElement* el, const std::string& );
+    void addDocIndex( FoliaElement*, const std::string& );
+    void delDocIndex( const FoliaElement*, const std::string& );
 
     FoliaElement* operator []( size_t ) const; //select i'th element from data
-  
-    FoliaElement *index( const std::string& ) const; //retrieve element with specified ID 
-    FoliaElement* operator []( const std::string& ) const ; //index as operator 
-    bool isDeclared( AnnotationType::AnnotationType, 
-		     const std::string&, const std::string&,
-		     const std::string&, const std::string& );
+
+    FoliaElement *index( const std::string& ) const; //retrieve element with specified ID
+    FoliaElement* operator []( const std::string& ) const ; //index as operator
+    bool isDeclared( AnnotationType::AnnotationType,
+		     const std::string&,
+		     const std::string&,
+		     const std::string& );
     bool isDeclared( AnnotationType::AnnotationType, const std::string& = "" );
     std::string defaultset( AnnotationType::AnnotationType ) const;
 
-    std::string defaultannotator( AnnotationType::AnnotationType, 
+    std::string defaultannotator( AnnotationType::AnnotationType,
 				  const std::string& ="" ) const;
-    std::string defaultannotatortype( AnnotationType::AnnotationType, 
+    std::string defaultannotatortype( AnnotationType::AnnotationType,
 				      const std::string& ="" ) const;
 
-    std::string defaultdatetime( AnnotationType::AnnotationType, 
+    std::string defaultdatetime( AnnotationType::AnnotationType,
 				 const std::string& ="" ) const;
 
     FoliaElement* parseXml( );
 
     std::string id() const { return _id; };
-    void declare( AnnotationType::AnnotationType, 
+    void declare( AnnotationType::AnnotationType,
 		  const std::string&,
 		  const std::string& = "" );
-    void declare( AnnotationType::AnnotationType, 
-		  const std::string&, const std::string&, 
+    void declare( AnnotationType::AnnotationType,
+		  const std::string&, const std::string&,
 		  const std::string&, const std::string& );
     xmlDoc *XmlDoc() const { return xmldoc; };
     xmlNs *foliaNs() const { return _foliaNsOut; };
     void keepForDeletion( FoliaElement *p ) { delSet.insert( p ); };
+    void addExternal( External *p ) { externals.push_back( p ); };
+    FoliaElement *resolveExternals( FoliaElement* );
     int debug;
 
     class at_t {
       friend std::ostream& operator<<( std::ostream&, const at_t& );
     public:
-    at_t( const std::string& _a, const std::string& _t, const std::string& _d ): a(_a),t(_t),d(_d){}; 
+    at_t( const std::string& _a, const std::string& _t, const std::string& _d ): a(_a),t(_t),d(_d){};
       std::string a;
       std::string t;
       std::string d;
@@ -160,6 +171,7 @@ namespace folia {
     std::map<AnnotationType::AnnotationType,std::multimap<std::string,at_t> > annotationdefaults;
 
     FoliaElement* parseFoliaDoc( xmlNode * );
+    void parsemeta( xmlNode * );
     void setimdi( xmlNode * );
     void setAttributes( const KWargs&  );
     void parseannotations( xmlNode * );
@@ -170,6 +182,7 @@ namespace folia {
     std::map<std::string, FoliaElement* > sindex;
     std::vector<FoliaElement* > iindex;
     std::vector<FoliaElement*> data;
+    std::vector<External*> externals;
     std::string _id;
     std::set<FoliaElement *> delSet;
     FoliaElement *foliadoc;
@@ -184,17 +197,25 @@ namespace folia {
     std::string _language;
     std::string _publisher;
     std::string _license;
+    std::map<std::string,std::string> meta_atts;
     std::multimap<std::string,std::string> styles;
     bool loadall;
     std::string filename;
     std::string version;
+    bool external;
   };
 
   bool operator==( const Document&, const Document& );
-  inline bool operator!=( const Document& d1, const Document& d2 ){ 
+  inline bool operator!=( const Document& d1, const Document& d2 ){
     return !( d1==d2 );
   }
 
+  std::ostream& operator<<( std::ostream&, const Document * );
+  inline std::ostream& operator<<( std::ostream& os, const Document& d ){
+    os << &d;
+    return os;
+  }
+
   inline std::ostream& operator<<( std::ostream& os, const Document::at_t& at ){
     os << "<" << at.a << "," << at.t << "," << at.d << ">";
     return os;
diff --git a/include/libfolia/folia.h b/include/libfolia/folia.h
index d7f11ed..8c1d7b9 100644
--- a/include/libfolia/folia.h
+++ b/include/libfolia/folia.h
@@ -1,11 +1,11 @@
 /*
-  $Id: folia.h 15909 2013-04-03 13:52:24Z sloot $
+  $Id: folia.h 17507 2014-08-13 15:20:36Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/libfolia/folia.h $
 
-  Copyright (c) 1998 - 2013
+  Copyright (c) 1998 - 2014
   ILK   - Tilburg University
   CLiPS - University of Antwerp
- 
+
   This file is part of libfolia
 
   libfolia is free software; you can redistribute it and/or modify
@@ -32,16 +32,12 @@
 
 #include <list>
 #include "unicode/unistr.h"
-#include "unicode/regex.h"
 #include "libxml/tree.h"
-#include "libxml/xpath.h"
-#include <ctime>
 #include "libfolia/foliautils.h"
 
 namespace folia {
   class Document;
-  class FoliaElement;
-  class AbstractTokenAnnotation;
+  class AbstractSpanAnnotation;
   class Alternative;
   class PosAnnotation;
   class LemmaAnnotation;
@@ -55,76 +51,72 @@ namespace folia {
   class Paragraph;
   class Morpheme;
 
+  extern std::set<ElementType> default_ignore;
+  extern std::set<ElementType> default_ignore_annotations;
+  extern std::set<ElementType> default_ignore_structure;
+
+#define NOT_IMPLEMENTED {						\
+    throw NotImplementedError( xmltag() + "::" + std::string(__func__) ); \
+  }
+
   class FoliaElement {
     friend std::ostream& operator<<( std::ostream&, const FoliaElement& );
     friend std::ostream& operator<<( std::ostream&, const FoliaElement* );
     friend bool operator==( const FoliaElement&, const FoliaElement& );
-    friend class Document;
-    friend class Correction;
   public:
-    //Constructor  
-    FoliaElement( Document* =0 );
-    virtual ~FoliaElement();
+    virtual ~FoliaElement(){};
 
-    static FoliaElement *createElement( Document *, const ElementType  );
-    static FoliaElement *createElement( Document *, const std::string&  );
-
-    void classInit( const std::string& s="" ){
-      init(); // virtual init
-      if ( !s.empty() ){
-	// this enables the init of empty classes, which hopefully get their
-	// attributes in a later state
-	setAttributes(  getArgs( s ) );
-      }
-    }
-    
-    void classInit( const KWargs& a ){
-      init(); // virtual init
-      setAttributes( a ); // also virtual!
-    }
-    
-    virtual void setAttributes( const KWargs& );
-
-    void setDateTime( const std::string& );
-    std::string getDateTime() const;
-
-    //functions regarding contained data
-    size_t size() const { return data.size(); };
-  
-    void fixupDoc( Document* );
-    virtual FoliaElement *append( FoliaElement* );
-    virtual FoliaElement *postappend( ) { return this; };
-    virtual std::vector<FoliaElement*> findreplacables( FoliaElement * ) const;
-    void remove( FoliaElement *, bool = true );
-    void replace( FoliaElement * );
-
-    FoliaElement* index( size_t ) const;
+    virtual size_t size() const = 0;
+    virtual void fixupDoc( Document* ) = 0;
+    virtual FoliaElement *append( FoliaElement* ) = 0;
+    virtual FoliaElement *postappend( ) = 0;
+    virtual std::vector<FoliaElement*> findreplacables( FoliaElement * ) const = 0;
+    virtual void remove( size_t, bool = true ) = 0;
+    virtual void remove( FoliaElement *, bool = true ) = 0;
+    virtual void replace( FoliaElement * ) = 0;
+    virtual FoliaElement* replace( FoliaElement *, FoliaElement* ) = 0;
 
+    virtual FoliaElement* index( size_t ) const = 0;
+    virtual FoliaElement* rindex( size_t ) const = 0;
     FoliaElement* operator[]( size_t i ) const {
       return index(i);
     }
+    virtual bool isinstance( ElementType et ) const = 0;
 
-    FoliaElement* rindex( size_t ) const;
+    virtual const Word* resolveword( const std::string& ) const = 0;
 
-    virtual const Word* resolveword( const std::string& ) const { return 0; };
+    virtual void setDateTime( const std::string& ) = 0;
+    virtual std::string getDateTime() const = 0;
 
-    bool isinstance( ElementType et ) const {
-      return et == _element_id;
+    virtual std::vector<AbstractSpanAnnotation*> selectSpan() const = 0;
+
+    template <typename F>
+      F *addAnnotation( const KWargs& args ) {
+      F *res = 0;
+      try {
+	res = new F( doc(), args);
+      }
+      catch( std::exception& ){
+	delete res;
+	throw;
+      }
+      append( res );
+      return res;
     }
 
     template <typename F>
       bool isinstance() const {
       F obj("");
-      return _element_id == obj._element_id;
+      return element_id() == obj.element_id();
     }
-      
+
     template <typename F>
       std::vector<F*> select( const std::string& st,
-			      const std::set<ElementType>& exclude, 
+			      const std::set<ElementType>& exclude,
 			      bool recurse = true ) const {
-      F obj("");
+      F obj(0);
       std::vector<F*> res;
-      std::vector<FoliaElement*> tmp = select( obj._element_id, 
+      std::vector<FoliaElement*> tmp = select( obj.element_id(),
 					       st,
 					       exclude,
 					       recurse );
@@ -133,13 +125,13 @@ namespace folia {
       }
       return res;
     }
-    
+
     template <typename F>
       std::vector<F*> select( const std::string& st,
 			      bool recurse = true ) const {
-      F obj("");
+      F obj(0);
       std::vector<F*> res;
-      std::vector<FoliaElement*> tmp = select( obj._element_id, 
+      std::vector<FoliaElement*> tmp = select( obj.element_id(),
 					       st,
 					       recurse );
       for ( size_t i = 0; i < tmp.size(); ++i ){
@@ -151,9 +143,9 @@ namespace folia {
     template <typename F>
       std::vector<F*> select( const char* st,
 			      bool recurse = true ) const {
-      F obj("");
+      F obj(0);
       std::vector<F*> res;
-      std::vector<FoliaElement*> tmp = select( obj._element_id, 
+      std::vector<FoliaElement*> tmp = select( obj.element_id(),
 					       std::string(st),
 					       recurse );
       for ( size_t i = 0; i < tmp.size(); ++i ){
@@ -161,13 +153,13 @@ namespace folia {
       }
       return res;
     }
-    
+
     template <typename F>
-      std::vector<F*> select( const std::set<ElementType>& exclude, 
+      std::vector<F*> select( const std::set<ElementType>& exclude,
 			      bool recurse = true ) const {
-      F obj("");
+      F obj(0);
       std::vector<F*> res;
-      std::vector<FoliaElement*> tmp = select( obj._element_id, 
+      std::vector<FoliaElement*> tmp = select( obj.element_id(),
 					       exclude,
 					       recurse );
       for ( size_t i = 0; i < tmp.size(); ++i ){
@@ -175,282 +167,240 @@ namespace folia {
       }
       return res;
     }
-    
+
     template <typename F>
       std::vector<F*> select( bool recurse = true ) const {
-      F obj("");
+      F obj(0);
       std::vector<F*> res;
-      std::vector<FoliaElement*> tmp = select( obj._element_id,
+      std::vector<FoliaElement*> tmp = select( obj.element_id(),
 					       recurse );
       for ( size_t i = 0; i < tmp.size(); ++i ){
 	res.push_back( dynamic_cast<F*>( tmp[i]) );
       }
       return res;
     }
-    
-    template <typename F> 
-      std::vector<F*> annotations( ) const {
+
+    template <typename F>
+      std::vector<F*> annotations( const std::string& s = "" ) const {
       if ( allowannotations() ){
-	std::vector<F*> v = select<F>();
+	std::vector<F*> v = select<F>( s, default_ignore_annotations );
 	if ( v.size() >= 1 )
 	  return v;
 	else {
-	  F obj("");
-	  throw NoSuchAnnotation( obj.classname() );
+	  F obj(0);
+	  if ( s.empty() )
+	    throw NoSuchAnnotation( obj.classname() );
+	  else
+	    throw NoSuchAnnotation( obj.classname() + " for set='" + s + "'" );
 	}
       }
-      else {
-	throw NotImplementedError( "annotations() for " + _xmltag ); 
-      };
-    }
-    
-    template <typename F> 
-      F *annotation() const {
-      std::vector<F*>v = annotations<F>();
-      return v[0]; // always exist, otherwise annotations would throw()
+      else NOT_IMPLEMENTED;
     }
 
     template <typename F>
-      F *annotation( const std::string& st ) const {
-      if ( allowannotations() ){
-	// Will return a SINGLE annotation (even if there are multiple). 
-	// Raises a NoSuchAnnotation exception if none was found
-	std::vector<F*>v = select<F>( st );
-	if ( v.size() >= 1 )
-	  return v[0];
-	else {
-	  F obj("");
-	  if ( st.empty() )
-	    throw NoSuchAnnotation( obj.classname() );
-	  else
-	    throw NoSuchAnnotation( obj.classname() + " in set '" + st + "'" );
-	}
+      bool hasannotation( const std::string& st = "" ) const {
+      try {
+	std::vector<F*> v = annotations<F>( st );
+	return true;
       }
-      else {
-	throw NotImplementedError( "annotation() for " + _xmltag ); 
+      catch ( NoSuchAnnotation& e ){
+	return false;
       }
     }
 
-    std::vector<std::string> feats( const std::string& ) const;
+    template <typename F>
+      F *annotation( const std::string& st = "" ) const {
+      std::vector<F*>v = annotations<F>( st );
+      return v[0]; // always exist, otherwise annotations would throw()
+    }
+
+    virtual std::vector<FoliaElement*> findspans( ElementType,
+						  const std::string& = "" ) const NOT_IMPLEMENTED;
+
+    template <typename F>
+      std::vector<FoliaElement*> findspans( const std::string& st = "" ) const {
+      F obj("");
+      return findspans( obj.element_id(), st );
+    }
+
     std::vector<Sentence *> sentencePart() const;
-    std::string feat( const std::string& ) const;
+    virtual std::vector<std::string> feats( const std::string& ) const = 0;
+    virtual std::string feat( const std::string& ) const = 0;
     //XML (de)serialisation
     std::string xmlstring() const; // serialize to a string (XML fragment)
-    virtual xmlNode *xml( bool, bool = false ) const; //serialize to XML  
-    virtual FoliaElement* parseXml( const xmlNode * );
-    virtual std::string str() const;
+    virtual xmlNode *xml( bool, bool = false ) const = 0; //serialize to XML
+    virtual FoliaElement* parseXml( const xmlNode * ) = 0;
+    virtual std::string str() const = 0;
     UnicodeString unicode() const { return text(); };
     UnicodeString toktext( const std::string& cls = "current" ) const {
-      return text( cls, true );
-    }
-    virtual UnicodeString text( const std::string& = "current", bool = false ) const;
-    virtual TextContent *textcontent( const std::string& = "current" ) const;
-    virtual UnicodeString stricttext( const std::string& = "current" ) const;
-    bool hastext( const std::string& = "current" ) const ;
-    virtual FoliaElement *head() const {
-      throw NotImplementedError("head() for " + _xmltag );
+      return deeptext( cls, true );
     }
-    virtual FoliaElement *getNew() const {
-      throw NotImplementedError("getNew() for " + _xmltag ); };
-    virtual FoliaElement *getOriginal() const {
-      throw NotImplementedError("getOriginal() for " + _xmltag ); };
-    virtual FoliaElement *getCurrent() const {
-      throw NotImplementedError("getCurrent() for " + _xmltag ); };
-    virtual FoliaElement *split( FoliaElement *, FoliaElement *, 
-				    const std::string& = "" ){
-      throw NotImplementedError("split() for " + _xmltag ); };
-    virtual Correction *mergewords( FoliaElement *, 
+    virtual UnicodeString text( const std::string& = "current", bool = false ) const = 0;
+    virtual TextContent *textcontent( const std::string& = "current" ) const = 0;
+    UnicodeString stricttext( const std::string& = "current" ) const;
+    virtual UnicodeString deeptext( const std::string& = "current", bool = false ) const = 0;
+    bool hastext( const std::string& = "current" ) const;
+    virtual bool printable() const = 0;
+    virtual FoliaElement *head() const NOT_IMPLEMENTED;
+    virtual FoliaElement *getNew() const NOT_IMPLEMENTED;
+    virtual FoliaElement *getOriginal() const NOT_IMPLEMENTED;
+    virtual FoliaElement *getCurrent() const NOT_IMPLEMENTED;
+    virtual FoliaElement *split( FoliaElement *, FoliaElement *,
+				 const std::string& = "" ) NOT_IMPLEMENTED;
+
+    virtual Correction *mergewords( FoliaElement *,
 				    const std::vector<FoliaElement *>&,
-				    const std::string& = "" ){
-      throw NotImplementedError("mergewords() for " + _xmltag ); };
-    virtual Correction *deleteword( FoliaElement *, 
-				    const std::string& = "" ){
-      throw NotImplementedError("deleteword() for " + _xmltag ); };
-    virtual Correction *insertword( FoliaElement *, FoliaElement *,
-				    const std::string& = "" ){
-      throw NotImplementedError("insertword() for " + _xmltag ); };
-    virtual std::vector<Suggestion*> suggestions() const
-      { throw NotImplementedError("suggestions() for " + _xmltag ); };
-    virtual Suggestion *suggestions( size_t ) const
-      { throw NotImplementedError("suggestions() for " + _xmltag ); };    
-    virtual std::string subset() const 
-      { throw NotImplementedError("subset() for " + _xmltag ); };
-    virtual FoliaElement *previous() const {
-      throw NotImplementedError("previous() for " + _xmltag ); };
-    virtual FoliaElement *next() const {
-      throw NotImplementedError("next() for " + _xmltag ); };
-    virtual std::vector<Word*> context( size_t, 
-					const std::string& ="" ) const {
-      throw NotImplementedError("contect() for " + _xmltag ); };
-    virtual std::vector<Word*> leftcontext( size_t, 
-					    const std::string& ="" ) const {
-      throw NotImplementedError("leftcontect() for " + _xmltag ); 
-    };
-    virtual std::vector<Word*> rightcontext( size_t, 
-					     const std::string& ="" ) const {
-      throw NotImplementedError("rightcontext() for " + _xmltag ); 
-    };
-    virtual int offset() const {
-      throw NotImplementedError("offset() for " + _xmltag ); 
-    };
-    virtual std::string getlang() const {
-      throw NotImplementedError("offset() for " + _xmltag ); 
-    };
-    virtual std::string setlang( const std::string& ) {
-      throw NotImplementedError("offset() for " + _xmltag ); 
-    };
-
-    std::string pos( const std::string& = "" ) const;
-    std::string lemma( const std::string& = "" ) const;
-    std::string cls() const { return _class; };
-    std::string sett() const { return _set; };
-    std::string annotator( ) const { return _annotator; };
-    void annotator( const std::string& a ) { _annotator = a; };
-    AnnotatorType annotatortype() const { return _annotator_type; };
-    void annotatortype( AnnotatorType t ) { _annotator_type =  t; };
-    double confidence() const { return _confidence; };
-    void confidence( double d ) { _confidence = d; };
-    AnnotationType::AnnotationType annotation_type() const { return _annotation_type; };
-    std::string classname() const { return toString(_element_id); };
-    std::string n() const { return _n; };
-    std::string id() const { return _id; };
-    ElementType element_id() const { return _element_id; };
-    std::string xmltag() const { return _xmltag; };
-    Document *doc() const { return mydoc; };
-    xmlNs *foliaNs() const;
-    virtual Sentence *sentence() const {
-      throw NotImplementedError("sentence() for " + _xmltag );
-    };
-    virtual Paragraph *paragraph() const {
-      throw NotImplementedError("paragraph() for " + _xmltag );
-    };
-    virtual Division *division() const {
-      throw NotImplementedError("division() for " + _xmltag );
-    };
-    virtual Correction *incorrection() const {
-      throw NotImplementedError("incorrection() for " + _xmltag );
-    };
-    virtual std::vector<Paragraph*> paragraphs() const {
-      throw NotImplementedError("paragraphs() for " + _xmltag );
-    };
-    virtual std::vector<Sentence*> sentences() const {
-      throw NotImplementedError("sentences() for " + _xmltag );
-    };
-    virtual std::vector<Word*> words() const {
-      throw NotImplementedError("words() for " + _xmltag );
-    };
-    virtual std::vector<Morpheme*> morphemes( const std::string& ) const {
-      throw NotImplementedError("morphemes() for " + _xmltag );
-    };
-    virtual Morpheme* morpheme( size_t, const std::string& ) const {
-      throw NotImplementedError("morpheme() for " + _xmltag );
-    };
-    virtual Sentence *sentences( size_t ) const {
-      throw NotImplementedError("sentences() for " + _xmltag );
-    };
-    virtual Sentence *rsentences( size_t ) const {
-      throw NotImplementedError("rsentences() for " + _xmltag );
-    };
-    virtual Paragraph *paragraphs( size_t ) const {
-      throw NotImplementedError("paragraphs() for " + _xmltag );
-    };
-    virtual Paragraph *rparagraphs( size_t ) const {
-      throw NotImplementedError("rparagraphs() for " + _xmltag );
-    };
-    virtual Word *words( size_t ) const {
-      throw NotImplementedError("words() for " + _xmltag );
-    };
-    virtual std::vector<Word *> wordParts() const {
-      throw NotImplementedError("words() for " + _xmltag );
-    };
-    virtual Word *rwords( size_t ) const {
-      throw NotImplementedError("rwords() for " + _xmltag );
-    };
-    virtual DependencyDependent *dependent() const {
-      throw NotImplementedError("dependent() for " + _xmltag );
-    };
+				    const std::string& = "" ) NOT_IMPLEMENTED;
 
-    virtual std::string description() const;
+    virtual Correction *deleteword( FoliaElement *,
+				    const std::string& = "" ) NOT_IMPLEMENTED;
+    virtual Correction *insertword( FoliaElement *, FoliaElement *,
+				    const std::string& = "" ) NOT_IMPLEMENTED;
+    virtual std::vector<Suggestion*> suggestions() const NOT_IMPLEMENTED;
+    virtual Suggestion *suggestions( size_t ) const NOT_IMPLEMENTED;
+    virtual std::string subset() const NOT_IMPLEMENTED;
+    virtual FoliaElement *previous() const NOT_IMPLEMENTED;
+    virtual FoliaElement *next() const NOT_IMPLEMENTED;
+    virtual std::vector<Word*> context( size_t,
+					const std::string& ="" ) const NOT_IMPLEMENTED;
+    virtual std::vector<Word*> leftcontext( size_t,
+					    const std::string& ="" ) const NOT_IMPLEMENTED;
+    virtual std::vector<Word*> rightcontext( size_t,
+					     const std::string& ="" ) const NOT_IMPLEMENTED;
+    virtual FoliaElement *findspan( const std::vector<FoliaElement*>& ) const NOT_IMPLEMENTED;
+    virtual int offset() const NOT_IMPLEMENTED;
+    virtual std::string getlang() const NOT_IMPLEMENTED;
+    virtual std::string setlang( const std::string& ) NOT_IMPLEMENTED;
+
+    virtual std::string pos( const std::string& = "" ) const = 0;
+    virtual std::string lemma( const std::string& = "" ) const = 0;
+    virtual std::string cls() const = 0;
+    virtual std::string sett() const = 0;
+    virtual std::string annotator( ) const = 0;
+    virtual void annotator( const std::string& ) = 0;
+    virtual AnnotatorType annotatortype() const = 0;
+    virtual void annotatortype( AnnotatorType t ) =  0;
+    virtual AnnotationType::AnnotationType annotation_type() const = 0;
+    virtual std::string classname() const = 0;
+    virtual std::string n() const = 0;
+    virtual std::string id() const = 0;
+    virtual ElementType element_id() const = 0;
+    virtual std::string xmltag() const = 0;
+    virtual Document *doc() const = 0;
+    //    virtual xmlNs *foliaNs() const = 0;
+    virtual Sentence *sentence() const NOT_IMPLEMENTED;
+    virtual Paragraph *paragraph() const NOT_IMPLEMENTED;
+    virtual Division *division() const NOT_IMPLEMENTED;
+    virtual Correction *incorrection() const NOT_IMPLEMENTED;
+    virtual std::vector<Paragraph*> paragraphs() const NOT_IMPLEMENTED;
+    virtual std::vector<Sentence*> sentences() const NOT_IMPLEMENTED;
+    virtual std::vector<Word*> words() const NOT_IMPLEMENTED;
+    virtual std::vector<FoliaElement*> wrefs() const NOT_IMPLEMENTED;
+
+    virtual std::vector<Morpheme*> morphemes( const std::string& ="" ) const NOT_IMPLEMENTED;
+    virtual Morpheme* morpheme( size_t, const std::string& ="" ) const NOT_IMPLEMENTED;
+    virtual Sentence *sentences( size_t ) const NOT_IMPLEMENTED;
+    virtual Sentence *rsentences( size_t ) const NOT_IMPLEMENTED;
+    virtual Paragraph *paragraphs( size_t ) const NOT_IMPLEMENTED;
+    virtual Paragraph *rparagraphs( size_t ) const NOT_IMPLEMENTED;
+    virtual Word *words( size_t ) const NOT_IMPLEMENTED;
+    virtual std::vector<Word *> wordParts() const NOT_IMPLEMENTED;
+    virtual Word *rwords( size_t ) const NOT_IMPLEMENTED;
+    virtual DependencyDependent *dependent() const NOT_IMPLEMENTED;
+
+    std::string description() const;
+    virtual Sentence *addSentence( const KWargs& ) = 0;
     Sentence *addSentence( const std::string& s ="" ){
       return addSentence( getArgs(s) );
     };
-    Sentence *addSentence( const KWargs& );
+    virtual Word *addWord( const KWargs& ) = 0;
     Word *addWord( const std::string& s ){
       return addWord( getArgs(s) );
     }
-    Word *addWord( const KWargs& );
     TextContent *settext( const std::string&, const std::string& = "current" );
     TextContent *settext( const std::string&, int , const std::string& = "current" );
+    TextContent *setutext( const UnicodeString&, const std::string& = "current" );
+    TextContent *setutext( const UnicodeString&, int , const std::string& = "current" );
 
-    template <typename F>
-      F *addAlternative();
-    template <typename F>
-      F *addAlternative( const KWargs& );
-
-    template <typename F>
-      F *addAnnotation( const KWargs& args ) {
-      F *res = 0;
-      try {
-	res = new F( mydoc, args);
-      }
-      catch( std::exception& ){
-	delete res;
-	throw;
-      }
-      append( res );
-      return res;
-    }
-    PosAnnotation *addPosAnnotation( const KWargs& );
-    LemmaAnnotation *addLemmaAnnotation( const KWargs& );
-    std::vector<Alternative*> alternatives( const std::string& s = "" ) const { 
-      return alternatives( BASE, s );
-    }
+    virtual PosAnnotation *addPosAnnotation( const KWargs& ) = 0;
+    virtual LemmaAnnotation *addLemmaAnnotation( const KWargs& ) = 0;
     virtual std::vector<Alternative *> alternatives( ElementType,
 						     const std::string& = ""
-						     ) const { 
-      throw NotImplementedError("alternatives() for " + _xmltag ); 
+						     ) const NOT_IMPLEMENTED;
+    std::vector<Alternative*> alternatives( const std::string& s = "" ) const {
+      return alternatives( BASE, s );
     }
     virtual std::string content() const {
       throw NoSuchAnnotation( "content" );
     }
-    virtual Correction *correct( const std::vector<FoliaElement*>,
-				 const std::vector<FoliaElement*>,
-				 const std::vector<FoliaElement*>,
-				 const std::vector<FoliaElement*>,
-				 const KWargs& ){
-      throw NotImplementedError("correct() for " + _xmltag );
-    }
+    virtual Correction *correct( const std::vector<FoliaElement*>&,
+				 const std::vector<FoliaElement*>&,
+				 const std::vector<FoliaElement*>&,
+				 const std::vector<FoliaElement*>&,
+				 const KWargs& ) NOT_IMPLEMENTED;
     virtual Correction* correct( FoliaElement*,
 				 FoliaElement*,
-				 const KWargs& ){
-      throw NotImplementedError("correct() for " + _xmltag );
-    }
-    virtual Correction *correct( const std::string& = "" ){
-      throw NotImplementedError("correct() for " + _xmltag ); };
-
-    virtual std::string src() const {
-      throw NotImplementedError("src() for " + _xmltag ); };
-
-    virtual UnicodeString caption() const {
-      throw NotImplementedError("caption() for " + _xmltag ); };
-
-    void increfcount() { ++refcount; };
-    FoliaElement *parent() const { return _parent; };
-    void setParent( FoliaElement *p ) { _parent = p ; };
-    void setAuth( bool b ){ _auth = b; };
-    virtual std::vector<FoliaElement *> resolve() const {
-      throw NotImplementedError("resolve() for " + _xmltag );
+				 const KWargs& ) NOT_IMPLEMENTED;
+    virtual Correction* correct( FoliaElement*,
+				 FoliaElement*,
+				 const std::vector<FoliaElement*>&,
+				 const KWargs& ) NOT_IMPLEMENTED;
+    virtual Correction *correct( const std::string& = "" ) NOT_IMPLEMENTED;
+    virtual std::string src() const NOT_IMPLEMENTED;
+    virtual UnicodeString caption() const NOT_IMPLEMENTED;
+    virtual int refcount() const = 0;
+    virtual void increfcount() = 0;
+    virtual FoliaElement *parent() const = 0;
+    virtual void setParent( FoliaElement *p ) = 0;
+    virtual void setAuth( bool b ) = 0;
+    virtual std::vector<FoliaElement *> resolve() const NOT_IMPLEMENTED;
+    virtual const FoliaElement* resolveid() const NOT_IMPLEMENTED;
+    bool isSubClass( ElementType ) const;
+    bool isSubClass( const FoliaElement *c ) const {
+      return isSubClass( c->element_id() );
     };
+    virtual std::string getTextDelimiter( bool retaintok=false ) const = 0;
+    virtual void setAttributes( const KWargs& ) = 0;
+    virtual KWargs collectAttributes() const = 0;
+    virtual std::string generateId( const std::string& ) NOT_IMPLEMENTED;
+    virtual size_t occurrences() const = 0;
+    virtual size_t occurrences_per_set() const = 0;
+    virtual Attrib required_attributes() const = 0;
+    virtual bool checkAtts() = 0;
 
-  protected:
     virtual void init()=0;
-    virtual KWargs collectAttributes() const;
-    virtual std::string getTextDelimiter( bool=false ) const { return TEXTDELIMITER; }
-    virtual std::string generateId( const std::string& ){
-      throw NotImplementedError( "generateId() not allowed for " + classname() );
-    };
     virtual bool allowannotations() const { return false; };
-    
+
+    virtual std::vector<FoliaElement*> select( ElementType elementtype,
+					       bool = true ) const = 0;
+    virtual std::vector<FoliaElement*> select( ElementType elementtype,
+					       const std::set<ElementType>& ,
+					       bool = true ) const = 0;
+    virtual std::vector<FoliaElement*> select( ElementType elementtype,
+					       const std::string&,
+					       bool = true ) const = 0;
+    virtual std::vector<FoliaElement*> select( ElementType elementtype,
+					       const std::string&,
+					       const std::set<ElementType>& ,
+					       bool = true ) const = 0;
+    virtual bool acceptable( ElementType ) const = 0;
+    virtual bool addable( const FoliaElement * ) const = 0;
+    template <typename F>
+      F *addAlternative();
+    template <typename F>
+      F *addAlternative( const KWargs& );
+
+  };
+
+  class FoliaImpl: public virtual FoliaElement {
+  public:
+    //Constructor
+    FoliaImpl( Document* = 0 );
+    virtual ~FoliaImpl();
+    // static element Constructor
+    static FoliaElement *createElement( Document *, const std::string&  );
+
+
     std::vector<FoliaElement*> select( ElementType elementtype,
 				       bool = true ) const;
     std::vector<FoliaElement*> select( ElementType elementtype,
@@ -463,10 +413,153 @@ namespace folia {
 				       const std::string&,
 				       const std::set<ElementType>& ,
 				       bool = true ) const;
-    bool acceptable( ElementType ) const;
     bool checkAtts();
     bool addable( const FoliaElement * ) const;
+    void classInit( const std::string& s="" ){
+      init(); // virtual init
+      if ( !s.empty() ){
+	// this enables the init of empty classes, which hopefully get their
+	// attributes in a later state
+	setAttributes(  getArgs( s ) );
+      }
+    }
+
+    void classInit( const KWargs& a ){
+      init(); // virtual init
+      setAttributes( a ); // also virtual!
+    }
+
+    template <typename F>
+      bool isinstance() const {
+      F obj("");
+      return element_id() == obj.element_id();
+    }
+
+    template <typename F>
+      std::vector<F*> select( bool recurse = true ) const {
+      return FoliaElement::select<F>(recurse);
+    }
+
+    template <typename F>
+      std::vector<F*> select( const std::string& st,
+			      const std::set<ElementType>& exclude,
+			      bool recurse = true ) const {
+      return FoliaElement::select<F>( st, exclude, recurse );
+    }
+
+    template <typename F>
+      std::vector<F*> select( const std::string& st,
+			      bool recurse = true ) const {
+      return FoliaElement::select<F>( st, recurse );
+    }
+
+    template <typename F>
+      std::vector<F*> select( const char* st,
+			      bool recurse = true ) const {
+      return FoliaElement::select<F>( st, recurse );
+    }
+
+    template <typename F>
+      std::vector<F*> select( const std::set<ElementType>& exclude,
+			      bool recurse = true ) const {
+      return FoliaElement::select<F>( exclude, recurse );
+    }
+
+    template <typename F>
+      F *addAnnotation( const KWargs& args ) {
+      return FoliaElement::addAnnotation<F>( args );
+    }
+
+    template <typename F>
+      std::vector<F*> annotations( const std::string& s = "" ) const {
+      return FoliaElement::annotations<F>( s );
+    }
+
+    template <typename F>
+      bool hasannotation( const std::string& st = "" ) const {
+      return FoliaElement::hasannotation<F>(st);
+    }
+
+    template <typename F>
+      F *annotation( const std::string& st = "" ) const {
+      return FoliaElement::annotation<F>(st);
+    }
+
+
+    bool acceptable( ElementType ) const;
+    void setAttributes( const KWargs& );
+    KWargs collectAttributes() const;
+    xmlNode *xml( bool, bool = false ) const;
+    FoliaElement* parseXml( const xmlNode * );
+    std::vector<std::string> feats( const std::string& ) const;
+    std::string feat( const std::string& ) const;
+    std::string str() const;
+    UnicodeString text( const std::string& = "current", bool = false ) const;
+    //functions regarding contained data
+    size_t size() const { return data.size(); };
+
 
+    FoliaElement* index( size_t ) const;
+    FoliaElement* rindex( size_t ) const;
+    std::string pos( const std::string& = "" ) const ;
+    std::string lemma( const std::string& = "" ) const;
+    std::string cls() const { return _class; };
+    std::string sett() const { return _set; };
+    void setDateTime( const std::string& );
+    std::string getDateTime() const;
+    std::vector<FoliaElement*> findreplacables( FoliaElement * ) const;
+    const Word* resolveword( const std::string& ) const { return 0; };
+    bool isinstance( ElementType et ) const {
+      return et == _element_id;
+    }
+
+    void fixupDoc( Document* );
+    FoliaElement *append( FoliaElement* );
+    FoliaElement *postappend( ) { return this; };
+    void remove( size_t, bool = true );
+    void remove( FoliaElement *, bool = true );
+    void replace( FoliaElement * );
+    FoliaElement* replace( FoliaElement *, FoliaElement* );
+
+    UnicodeString deeptext( const std::string& = "current", bool = false ) const;
+    UnicodeString toktext( const std::string& cls = "current" ) const {
+      return deeptext( cls, true );
+    }
+    TextContent *textcontent( const std::string& = "current" ) const;
+    std::string annotator( ) const { return _annotator; };
+    void annotator( const std::string& a ) { _annotator = a; };
+    AnnotatorType annotatortype() const { return _annotator_type; };
+    void annotatortype( AnnotatorType t ) { _annotator_type =  t; };
+    double confidence() const { return _confidence; };
+    void confidence( double d ) { _confidence = d; };
+    AnnotationType::AnnotationType annotation_type() const { return _annotation_type; };
+    std::string classname() const { return toString(_element_id); };
+    std::string n() const { return _n; };
+    std::string id() const { return _id; };
+    ElementType element_id() const { return _element_id; };
+    std::string xmltag() const { return _xmltag; };
+    Document *doc() const { return mydoc; };
+
+    int refcount() const { return _refcount; };
+    void increfcount() { ++_refcount; };
+    FoliaElement *parent() const { return _parent; };
+    void setParent( FoliaElement *p ) { _parent = p ; };
+    void setAuth( bool b ){ _auth = b; };
+    bool printable() const { return PRINTABLE; };
+    size_t occurrences() const { return _occurrences; };
+    size_t occurrences_per_set() const { return _occurrences_per_set; };
+    Attrib required_attributes() const { return _required_attributes; };
+    PosAnnotation *addPosAnnotation( const KWargs& );
+    LemmaAnnotation *addLemmaAnnotation( const KWargs& );
+    std::vector<AbstractSpanAnnotation*> selectSpan() const;
+    Sentence *addSentence( const KWargs& );
+    Word *addWord( const KWargs& );
+    std::string getTextDelimiter( bool retaintok=false ) const;
+  private:
+    void addFeatureNodes( const KWargs& args );
+
+  protected:
+    xmlNs *foliaNs() const;
     std::vector<FoliaElement*> data;
     FoliaElement *_parent;
     bool _auth;
@@ -478,15 +571,11 @@ namespace folia {
 
     Attrib _required_attributes;
     Attrib _optional_attributes;
-    size_t occurrences;
-    size_t occurrences_per_set;
+    size_t _occurrences;
+    size_t _occurrences_per_set;
     std::string TEXTDELIMITER;
     bool PRINTABLE;
     bool AUTH;
-
-    //common FoLiA attributes
-    //not applicable to all subtypes, but taking this slight extra memory 
-    //loss for granted. (Perhaps make them into pointers?)
     std::string _id;
     std::string _set;
     std::string _class;
@@ -495,58 +584,92 @@ namespace folia {
     std::string _datetime;
     AnnotatorType _annotator_type;
     double _confidence;
-    int refcount;
+    int _refcount;
   };
 
+  bool isSubClass( const ElementType e1, const ElementType e2 );
+
+  inline bool isSubClass( const FoliaElement *e1, const FoliaElement *e2 ){
+    return isSubClass( e1->element_id(), e2->element_id() );
+  }
+
   bool operator==( const FoliaElement&, const FoliaElement& );
   inline bool operator!=( const FoliaElement& e1, const FoliaElement& e2 ){
     return !( e1 == e2 );
   }
 
-  inline size_t len( const FoliaElement *e ) { 
+  inline size_t len( const FoliaElement *e ) {
     return e->size(); }
 
   template <typename T>
     inline size_t len( const std::vector<T>& v ) {
     return v.size(); }
-  inline std::string str( const FoliaElement *e ) { 
+
+  inline std::string str( const FoliaElement *e ) {
     return e->str(); }
-  inline UnicodeString text( const FoliaElement *e ) { 
+
+  inline UnicodeString text( const FoliaElement *e ) {
     if ( e )
       return e->text();
     else
       throw ValueError( "text() for empty element" );
   }
+
   inline UnicodeString unicode( const FoliaElement *e ) {
     return e->unicode(); }
-  inline bool isinstance( const FoliaElement *e, ElementType t ) { 
+
+  inline bool isinstance( const FoliaElement *e, ElementType t ) {
     return e->isinstance( t ); }
 
-  class AllowGenerateID {
+  class AllowGenerateID: public virtual FoliaElement {
   public:
     void setMaxId( FoliaElement * );
     int getMaxId( const std::string& );
-  protected:
-    std::string IGgen( const std::string&, const std::string& );
+    std::string generateId( const std::string& tag ){
+      return IDgen( tag, this );
+    }
   private:
+    std::string IDgen( const std::string&, const FoliaElement* );
     std::map<std::string, int> maxid;
   };
 
-  class AbstractStructureElement: public FoliaElement, AllowGenerateID {
-  public:  
-  AbstractStructureElement( Document *d=0 ): FoliaElement( d ) { classInit(); };
-    
+  class AllowCorrection: public virtual FoliaElement {
+  public:
+    Correction *correct( const std::vector<FoliaElement*>& v1,
+			 const std::vector<FoliaElement*>& v2,
+ 			 const std::vector<FoliaElement*>& v3,
+			 const std::vector<FoliaElement*>& v4,
+			 const KWargs& args );
+    Correction *correct( FoliaElement* o,
+			 FoliaElement* n,
+			 const KWargs& args ) {
+      const std::vector<FoliaElement*> v;
+      return correct( o, n, v, args );
+    }
+    Correction* correct( FoliaElement*,
+			 FoliaElement*,
+			 const std::vector<FoliaElement*>&,
+			 const KWargs& );
+    Correction *correct( const std::string& = "" );
+  };
+
+  class AllowAnnotation: public virtual FoliaElement {
+  public:
+    virtual bool allowannotations() const { return true; };
+  };
+
+  class AbstractStructureElement: public FoliaImpl,
+    public AllowGenerateID,
+    public AllowAnnotation,
+    public AllowCorrection {
+  public:
+  AbstractStructureElement( Document *d=0 ): FoliaImpl( d ) { classInit(); };
+
     std::string str() const;
-    bool allowannotations() const { return true; };
     std::vector<Alternative *> alternatives( ElementType = BASE,
 					     const std::string& = "" ) const;
-  
+
     FoliaElement *append( FoliaElement* );
-    Correction *correct( std::vector<FoliaElement*>,
-			 std::vector<FoliaElement*>,
-			 std::vector<FoliaElement*>,
-			 std::vector<FoliaElement*>,
-			 const KWargs& );
     std::vector<Paragraph*> paragraphs() const;
     std::vector<Sentence*> sentences() const;
     std::vector<Word*> words() const;
@@ -557,110 +680,146 @@ namespace folia {
     Word *words( size_t ) const;
     Word *rwords( size_t ) const;
     const Word* resolveword( const std::string& ) const;
-    std::string generateId( const std::string& tag ){
-      return IGgen( tag, _id ); 
-    }
   private:
     void init();
   };
 
-  class AbstractAnnotation: public FoliaElement {
-  public:
-  AbstractAnnotation( Document *d=0 ):  FoliaElement( d ){};
-  };
-
-  class AbstractTokenAnnotation: public AbstractAnnotation, AllowGenerateID {
+  class AbstractAnnotation: public FoliaImpl {
   public:
-  AbstractTokenAnnotation( Document *d=0 ):  AbstractAnnotation( d ){ classInit(); };
-    std::string generateId( const std::string& tag ){
-      return IGgen( tag, _id ); 
-    }
-  private:
-    void init();
+  AbstractAnnotation( Document *d=0 ): FoliaImpl( d ){};
   };
 
-  class AbstractSubTokenAnnotation: public AbstractAnnotation {
+  class AbstractTokenAnnotation:
+    public AbstractAnnotation,
+    public AllowGenerateID {
   public:
-  AbstractSubTokenAnnotation( Document *d=0 ):  AbstractAnnotation( d ){ classInit(); };
+  AbstractTokenAnnotation( Document *d=0 ): AbstractAnnotation( d ){ classInit(); };
   private:
     void init();
   };
 
-  class Feature: public FoliaElement {
+  class Feature: public FoliaImpl {
   public:
-  Feature( const std::string& s=""): FoliaElement( ){ classInit( s ); }
-  Feature( const KWargs& a ): FoliaElement( ){ classInit( a ); }
-  Feature( Document *d, const std::string& s=""): FoliaElement( d ){ classInit( s ); }
-  Feature( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); }
+  Feature( const std::string& s=""): FoliaImpl(){ classInit( s ); }
+  Feature( const KWargs& a ): FoliaImpl(){ classInit( a ); }
+  Feature( Document *d, const std::string& s=""): FoliaImpl(d){ classInit( s ); }
+  Feature( Document *d, const KWargs& a ): FoliaImpl(d){ classInit( a ); }
     void setAttributes( const KWargs& );
-    KWargs collectAttributes() const;  
+    KWargs collectAttributes() const;
     std::string subset() const { return _subset; };
 
   protected:
     std::string _subset;
-  
+
   private:
     void init();
   };
 
-  class AbstractSpanAnnotation: public AbstractAnnotation, AllowGenerateID {
+  class AbstractSpanAnnotation: public AbstractAnnotation,
+    public AllowGenerateID,
+    public AllowAnnotation,
+    public AllowCorrection
+    {
   public:
-  AbstractSpanAnnotation( Document *d=0 ):  AbstractAnnotation( d ){ classInit(); };
+  AbstractSpanAnnotation( Document *d=0 ): AbstractAnnotation( d ){ classInit(); };
     xmlNode *xml( bool, bool=false ) const;
     FoliaElement *append( FoliaElement* );
-    std::string generateId( const std::string& tag ){
-      return IGgen( tag, _id ); 
-    }
+
+    std::vector<FoliaElement*> wrefs() const;
+
   private:
     void init();
   };
 
-  class TextContent: public FoliaElement {
+  class AbstractTextMarkup: public AbstractAnnotation {
   public:
-  TextContent( const std::string& s="" ):  FoliaElement( ){ classInit( s ); }
-  TextContent( const KWargs& a ):  FoliaElement( ){ classInit( a ); }
-  TextContent( Document *d, const std::string& s="" ):  FoliaElement( d ){ classInit( s ); }
-  TextContent( Document *d, const KWargs& a ):  FoliaElement( d ){ classInit( a ); }
-    FoliaElement* parseXml( const xmlNode * );
-    xmlNode *xml( bool, bool=false ) const;
+  AbstractTextMarkup( Document *d=0 ): AbstractAnnotation( d ){ classInit(); };
+    void setAttributes( const KWargs& );
+    KWargs collectAttributes() const;
+    const FoliaElement* resolveid() const;
+    UnicodeString text( const std::string& = "current", bool = false ) const;
+  protected:
+    std::string getTextDelimiter( bool ) const { return ""; };
+    std::string idref;
+  private:
+    void init();
+  };
+
+  class TextMarkupGap: public AbstractTextMarkup {
+  public:
+  TextMarkupGap( Document *d=0 ): AbstractTextMarkup( d ){ classInit(); };
+  private:
+    void init();
+  };
+
+  class TextMarkupString: public AbstractTextMarkup {
+  public:
+  TextMarkupString( Document *d=0 ): AbstractTextMarkup( d ){ classInit(); };
+  private:
+    void init();
+  };
+
+  class TextMarkupCorrection: public AbstractTextMarkup {
+  public:
+  TextMarkupCorrection( Document *d=0 ): AbstractTextMarkup( d ){ classInit(); };
     void setAttributes( const KWargs& );
-    KWargs collectAttributes() const;  
+    KWargs collectAttributes() const;
+    UnicodeString text( const std::string& = "current", bool = false ) const;
+  private:
+    void init();
+    std::string _original;
+  };
+
+  class TextMarkupError: public AbstractTextMarkup {
+  public:
+  TextMarkupError( Document *d=0 ): AbstractTextMarkup( d ){ classInit(); };
+  private:
+    void init();
+  };
+
+  class TextMarkupStyle: public AbstractTextMarkup {
+  public:
+  TextMarkupStyle( Document *d=0 ): AbstractTextMarkup( d ){ classInit(); };
+  private:
+    void init();
+  };
+
+  class TextContent: public FoliaImpl {
+  public:
+  TextContent( const std::string& s="" ): FoliaImpl(){ classInit( s ); }
+  TextContent( const KWargs& a ): FoliaImpl(){ classInit( a ); }
+  TextContent( Document *d, const std::string& s="" ): FoliaImpl(d){ classInit( s ); }
+  TextContent( Document *d, const KWargs& a ): FoliaImpl(d){ classInit( a ); }
+    void setAttributes( const KWargs& );
+    KWargs collectAttributes() const;
     std::string str() const;
     UnicodeString text( const std::string& = "current", bool = false ) const;
     int offset() const { return _offset; };
-    std::string getlang() const { return _lang; };
-    std::string setlang( const std::string& l ) { 
-      std::string t = _lang;
-      _lang = l;
-      return t;
-    };
-    FoliaElement *append( FoliaElement* ){ 
-      throw NotImplementedError("TextContent::append() for " + _xmltag ); };
     TextContent *postappend();
     std::vector<FoliaElement*> findreplacables( FoliaElement * ) const;
   private:
     void init();
     int _offset;
-    std::string _lang;
+    std::string _lang; // UNUSED!
     UnicodeString _text;
   };
 
-  class FoLiA: public FoliaElement {
+  class FoLiA: public FoliaImpl {
   public:
-  FoLiA( const std::string& s="" ): FoliaElement( ) { classInit( s ); };
-  FoLiA( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  FoLiA( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  FoLiA( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  FoLiA( const std::string& s="" ): FoliaImpl() { classInit( s ); };
+  FoLiA( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  FoLiA( Document *d, const std::string& s=""): FoliaImpl(d) { classInit( s ); };
+  FoLiA( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
   private:
     void init();
   };
 
-  class DCOI: public FoliaElement {
+  class DCOI: public FoliaImpl {
   public:
-  DCOI( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  DCOI( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  DCOI( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  DCOI( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  DCOI( const std::string& s=""): FoliaImpl() { classInit( s ); };
+  DCOI( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  DCOI( Document *d, const std::string& s=""): FoliaImpl(d) { classInit( s ); };
+  DCOI( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
   private:
     void init();
   };
@@ -675,23 +834,63 @@ namespace folia {
     void init();
   };
 
-  class Gap: public FoliaElement {
+  class TableHead: public AbstractStructureElement {
+  public:
+  TableHead( const std::string& s=""): AbstractStructureElement() {  classInit( s ); };
+  TableHead( const KWargs& a ): AbstractStructureElement() {  classInit( a ); };
+  TableHead( Document *d, const std::string& s=""): AbstractStructureElement( d ) {  classInit( s ); };
+  TableHead( Document *d, const KWargs& a ): AbstractStructureElement( d ) {  classInit( a ); };
+  private:
+    void init();
+  };
+
+  class Table: public AbstractStructureElement {
+  public:
+  Table( const std::string& s=""): AbstractStructureElement() {  classInit( s ); };
+  Table( const KWargs& a ): AbstractStructureElement() {  classInit( a ); };
+  Table( Document *d, const std::string& s=""): AbstractStructureElement( d ) {  classInit( s ); };
+  Table( Document *d, const KWargs& a ): AbstractStructureElement( d ) {  classInit( a ); };
+  private:
+    void init();
+  };
+
+  class Row: public AbstractStructureElement {
   public:
-  Gap( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  Gap( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  Gap( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  Gap( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  Row( const std::string& s=""): AbstractStructureElement() {  classInit( s ); };
+  Row( const KWargs& a ): AbstractStructureElement() {  classInit( a ); };
+  Row( Document *d, const std::string& s=""): AbstractStructureElement( d ) {  classInit( s ); };
+  Row( Document *d, const KWargs& a ): AbstractStructureElement( d ) {  classInit( a ); };
+  private:
+    void init();
+  };
+
+  class Cell: public AbstractStructureElement {
+  public:
+  Cell( const std::string& s=""): AbstractStructureElement() {  classInit( s ); };
+  Cell( const KWargs& a ): AbstractStructureElement() {  classInit( a ); };
+  Cell( Document *d, const std::string& s=""): AbstractStructureElement( d ) {  classInit( s ); };
+  Cell( Document *d, const KWargs& a ): AbstractStructureElement( d ) {  classInit( a ); };
+  private:
+    void init();
+  };
+
+  class Gap: public FoliaImpl {
+  public:
+  Gap( const std::string& s=""): FoliaImpl() { classInit( s ); };
+  Gap( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  Gap( Document *d, const std::string& s=""): FoliaImpl(d) { classInit( s ); };
+  Gap( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
     std::string content() const;
   private:
     void init();
   };
 
-  class Content: public FoliaElement {
+  class Content: public FoliaImpl {
   public:
-  Content( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  Content( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  Content( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  Content( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  Content( const std::string& s=""): FoliaImpl() { classInit( s ); };
+  Content( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  Content( Document *d, const std::string& s=""): FoliaImpl(d) { classInit( s ); };
+  Content( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
     FoliaElement* parseXml( const xmlNode * );
     xmlNode *xml( bool, bool = false ) const;
     std::string content() const { return value; };
@@ -699,23 +898,23 @@ namespace folia {
     void init();
     std::string value;
   };
-  
-  class MetricAnnotation: public FoliaElement {
+
+  class MetricAnnotation: public FoliaImpl {
   public:
-  MetricAnnotation( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  MetricAnnotation( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  MetricAnnotation( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  MetricAnnotation( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  MetricAnnotation( const std::string& s=""): FoliaImpl() { classInit( s ); };
+  MetricAnnotation( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  MetricAnnotation( Document *d, const std::string& s=""): FoliaImpl(d) { classInit( s ); };
+  MetricAnnotation( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
   private:
     void init();
   };
 
   class Division: public AbstractStructureElement {
   public:
-  Division( const std::string& s=""):  AbstractStructureElement() { classInit( s ); };
-  Division( const KWargs& a ):  AbstractStructureElement() { classInit( a ); };
-  Division( Document *d, const std::string& s=""):  AbstractStructureElement( d ) { classInit( s ); };
-  Division( Document *d, const KWargs& a ):  AbstractStructureElement( d ) { classInit( a ); };
+  Division( const std::string& s=""): AbstractStructureElement() { classInit( s ); };
+  Division( const KWargs& a ): AbstractStructureElement() { classInit( a ); };
+  Division( Document *d, const std::string& s=""): AbstractStructureElement( d ) { classInit( s ); };
+  Division( Document *d, const KWargs& a ): AbstractStructureElement( d ) { classInit( a ); };
     Head *head() const;
   private:
     void init();
@@ -723,20 +922,23 @@ namespace folia {
 
   class LineBreak: public AbstractStructureElement {
   public:
-  LineBreak( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  LineBreak( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  LineBreak( Document *d,  const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  LineBreak( Document *d,  const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  LineBreak( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  LineBreak( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  LineBreak( Document *d,  const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  LineBreak( Document *d,  const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
+    UnicodeString text( const std::string& = "current", bool = false ) const {
+      return "";
+    }
   private:
     void init();
   };
 
   class WhiteSpace: public AbstractStructureElement {
   public:
-  WhiteSpace( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  WhiteSpace( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  WhiteSpace( Document *d,  const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  WhiteSpace( Document *d,  const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  WhiteSpace( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  WhiteSpace( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  WhiteSpace( Document *d,  const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  WhiteSpace( Document *d,  const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
@@ -744,13 +946,9 @@ namespace folia {
   class Word: public AbstractStructureElement {
   public:
   Word( const std::string& s="" ): AbstractStructureElement(){ classInit( s ); };
-  Word( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  Word( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  Word( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
-    Correction *correct( const std::string& = "" );
-    Correction *correct( FoliaElement*,
-			 FoliaElement*,
-			 const KWargs& );
+  Word( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  Word( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  Word( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
     FoliaElement *split( FoliaElement *, FoliaElement *,
 			 const std::string& = "" );
     Sentence *sentence() const;
@@ -761,35 +959,34 @@ namespace folia {
     Correction *incorrection() const;
     Word *previous() const;
     Word *next() const;
-    std::vector<Word*> context( size_t, 
+    std::vector<Word*> context( size_t,
 				const std::string& ="" ) const;
-    std::vector<Word*> leftcontext( size_t, 
+    std::vector<Word*> leftcontext( size_t,
 				    const std::string& = "" ) const;
-    std::vector<Word*> rightcontext( size_t, 
+    std::vector<Word*> rightcontext( size_t,
 				     const std::string& ="" ) const;
+    std::vector<FoliaElement*> findspans( ElementType,
+					  const std::string& = "" ) const;
     FoliaElement *append( FoliaElement *);
     const Word* resolveword( const std::string& ) const;
     void setAttributes( const KWargs& );
-    KWargs collectAttributes() const;  
-    std::string getTextDelimiter( bool retaintok=false) const { 
-      if ( space || retaintok )
-	return TEXTDELIMITER;
-      else {
-	return "";
-      }
-    }
+    KWargs collectAttributes() const;
+    std::string getTextDelimiter( bool=false) const;
   private:
     void init();
     bool space;
   };
 
-  class String: public AbstractTokenAnnotation {
+  class String:
+    public AbstractTokenAnnotation,
+    public AllowAnnotation,
+    public AllowCorrection {
   public:
   String( const std::string& s="" ): AbstractTokenAnnotation(){ classInit( s ); };
-  String( const KWargs& a ):  AbstractTokenAnnotation(){ classInit( a ); };
-  String( Document *d, const std::string& s=""):  AbstractTokenAnnotation( d ){ classInit( s ); };
-  String( Document *d, const KWargs& a ):  AbstractTokenAnnotation( d ){ classInit( a ); };
-  private:
+  String( const KWargs& a ): AbstractTokenAnnotation(){ classInit( a ); };
+  String( Document *d, const std::string& s=""): AbstractTokenAnnotation( d ){ classInit( s ); };
+  String( Document *d, const KWargs& a ): AbstractTokenAnnotation( d ){ classInit( a ); };
+    private:
     void init();
   };
 
@@ -806,13 +1003,13 @@ namespace folia {
 
   class Sentence: public AbstractStructureElement {
   public:
-  Sentence( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); }
-  Sentence( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); }
-  Sentence( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); }
-  Sentence( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); }
-    Correction *splitWord( FoliaElement *, FoliaElement *, 
+  Sentence( const std::string& s=""): AbstractStructureElement(){ classInit( s ); }
+  Sentence( const KWargs& a ): AbstractStructureElement(){ classInit( a ); }
+  Sentence( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); }
+  Sentence( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); }
+    Correction *splitWord( FoliaElement *, FoliaElement *,
 			   FoliaElement *, const KWargs& );
-    Correction *mergewords( FoliaElement *, 
+    Correction *mergewords( FoliaElement *,
 			    const std::vector<FoliaElement *>&,
 			    const std::string& = "" );
     Correction *deleteword( FoliaElement *, const std::string& args );
@@ -822,27 +1019,26 @@ namespace folia {
   private:
     Correction *correctWords( const std::vector<FoliaElement *>&,
 			      const std::vector<FoliaElement *>&,
-			      const std::vector<FoliaElement *>&, 
 			      const KWargs& );
     void init();
   };
 
   class Text: public AbstractStructureElement {
   public:
-  Text( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  Text( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  Text( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  Text( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  Text( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  Text( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  Text( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  Text( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
 
   class Event: public AbstractStructureElement {
   public:
-  Event( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  Event( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  Event( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  Event( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  Event( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  Event( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  Event( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  Event( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
@@ -851,50 +1047,50 @@ namespace folia {
   public:
   Caption( const std::string& s="" ): AbstractStructureElement(){ classInit( s ); };
   Caption( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
-  Caption( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  Caption( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  Caption( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  Caption( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
 
   class Label: public AbstractStructureElement {
   public:
-  Label( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
+  Label( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
   Label( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
-  Label( Document *d, const std::string& s="" ):  AbstractStructureElement( d ){ classInit( s ); };
+  Label( Document *d, const std::string& s="" ): AbstractStructureElement( d ){ classInit( s ); };
   Label( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
 
-  class ListItem: public AbstractStructureElement {
+  class Item: public AbstractStructureElement {
   public:
-  ListItem( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  ListItem( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  ListItem( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  ListItem( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  Item( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  Item( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  Item( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  Item( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
 
   class List: public AbstractStructureElement {
   public:
-  List( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  List( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  List( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  List( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  List( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  List( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  List( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  List( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
 
   class Figure: public AbstractStructureElement {
   public:
-  Figure( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  Figure( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  Figure( Document *d, const std::string& s="" ):  AbstractStructureElement( d ){ classInit( s ); };
-  Figure( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  Figure( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  Figure( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  Figure( Document *d, const std::string& s="" ): AbstractStructureElement( d ){ classInit( s ); };
+  Figure( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
     void setAttributes( const KWargs& );
-    KWargs collectAttributes() const;  
+    KWargs collectAttributes() const;
     std::string src() const { return _src; };
     UnicodeString caption() const;
   private:
@@ -904,32 +1100,31 @@ namespace folia {
 
   class Paragraph: public AbstractStructureElement {
   public:
-  Paragraph( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  Paragraph( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  Paragraph( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  Paragraph( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
+  Paragraph( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  Paragraph( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  Paragraph( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  Paragraph( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
 
   class Alternative: public AbstractStructureElement {
   public:
-  Alternative( const std::string& s=""):  AbstractStructureElement(){ classInit( s ); };
-  Alternative( const KWargs& a ):  AbstractStructureElement(){ classInit( a ); };
-  Alternative( Document *d, const std::string& s=""):  AbstractStructureElement( d ){ classInit( s ); };
-  Alternative( Document *d, const KWargs& a ):  AbstractStructureElement( d ){ classInit( a ); };
-    bool allowannotations() const { return true; };
+  Alternative( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  Alternative( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  Alternative( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  Alternative( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
   private:
     void init();
   };
 
-  
-  class AlternativeLayers: public FoliaElement {
+
+  class AlternativeLayers: public FoliaImpl {
   public:
-  AlternativeLayers( const std::string& s=""): FoliaElement(){ classInit( s ); };
-  AlternativeLayers( const KWargs& a ): FoliaElement(){ classInit( a ); };
-  AlternativeLayers( Document *d, const std::string& s=""): FoliaElement( d ){ classInit( s ); };
-  AlternativeLayers( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); };
+  AlternativeLayers( const std::string& s=""): FoliaImpl(){ classInit( s ); };
+  AlternativeLayers( const KWargs& a ): FoliaImpl(){ classInit( a ); };
+  AlternativeLayers( Document *d, const std::string& s=""): FoliaImpl(d){ classInit( s ); };
+  AlternativeLayers( Document *d, const KWargs& a ): FoliaImpl(d){ classInit( a ); };
   private:
     void init();
   };
@@ -942,7 +1137,7 @@ namespace folia {
     F *res = 0;
     Alternative *alt = 0;
     try {
-      alt = new Alternative( mydoc, kw );
+      alt = new Alternative( doc(), kw );
       res = alt->addAnnotation<F>( args );
     }
     catch( std::exception& ){
@@ -952,6 +1147,7 @@ namespace folia {
     append( alt );
     return res;
   }
+
   template <typename F>
     F *FoliaElement::addAlternative(){
     KWargs numb;
@@ -978,6 +1174,16 @@ namespace folia {
     void init();
   };
 
+  class LangAnnotation: public AbstractTokenAnnotation {
+  public:
+  LangAnnotation( const std::string& s=""): AbstractTokenAnnotation(){ classInit( s ); };
+  LangAnnotation( const KWargs& a ): AbstractTokenAnnotation(){ classInit( a ); };
+  LangAnnotation( Document *d, const std::string& s=""): AbstractTokenAnnotation( d ){ classInit( s ); };
+  LangAnnotation( Document *d, const KWargs& a ): AbstractTokenAnnotation( d ){ classInit( a ); };
+  private:
+    void init();
+  };
+
   class PhonAnnotation: public AbstractTokenAnnotation {
   public:
   PhonAnnotation( const std::string& s=""): AbstractTokenAnnotation(){ classInit( s ); };
@@ -1026,6 +1232,7 @@ namespace folia {
   Quote( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
     FoliaElement *append( FoliaElement *);
     std::vector<Word*> wordParts() const;
+    std::string getTextDelimiter( bool=false) const;
   private:
     void init();
   };
@@ -1130,41 +1337,41 @@ namespace folia {
     void init();
   };
 
-  class WordReference: public FoliaElement {
+  class WordReference: public FoliaImpl {
   public:
-  WordReference( const std::string& s="" ): FoliaElement( ){ classInit( s ); };
-  WordReference( const KWargs& a ): FoliaElement( ){ classInit( a ); };
-  WordReference( Document *d, const std::string& s="" ): FoliaElement( d ){ classInit( s ); };
-  WordReference( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); };
+  WordReference( const std::string& s="" ): FoliaImpl(){ classInit( s ); };
+  WordReference( const KWargs& a ): FoliaImpl(){ classInit( a ); };
+  WordReference( Document *d, const std::string& s="" ): FoliaImpl(d){ classInit( s ); };
+  WordReference( Document *d, const KWargs& a ): FoliaImpl(d){ classInit( a ); };
   private:
     void init();
     FoliaElement* parseXml( const xmlNode *node );
-  };  
+  };
 
-  class Alignment: public FoliaElement {
+  class Alignment: public FoliaImpl {
   public:
-  Alignment( const std::string& s="" ): FoliaElement( ){ classInit( s ); };
-  Alignment( const KWargs& a ): FoliaElement( ){ classInit( a ); };
-  Alignment( Document *d, const std::string& s="" ): FoliaElement( d ){ classInit( s ); };
-  Alignment( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); };
+  Alignment( const std::string& s="" ): FoliaImpl(){ classInit( s ); };
+  Alignment( const KWargs& a ): FoliaImpl(){ classInit( a ); };
+  Alignment( Document *d, const std::string& s="" ): FoliaImpl(d){ classInit( s ); };
+  Alignment( Document *d, const KWargs& a ): FoliaImpl(d){ classInit( a ); };
     std::string href() const { return _href; };
     std::vector<FoliaElement *>resolve() const;
-    KWargs collectAttributes() const;  
+    KWargs collectAttributes() const;
     void setAttributes( const KWargs& );
   private:
     void init();
     std::string _href;
     std::string _type;
-  };  
+  };
 
-  class AlignReference: public FoliaElement {
+  class AlignReference: public FoliaImpl {
     friend class Alignment;
   public:
-  AlignReference( const std::string& s="" ): FoliaElement( ){ classInit( s ); };
-  AlignReference( const KWargs& a ): FoliaElement( ){ classInit( a ); };
-  AlignReference( Document *d, const std::string& s="" ): FoliaElement( d ){ classInit( s ); };
-  AlignReference( Document *d, const KWargs& a ): FoliaElement( d ){ classInit( a ); };
-    KWargs collectAttributes() const;  
+  AlignReference( const std::string& s="" ): FoliaImpl(){ classInit( s ); };
+  AlignReference( const KWargs& a ): FoliaImpl(){ classInit( a ); };
+  AlignReference( Document *d, const std::string& s="" ): FoliaImpl(d){ classInit( s ); };
+  AlignReference( Document *d, const KWargs& a ): FoliaImpl(d){ classInit( a ); };
+    KWargs collectAttributes() const;
     void setAttributes( const KWargs& );
   private:
     void init();
@@ -1173,7 +1380,7 @@ namespace folia {
     std::string refId;
     std::string _type;
     std::string _t;
-  };  
+  };
 
   class SyntacticUnit: public AbstractSpanAnnotation {
   public:
@@ -1267,22 +1474,23 @@ namespace folia {
     void init();
   };
 
-  class AbstractAnnotationLayer: public FoliaElement, AllowGenerateID {
+  class AbstractAnnotationLayer: public FoliaImpl,
+    public AllowGenerateID,
+    public AllowAnnotation,
+    public AllowCorrection {
   public:
-  AbstractAnnotationLayer( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  AbstractAnnotationLayer( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  AbstractAnnotationLayer( Document *d, const std::string& s=""): FoliaElement( d ) { classInit( s ); };
-  AbstractAnnotationLayer( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
-    std::string generateId( const std::string& tag ){
-      return IGgen( tag, _id ); 
-    }
+  AbstractAnnotationLayer( const std::string& s=""): FoliaImpl() { classInit( s ); };
+  AbstractAnnotationLayer( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  AbstractAnnotationLayer( Document *d, const std::string& s=""): FoliaImpl(d) { classInit( s ); };
+  AbstractAnnotationLayer( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
+    FoliaElement *findspan( const std::vector<FoliaElement*>& ) const;
   private:
     void init();
   };
 
-  class AbstractCorrectionChild: public FoliaElement {
+  class AbstractCorrectionChild: public FoliaImpl {
   public:
-  AbstractCorrectionChild( Document *d=0 ):  FoliaElement( d ){ classInit(); };
+  AbstractCorrectionChild( Document *d=0 ): FoliaImpl(d){ classInit(); };
   private:
     void init();
   };
@@ -1327,12 +1535,12 @@ namespace folia {
     void init();
   };
 
-  class Description: public FoliaElement {
+  class Description: public FoliaImpl {
   public:
-  Description( const std::string& s=""): FoliaElement( ) { classInit( s ); };
-  Description( const KWargs& a ): FoliaElement( ) { classInit( a ); };
-  Description( Document *d, const std::string& s="" ): FoliaElement( d ) { classInit( s ); };
-  Description( Document *d, const KWargs& a ): FoliaElement( d ) { classInit( a ); };
+  Description( const std::string& s=""): FoliaImpl() { classInit( s ); };
+  Description( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  Description( Document *d, const std::string& s="" ): FoliaImpl(d) { classInit( s ); };
+  Description( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
     std::string description() const { return _value; };
     void setAttributes( const KWargs& kwargs );
     FoliaElement* parseXml( const xmlNode * );
@@ -1342,6 +1550,81 @@ namespace folia {
     std::string _value;
   };
 
+  class XmlComment: public FoliaImpl {
+  public:
+  XmlComment( const std::string& s=""): FoliaImpl() { classInit( s ); };
+  XmlComment( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  XmlComment( Document *d, const std::string& s="" ): FoliaImpl(d) { classInit( s ); };
+  XmlComment( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
+    FoliaElement* parseXml( const xmlNode * );
+    xmlNode *xml( bool, bool=false ) const;
+  private:
+    void init();
+    std::string _value;
+  };
+
+  class XmlText: public FoliaImpl {
+  public:
+  XmlText( const std::string& s=""): FoliaImpl() { classInit( s ); };
+  XmlText( const KWargs& a ): FoliaImpl() { classInit( a ); };
+  XmlText( Document *d, const std::string& s="" ): FoliaImpl(d) { classInit( s ); };
+  XmlText( Document *d, const KWargs& a ): FoliaImpl( d ) { classInit( a ); };
+    FoliaElement* parseXml( const xmlNode * );
+    xmlNode *xml( bool, bool=false ) const;
+    bool setvalue( const std::string& s ) { _value = s; return true; };
+    std::string getTextDelimiter( bool ) const { return ""; };
+    UnicodeString text( const std::string&, bool ) const;
+  private:
+    void init();
+    std::string _value; //UTF8 value
+  };
+
+  class External: public FoliaImpl {
+  public:
+  External( const std::string& s=""): FoliaImpl( ) { classInit( s ); };
+  External( const KWargs& a ): FoliaImpl( ) { classInit( a ); };
+  External( Document *d, const std::string& s="" ): FoliaImpl(d) { classInit( s ); };
+  External( Document *d, const KWargs& a ): FoliaImpl(d) { classInit( a ); };
+    FoliaElement* parseXml( const xmlNode * );
+    void resolve();
+    void setAttributes( const KWargs& );
+    KWargs collectAttributes() const;
+  private:
+    void init();
+    std::string _src;
+    bool _include;
+  };
+
+
+  class Note: public AbstractStructureElement {
+  public:
+  Note( const std::string& s=""): AbstractStructureElement(){ classInit( s ); };
+  Note( const KWargs& a ): AbstractStructureElement(){ classInit( a ); };
+  Note( Document *d, const std::string& s=""): AbstractStructureElement( d ){ classInit( s ); };
+  Note( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
+    KWargs collectAttributes() const;
+    void setAttributes( const KWargs& );
+  private:
+    void init();
+    std::string refId;
+  };
+
+  class Reference: public AbstractStructureElement {
+    friend class Note;
+  public:
+  Reference( const std::string& s="" ): AbstractStructureElement( ){ classInit( s ); };
+  Reference( const KWargs& a ): AbstractStructureElement( ){ classInit( a ); };
+  Reference( Document *d, const std::string& s="" ): AbstractStructureElement( d ){ classInit( s ); };
+  Reference( Document *d, const KWargs& a ): AbstractStructureElement( d ){ classInit( a ); };
+    KWargs collectAttributes() const;
+    void setAttributes( const KWargs& );
+  private:
+    void init();
+    std::string refId;
+    std::string _type;
+  };
+
+
   class Correction: public AbstractTokenAnnotation {
   public:
   Correction( const std::string& s=""): AbstractTokenAnnotation( ){ classInit( s ); }
@@ -1359,12 +1642,13 @@ namespace folia {
     Suggestion *suggestions( size_t ) const;
     UnicodeString text( const std::string& = "current", bool = false ) const;
     TextContent *textcontent( const std::string& = "current" ) const;
+    std::string getTextDelimiter( bool=false) const;
   private:
     void init();
   };
 
   class ErrorDetection: public AbstractTokenAnnotation  {
-  public: 
+  public:
   ErrorDetection( const std::string& s=""): AbstractTokenAnnotation(){ classInit( s ); }
   ErrorDetection( const KWargs& a ): AbstractTokenAnnotation(){ classInit( a ); }
   ErrorDetection( Document *d, const std::string& s=""): AbstractTokenAnnotation( d ){ classInit( s ); }
@@ -1373,20 +1657,6 @@ namespace folia {
     void init();
   };
 
-  class AbstractSubtokenAnnotation: public AbstractAnnotation, AllowGenerateID {
-  public:
-  AbstractSubtokenAnnotation( const std::string& s="" ): AbstractAnnotation( ){ classInit( s ); }
-  AbstractSubtokenAnnotation( const KWargs& a ): AbstractAnnotation( ){ classInit( a ); }
-  AbstractSubtokenAnnotation( Document *d, const std::string& s="" ): AbstractAnnotation( d ){ classInit( s ); }
-  AbstractSubtokenAnnotation( Document *d, const KWargs& a ): AbstractAnnotation( d ){ classInit( a ); }
-    std::string generateId( const std::string& tag ){
-      return IGgen( tag, _id ); 
-    }
-
-  private:
-    void init();
-  };
-
   class TimeSegment: public AbstractSpanAnnotation {
   public:
   TimeSegment( const std::string& s="" ): AbstractSpanAnnotation(){ classInit( s ); }
@@ -1407,16 +1677,6 @@ namespace folia {
     void init();
   };
 
-  class Subentity: public AbstractSubtokenAnnotation {
-  public:
-  Subentity( const std::string& s="" ): AbstractSubtokenAnnotation(){ classInit( s ); }
-  Subentity( const KWargs& a ): AbstractSubtokenAnnotation(){ classInit( a ); }
-  Subentity( Document *d, const std::string& s="" ): AbstractSubtokenAnnotation( d ){ classInit( s ); }
-  Subentity( Document *d, const KWargs& a ): AbstractSubtokenAnnotation( d ){ classInit( a ); }
-  private:
-    void init();
-  };
-
   class SyntaxLayer: public AbstractAnnotationLayer {
   public:
   SyntaxLayer( const std::string& s=""): AbstractAnnotationLayer(){ classInit( s ); }
diff --git a/include/libfolia/foliautils.h b/include/libfolia/foliautils.h
index 956d810..d07f9e9 100644
--- a/include/libfolia/foliautils.h
+++ b/include/libfolia/foliautils.h
@@ -1,11 +1,11 @@
 /*
-  $Id: foliautils.h 15907 2013-04-03 13:43:03Z sloot $
+  $Id: foliautils.h 17477 2014-08-05 12:59:20Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/libfolia/foliautils.h $
 
-  Copyright (c) 1998 - 2013
+  Copyright (c) 1998 - 2014
   ILK   - Tilburg University
   CLiPS - University of Antwerp
- 
+
   This file is part of libfolia
 
   libfolia is free software; you can redistribute it and/or modify
@@ -46,12 +46,12 @@
 
 namespace folia {
   enum AnnotatorType{ UNDEFINED = -1, AUTO = 0, MANUAL = 1 };
-  
-  enum Attrib { NO_ATT=0, ID=1, CLASS=2, ANNOTATOR=4, CONFIDENCE=8, 
+
+  enum Attrib { NO_ATT=0, ID=1, CLASS=2, ANNOTATOR=4, CONFIDENCE=8,
 		N=16, DATETIME=32, SETONLY=64, ALL=127 };
-  
+
   inline Attrib& operator++( Attrib & a ){
-    return a = ( SETONLY == a ) 
+    return a = ( SETONLY == a )
       ? NO_ATT
       : ( NO_ATT == a ? ID : Attrib(a<<1) );
   }
@@ -59,59 +59,65 @@ namespace folia {
   inline Attrib operator|( Attrib a1, Attrib a2 ){
     return (Attrib) ((int)a1|(int)a2) ;
   }
-  
+
   inline Attrib& operator|=( Attrib& a1, Attrib& a2 ){
     a1 = (a1 | a2);
     return a1;
   }
-  
+
   enum ElementType  {
     BASE=0, TextContent_t,
     Text_t, Word_t, Str_t,
-    WordReference_t, Event_t, 
+    WordReference_t, Event_t,
     TimeSegment_t, TimingLayer_t,
-    LineBreak_t, WhiteSpace_t, 
+    LineBreak_t, WhiteSpace_t,
     Sentence_t, Paragraph_t,
-    Division_t, Head_t, 
+    Division_t, Head_t,
     Caption_t, Label_t,
-    List_t, ListItem_t,
+    List_t, Item_t,
     Figure_t, Quote_t, //structure annotation elements
-    Pos_t, Lemma_t, 
-    Phon_t, Domain_t, 
+    Pos_t, Lemma_t,
+    Phon_t, Domain_t,
     Sense_t, Subjectivity_t,
     Metric_t, Correction_t, //token annotation elements
-    AnnotationLayer_t, SyntacticUnit_t, 
-    Chunk_t, Chunking_t, 
-    Entity_t, Entities_t, 
-    Coreferences_t, CoreferenceLink_t, 
-    CoreferenceChain_t,  SyntaxLayer_t, 
+    AnnotationLayer_t, SpanAnnotation_t,
+    SyntacticUnit_t,
+    Chunk_t, Chunking_t,
+    Entity_t, Entities_t,
+    Coreferences_t, CoreferenceLink_t,
+    CoreferenceChain_t,  SyntaxLayer_t,
     Semroles_t, Semrole_t,
-    //    Subentity_t, Subentities_t, //annotation layers
-    Morphology_t, Morpheme_t, 
-    ErrorDetection_t, New_t, 
-    Original_t, Current_t, 
+    Morphology_t, Morpheme_t,
+    ErrorDetection_t, New_t,
+    Original_t, Current_t,
     Alternative_t, Alternatives_t, //alternatives
-    Description_t, Gap_t, 
-    Suggestion_t, Content_t, 
-    Feature_t, SynsetFeature_t, 
-    ActorFeature_t, HeadFeature_t, 
-    ValueFeature_t, TimeFeature_t, 
+    Description_t, Gap_t,
+    Suggestion_t, Content_t,
+    Feature_t, SynsetFeature_t,
+    ActorFeature_t, HeadFeature_t,
+    ValueFeature_t, TimeFeature_t,
     ModalityFeature_t, LevelFeature_t,
     BeginDateTimeFeature_t, EndDateTimeFeature_t,
     FunctionFeature_t, //features
     PlaceHolder_t,
-    Dependencies_t, Dependency_t, 
+    Dependencies_t, Dependency_t,
     Headwords_t, DependencyDependent_t,
     Alignment_t, AlignReference_t,
+    Table_t, TableHead_t, Row_t, Cell_t,
+    Lang_t, XmlComment_t,
+    TokenAnnotation_t, Structure_t,
+    AbstractTextMarkup_t, TextMarkupString_t, TextMarkupGap_t,
+    TextMarkupCorrection_t, TextMarkupError_t, TextMarkupStyle_t,
+    XmlText_t, External_t, Note_t, Reference_t,
     LastElement
   };
-  
+
   inline ElementType& operator++( ElementType &et ){
-    return et = ( LastElement == et ) 
-      ? BASE 
+    return et = ( LastElement == et )
+      ? BASE
       : ElementType(et+1);
   }
-    
+
   /*
    * Annotation types tie FoLiA elements to a particular kind of annotation.
    * Especially declarations make use of this.
@@ -119,105 +125,106 @@ namespace folia {
    */
   namespace AnnotationType {
     enum AnnotationType { NO_ANN, TEXT, TOKEN, DIVISION, PARAGRAPH, STRING,
-			  LIST, FIGURE, WHITESPACE, LINEBREAK, SENTENCE, 
+			  LIST, FIGURE, WHITESPACE, LINEBREAK, SENTENCE,
 			  POS, LEMMA, DOMEIN, SENSE, SYNTAX, CHUNKING, ENTITY,
 			  // Attention DOMAIN seems to be a defined constant
 			  // where/how/why?
-			  CORRECTION, SUGGESTION, ERRORDETECTION, ALTERNATIVE, 
-			  PHON, SUBJECTIVITY, MORPHOLOGICAL, SUBENTITY, EVENT, 
-			  DEPENDENCY, TIMEDEVENT, GAP, ALIGNMENT, 
+			  CORRECTION, SUGGESTION, ERRORDETECTION, ALTERNATIVE,
+			  PHON, SUBJECTIVITY, MORPHOLOGICAL, SUBENTITY, EVENT,
+			  DEPENDENCY, TIMEDEVENT, GAP, ALIGNMENT,
 			  COMPLEXALIGNMENT, COREFERENCE, SEMROLE, METRIC,
+			  TABLE, LANG, STYLE, NOTE,
 			  LAST_ANN
     };
     inline AnnotationType& operator++( AnnotationType &at ){
-      return at = ( LAST_ANN == at ) 
-	? NO_ANN 
+      return at = ( LAST_ANN == at )
+	? NO_ANN
 	: AnnotationType(at+1);
     }
   }
 
   enum MetaDataType { NATIVE, CMDI, IMDI };
-  
+
   class ArgsError: public std::runtime_error {
   public:
   ArgsError( const std::string& s ): std::runtime_error( "error in argument list: " + s  ){};
   };
-  
+
   class KeyError: public std::out_of_range {
   public:
   KeyError(): std::out_of_range( "key out of range" ){};
   };
-  
+
   class NotImplementedError: public std::runtime_error {
   public:
-  NotImplementedError( const std::string& s ): 
+  NotImplementedError( const std::string& s ):
     std::runtime_error( "NOT IMPLEMENTED: " + s ){};
   };
-  
+
   class ValueError: public std::runtime_error {
   public:
   ValueError( const std::string& s ): std::runtime_error( s ){};
   };
-  
+
   class XmlError: public std::runtime_error {
   public:
   XmlError( const std::string& s ): std::runtime_error( "XML error: " + s ){};
   };
-  
+
   class NoSuchAnnotation: public std::runtime_error {
   public:
   NoSuchAnnotation( ): std::runtime_error( "no such annotation" ){};
   NoSuchAnnotation( const std::string& s ): std::runtime_error( "no such annotation: " + s ){};
   };
-  
+
   class NoSuchText: public std::runtime_error {
   public:
   NoSuchText( ): std::runtime_error( "no such text" ){};
   NoSuchText( const std::string& s ): std::runtime_error( "no such text: " + s ){};
   };
-  
+
   class NoDescription: public std::runtime_error {
   public:
   NoDescription( ): std::runtime_error( "no description" ){};
   };
-  
+
   class DuplicateAnnotationError: public std::runtime_error {
   public:
   DuplicateAnnotationError( const std::string& s ): std::runtime_error( s ){};
   };
-  
+
   class DuplicateIDError: public std::runtime_error {
   public:
   DuplicateIDError( const std::string& s ): std::runtime_error( "duplicate ID : " + s ){};
   };
-  
+
   class NoDefaultError: public std::runtime_error {
   public:
   NoDefaultError( const std::string& s ): std::runtime_error( "No Default found: " + s ){};
   };
-  
+
   UnicodeString UTF8ToUnicode( const std::string& );
   std::string UnicodeToUTF8( const UnicodeString& );
-  
+
   std::string toString( const AnnotationType::AnnotationType& );
   AnnotatorType stringToANT( const std::string& );
-  
+
   AnnotationType::AnnotationType stringToAT( const std::string& );
-  
+
   std::string toString( const ElementType& );
   ElementType stringToET( const std::string& );
-  
+
   typedef std::map<std::string, std::string> KWargs;
-  
+
   KWargs getArgs( const std::string& );
   std::string toString( const KWargs& );
-  
-  inline std::ostream& operator<<( std::ostream& os, 
+
+  inline std::ostream& operator<<( std::ostream& os,
 				   const AnnotationType::AnnotationType& at ){
     os << toString( at );
     return os;
   }
-  
+
 }
 
 namespace TiCC {
@@ -225,7 +232,7 @@ namespace TiCC {
     inline folia::AnnotationType::AnnotationType stringTo( const std::string& str ) {
     return folia::stringToAT( str );
   }
-  
+
   template<>
     inline folia::ElementType stringTo( const std::string& str ) {
     return folia::stringToET( str );
@@ -241,7 +248,7 @@ namespace TiCC {
     else
       return folia::UNDEFINED;
   }
-  
+
 }
 
 namespace folia {
@@ -256,7 +263,8 @@ namespace folia {
 
   bool isNCName( const std::string& );
 
-  inline std::string strip( const std::string& s ){ return TiCC::trim(s); };
+  inline std::string strip( const std::string& s ){ return TiCC::trim(s); }
+
 } // namespace folia
 
 #endif // FOLIA_UTILS
diff --git a/install-sh b/install-sh
index 6781b98..377bb86 100755
--- a/install-sh
+++ b/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2009-04-28.21; # UTC
+scriptversion=2011-11-20.07; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -35,7 +35,7 @@ scriptversion=2009-04-28.21; # UTC
 # FSF changes to this file are in the public domain.
 #
 # Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
+# 'make' implicit rules from creating a file called install from it
 # when there is no Makefile.
 #
 # This script is compatible with the BSD install script, but was written
@@ -156,6 +156,10 @@ while test $# -ne 0; do
     -s) stripcmd=$stripprog;;
 
     -t) dst_arg=$2
+	# Protect names problematic for 'test' and other utilities.
+	case $dst_arg in
+	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
+	esac
 	shift;;
 
     -T) no_target_directory=true;;
@@ -186,6 +190,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
     fi
     shift # arg
     dst_arg=$arg
+    # Protect names problematic for 'test' and other utilities.
+    case $dst_arg in
+      -* | [=\(\)!]) dst_arg=./$dst_arg;;
+    esac
   done
 fi
 
@@ -194,13 +202,17 @@ if test $# -eq 0; then
     echo "$0: no input file specified." >&2
     exit 1
   fi
-  # It's OK to call `install-sh -d' without argument.
+  # It's OK to call 'install-sh -d' without argument.
   # This can happen when creating conditional directories.
   exit 0
 fi
 
 if test -z "$dir_arg"; then
-  trap '(exit $?); exit' 1 2 13 15
+  do_exit='(exit $ret); exit $ret'
+  trap "ret=129; $do_exit" 1
+  trap "ret=130; $do_exit" 2
+  trap "ret=141; $do_exit" 13
+  trap "ret=143; $do_exit" 15
 
   # Set umask so as not to create temps with too-generous modes.
   # However, 'strip' requires both read and write access to temps.
@@ -228,9 +240,9 @@ fi
 
 for src
 do
-  # Protect names starting with `-'.
+  # Protect names problematic for 'test' and other utilities.
   case $src in
-    -*) src=./$src;;
+    -* | [=\(\)!]) src=./$src;;
   esac
 
   if test -n "$dir_arg"; then
@@ -252,12 +264,7 @@ do
       echo "$0: no destination specified." >&2
       exit 1
     fi
-
     dst=$dst_arg
-    # Protect names starting with `-'.
-    case $dst in
-      -*) dst=./$dst;;
-    esac
 
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
@@ -347,7 +354,7 @@ do
 	      if test -z "$dir_arg" || {
 		   # Check for POSIX incompatibilities with -m.
 		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-		   # other-writeable bit of parent directory when it shouldn't.
+		   # other-writable bit of parent directory when it shouldn't.
 		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
 		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
 		   case $ls_ld_tmpdir in
@@ -385,7 +392,7 @@ do
 
       case $dstdir in
 	/*) prefix='/';;
-	-*) prefix='./';;
+	[-=\(\)!]*) prefix='./';;
 	*)  prefix='';;
       esac
 
@@ -403,7 +410,7 @@ do
 
       for d
       do
-	test -z "$d" && continue
+	test X"$d" = X && continue
 
 	prefix=$prefix$d
 	if test -d "$prefix"; then
diff --git a/ltmain.sh b/ltmain.sh
index c2852d8..a356aca 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -70,7 +70,7 @@
 #         compiler:		$LTCC
 #         compiler flags:		$LTCFLAGS
 #         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1
+#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
 #         automake:	$automake_version
 #         autoconf:	$autoconf_version
 #
@@ -80,7 +80,7 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1ubuntu1"
+VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
 TIMESTAMP=""
 package_revision=1.3337
 
diff --git a/m4/Makefile.in b/m4/Makefile.in
index dc24a41..56323e3 100644
--- a/m4/Makefile.in
+++ b/m4/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -18,6 +17,51 @@
 # $Id: $
 # $URL: $
 VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -37,7 +81,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = m4
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_icu_check.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -50,11 +94,30 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 SOURCES =
 DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -100,7 +163,6 @@ LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
@@ -227,11 +289,11 @@ mostlyclean-libtool:
 
 clean-libtool:
 	-rm -rf .libs _libs
-tags: TAGS
-TAGS:
+tags TAGS:
+
+ctags CTAGS:
 
-ctags: CTAGS
-CTAGS:
+cscope cscopelist:
 
 
 distdir: $(DISTFILES)
@@ -367,15 +429,16 @@ uninstall-am:
 .MAKE: install-am install-strip
 
 .PHONY: all all-am check check-am clean clean-generic clean-libtool \
-	distclean distclean-generic distclean-libtool distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
-	install-info install-info-am install-man install-pdf \
-	install-pdf-am install-ps install-ps-am install-strip \
-	installcheck installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
+	cscopelist-am ctags-am distclean distclean-generic \
+	distclean-libtool distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags-am uninstall uninstall-am
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/missing b/missing
index 86a8fc3..db98974 100755
--- a/missing
+++ b/missing
@@ -1,11 +1,10 @@
 #! /bin/sh
-# Common stub for a few missing GNU programs while installing.
+# Common wrapper for a few potentially missing GNU programs.
 
-scriptversion=2012-01-06.13; # UTC
+scriptversion=2013-10-28.13; # UTC
 
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
-# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Originally written by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -26,68 +25,40 @@ scriptversion=2012-01-06.13; # UTC
 # the same distribution terms that you use for the rest of that program.
 
 if test $# -eq 0; then
-  echo 1>&2 "Try \`$0 --help' for more information"
+  echo 1>&2 "Try '$0 --help' for more information"
   exit 1
 fi
 
-run=:
-sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
-sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
-  configure_ac=configure.ac
-else
-  configure_ac=configure.in
-fi
+case $1 in
 
-msg="missing on your system"
+  --is-lightweight)
+    # Used by our autoconf macros to check whether the available missing
+    # script is modern enough.
+    exit 0
+    ;;
 
-case $1 in
---run)
-  # Try to run requested program, and just exit if it succeeds.
-  run=
-  shift
-  "$@" && exit 0
-  # Exit code 63 means version mismatch.  This often happens
-  # when the user try to use an ancient version of a tool on
-  # a file that requires a minimum version.  In this case we
-  # we should proceed has if the program had been absent, or
-  # if --run hadn't been passed.
-  if test $? = 63; then
-    run=:
-    msg="probably too old"
-  fi
-  ;;
+  --run)
+    # Back-compat with the calling convention used by older automake.
+    shift
+    ;;
 
   -h|--h|--he|--hel|--help)
     echo "\
 $0 [OPTION]... PROGRAM [ARGUMENT]...
 
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
+Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
+to PROGRAM being missing or too old.
 
 Options:
   -h, --help      display this help and exit
   -v, --version   output version information and exit
-  --run           try to run the given command, and emulate it if it fails
 
 Supported PROGRAM values:
-  aclocal      touch file \`aclocal.m4'
-  autoconf     touch file \`configure'
-  autoheader   touch file \`config.h.in'
-  autom4te     touch the output file, or create a stub one
-  automake     touch all \`Makefile.in' files
-  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
-  flex         create \`lex.yy.c', if possible, from existing .c
-  help2man     touch the output file
-  lex          create \`lex.yy.c', if possible, from existing .c
-  makeinfo     touch the output file
-  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
+  bison     yacc      flex         lex       help2man
 
-Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
-\`g' are ignored when checking the name.
+Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
+'g' are ignored when checking the name.
 
 Send bug reports to <bug-automake at gnu.org>."
     exit $?
@@ -99,228 +70,141 @@ Send bug reports to <bug-automake at gnu.org>."
     ;;
 
   -*)
-    echo 1>&2 "$0: Unknown \`$1' option"
-    echo 1>&2 "Try \`$0 --help' for more information"
+    echo 1>&2 "$0: unknown '$1' option"
+    echo 1>&2 "Try '$0 --help' for more information"
     exit 1
     ;;
 
 esac
 
-# normalize program name to check for.
-program=`echo "$1" | sed '
-  s/^gnu-//; t
-  s/^gnu//; t
-  s/^g//; t'`
-
-# Now exit if we have it, but it failed.  Also exit now if we
-# don't have it and --version was passed (most likely to detect
-# the program).  This is about non-GNU programs, so use $1 not
-# $program.
-case $1 in
-  lex*|yacc*)
-    # Not GNU programs, they don't have --version.
-    ;;
-
-  *)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
-       # Could not run --version or --help.  This is probably someone
-       # running `$TOOL --version' or `$TOOL --help' to check whether
-       # $TOOL exists and not knowing $TOOL uses missing.
-       exit 1
-    fi
-    ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case $program in
-  aclocal*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
-         to install the \`Automake' and \`Perl' packages.  Grab them from
-         any GNU archive site."
-    touch aclocal.m4
-    ;;
-
-  autoconf*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`${configure_ac}'.  You might want to install the
-         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
-         archive site."
-    touch configure
-    ;;
-
-  autoheader*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
-         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
-         from any GNU archive site."
-    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
-    test -z "$files" && files="config.h"
-    touch_files=
-    for f in $files; do
-      case $f in
-      *:*) touch_files="$touch_files "`echo "$f" |
-				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
-      *) touch_files="$touch_files $f.in";;
-      esac
-    done
-    touch $touch_files
-    ;;
-
-  automake*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
-         You might want to install the \`Automake' and \`Perl' packages.
-         Grab them from any GNU archive site."
-    find . -type f -name Makefile.am -print |
-	   sed 's/\.am$/.in/' |
-	   while read f; do touch "$f"; done
-    ;;
-
-  autom4te*)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
-         You might have modified some files without having the
-         proper tools for further handling them.
-         You can get \`$1' as part of \`Autoconf' from any GNU
-         archive site."
-
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -f "$file"; then
-	touch $file
-    else
-	test -z "$file" || exec >$file
-	echo "#! /bin/sh"
-	echo "# Created by GNU Automake missing as a replacement of"
-	echo "#  $ $@"
-	echo "exit 0"
-	chmod +x $file
-	exit 1
-    fi
-    ;;
-
-  bison*|yacc*)
-    echo 1>&2 "\
-WARNING: \`$1' $msg.  You should only need it if
-         you modified a \`.y' file.  You may need the \`Bison' package
-         in order for those modifications to take effect.  You can get
-         \`Bison' from any GNU archive site."
-    rm -f y.tab.c y.tab.h
-    if test $# -ne 1; then
-        eval LASTARG=\${$#}
-	case $LASTARG in
-	*.y)
-	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
-	    if test -f "$SRCFILE"; then
-	         cp "$SRCFILE" y.tab.c
-	    fi
-	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
-	    if test -f "$SRCFILE"; then
-	         cp "$SRCFILE" y.tab.h
-	    fi
-	  ;;
-	esac
-    fi
-    if test ! -f y.tab.h; then
-	echo >y.tab.h
-    fi
-    if test ! -f y.tab.c; then
-	echo 'main() { return 0; }' >y.tab.c
-    fi
-    ;;
-
-  lex*|flex*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.l' file.  You may need the \`Flex' package
-         in order for those modifications to take effect.  You can get
-         \`Flex' from any GNU archive site."
-    rm -f lex.yy.c
-    if test $# -ne 1; then
-        eval LASTARG=\${$#}
-	case $LASTARG in
-	*.l)
-	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
-	    if test -f "$SRCFILE"; then
-	         cp "$SRCFILE" lex.yy.c
-	    fi
-	  ;;
-	esac
-    fi
-    if test ! -f lex.yy.c; then
-	echo 'main() { return 0; }' >lex.yy.c
-    fi
-    ;;
-
-  help2man*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-	 you modified a dependency of a manual page.  You may need the
-	 \`Help2man' package in order for those modifications to take
-	 effect.  You can get \`Help2man' from any GNU archive site."
-
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -f "$file"; then
-	touch $file
-    else
-	test -z "$file" || exec >$file
-	echo ".ab help2man is required to generate this page"
-	exit $?
-    fi
-    ;;
-
-  makeinfo*)
-    echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
-         you modified a \`.texi' or \`.texinfo' file, or any other file
-         indirectly affecting the aspect of the manual.  The spurious
-         call might also be the consequence of using a buggy \`make' (AIX,
-         DU, IRIX).  You might want to install the \`Texinfo' package or
-         the \`GNU make' package.  Grab either from any GNU archive site."
-    # The file to touch is that specified with -o ...
-    file=`echo "$*" | sed -n "$sed_output"`
-    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
-    if test -z "$file"; then
-      # ... or it is the one specified with @setfilename ...
-      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
-      file=`sed -n '
-	/^@setfilename/{
-	  s/.* \([^ ]*\) *$/\1/
-	  p
-	  q
-	}' $infile`
-      # ... or it is derived from the source name (dir/f.texi becomes f.info)
-      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
-    fi
-    # If the file does not exist, the user really needs makeinfo;
-    # let's fail without touching anything.
-    test -f $file || exit 1
-    touch $file
-    ;;
+# Run the given program, remember its exit status.
+"$@"; st=$?
+
+# If it succeeded, we are done.
+test $st -eq 0 && exit 0
+
+# Also exit now if we it failed (or wasn't found), and '--version' was
+# passed; such an option is passed most likely to detect whether the
+# program is present and works.
+case $2 in --version|--help) exit $st;; esac
+
+# Exit code 63 means version mismatch.  This often happens when the user
+# tries to use an ancient version of a tool on a file that requires a
+# minimum version.
+if test $st -eq 63; then
+  msg="probably too old"
+elif test $st -eq 127; then
+  # Program was missing.
+  msg="missing on your system"
+else
+  # Program was found and executed, but failed.  Give up.
+  exit $st
+fi
 
-  *)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
-         You might have modified some files without having the
-         proper tools for further handling them.  Check the \`README' file,
-         it often tells you about the needed prerequisites for installing
-         this package.  You may also peek at any GNU archive site, in case
-         some other package would contain this missing \`$1' program."
-    exit 1
+perl_URL=http://www.perl.org/
+flex_URL=http://flex.sourceforge.net/
+gnu_software_URL=http://www.gnu.org/software
+
+program_details ()
+{
+  case $1 in
+    aclocal|automake)
+      echo "The '$1' program is part of the GNU Automake package:"
+      echo "<$gnu_software_URL/automake>"
+      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
+      echo "<$gnu_software_URL/autoconf>"
+      echo "<$gnu_software_URL/m4/>"
+      echo "<$perl_URL>"
+      ;;
+    autoconf|autom4te|autoheader)
+      echo "The '$1' program is part of the GNU Autoconf package:"
+      echo "<$gnu_software_URL/autoconf/>"
+      echo "It also requires GNU m4 and Perl in order to run:"
+      echo "<$gnu_software_URL/m4/>"
+      echo "<$perl_URL>"
+      ;;
+  esac
+}
+
+give_advice ()
+{
+  # Normalize program name to check for.
+  normalized_program=`echo "$1" | sed '
+    s/^gnu-//; t
+    s/^gnu//; t
+    s/^g//; t'`
+
+  printf '%s\n' "'$1' is $msg."
+
+  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
+  case $normalized_program in
+    autoconf*)
+      echo "You should only need it if you modified 'configure.ac',"
+      echo "or m4 files included by it."
+      program_details 'autoconf'
+      ;;
+    autoheader*)
+      echo "You should only need it if you modified 'acconfig.h' or"
+      echo "$configure_deps."
+      program_details 'autoheader'
+      ;;
+    automake*)
+      echo "You should only need it if you modified 'Makefile.am' or"
+      echo "$configure_deps."
+      program_details 'automake'
+      ;;
+    aclocal*)
+      echo "You should only need it if you modified 'acinclude.m4' or"
+      echo "$configure_deps."
+      program_details 'aclocal'
+      ;;
+   autom4te*)
+      echo "You might have modified some maintainer files that require"
+      echo "the 'autom4te' program to be rebuilt."
+      program_details 'autom4te'
+      ;;
+    bison*|yacc*)
+      echo "You should only need it if you modified a '.y' file."
+      echo "You may want to install the GNU Bison package:"
+      echo "<$gnu_software_URL/bison/>"
+      ;;
+    lex*|flex*)
+      echo "You should only need it if you modified a '.l' file."
+      echo "You may want to install the Fast Lexical Analyzer package:"
+      echo "<$flex_URL>"
+      ;;
+    help2man*)
+      echo "You should only need it if you modified a dependency" \
+           "of a man page."
+      echo "You may want to install the GNU Help2man package:"
+      echo "<$gnu_software_URL/help2man/>"
     ;;
-esac
-
-exit 0
+    makeinfo*)
+      echo "You should only need it if you modified a '.texi' file, or"
+      echo "any other file indirectly affecting the aspect of the manual."
+      echo "You might want to install the Texinfo package:"
+      echo "<$gnu_software_URL/texinfo/>"
+      echo "The spurious makeinfo call might also be the consequence of"
+      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
+      echo "want to install GNU make:"
+      echo "<$gnu_software_URL/make/>"
+      ;;
+    *)
+      echo "You might have modified some files without having the proper"
+      echo "tools for further handling them.  Check the 'README' file, it"
+      echo "often tells you about the needed prerequisites for installing"
+      echo "this package.  You may also peek at any GNU archive site, in"
+      echo "case some other package contains this missing '$1' program."
+      ;;
+  esac
+}
+
+give_advice "$1" | sed -e '1s/^/WARNING: /' \
+                       -e '2,$s/^/         /' >&2
+
+# Propagate the correct exit status (expected to be 127 for a program
+# not found, 63 for a program that failed due to version mismatch).
+exit $st
 
 # Local variables:
 # eval: (add-hook 'write-file-hooks 'time-stamp)
diff --git a/src/Makefile.am b/src/Makefile.am
index d47eeb6..9033459 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-# $Id: Makefile.am 15924 2013-04-03 15:53:58Z sloot $
+# $Id: Makefile.am 17238 2014-05-22 14:26:29Z sloot $
 # $URL $
 
 AM_CPPFLAGS = -I at top_srcdir@/include
@@ -6,7 +6,7 @@ AM_CPPFLAGS = -I at top_srcdir@/include
 LDADD = libfolia.la
 
 lib_LTLIBRARIES = libfolia.la
-libfolia_la_LDFLAGS = -version-info 2:0:0
+libfolia_la_LDFLAGS = -version-info 2:1:0
 
 libfolia_la_SOURCES = folia.cxx document.cxx foliautils.cxx
 
@@ -14,7 +14,7 @@ bin_PROGRAMS = folialint
 folialint_SOURCES = folialint.cxx
 
 check_PROGRAMS = simpletest
-TESTS = $(check_PROGRAMS) 
-TESTS_ENVIRONMENT = topsrcdir=$(top_srcdir)
+TESTS = $(check_PROGRAMS)
+#TESTS_ENVIRONMENT = topsrcdir=$(top_srcdir)
 simpletest_SOURCES = simpletest.cxx
 CLEANFILES = simpletest.out
diff --git a/src/Makefile.in b/src/Makefile.in
index aebdcc7..e3a7cff 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -15,11 +14,56 @@
 
 @SET_MAKE@
 
-# $Id: Makefile.am 15924 2013-04-03 15:53:58Z sloot $
+# $Id: Makefile.am 17238 2014-05-22 14:26:29Z sloot $
 # $URL $
 
 
 VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -41,7 +85,8 @@ host_triplet = @host@
 bin_PROGRAMS = folialint$(EXEEXT)
 check_PROGRAMS = simpletest$(EXEEXT)
 subdir = src
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/depcomp $(top_srcdir)/test-driver
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_icu_check.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -86,7 +131,11 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
 libfolia_la_LIBADD =
 am_libfolia_la_OBJECTS = folia.lo document.lo foliautils.lo
 libfolia_la_OBJECTS = $(am_libfolia_la_OBJECTS)
-libfolia_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+libfolia_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
 	$(CXXFLAGS) $(libfolia_la_LDFLAGS) $(LDFLAGS) -o $@
 PROGRAMS = $(bin_PROGRAMS)
@@ -98,30 +147,249 @@ am_simpletest_OBJECTS = simpletest.$(OBJEXT)
 simpletest_OBJECTS = $(am_simpletest_OBJECTS)
 simpletest_LDADD = $(LDADD)
 simpletest_DEPENDENCIES = libfolia.la
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_ at AM_V@)
+am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
 SOURCES = $(libfolia_la_SOURCES) $(folialint_SOURCES) \
 	$(simpletest_SOURCES)
 DIST_SOURCES = $(libfolia_la_SOURCES) $(folialint_SOURCES) \
 	$(simpletest_SOURCES)
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
-am__tty_colors = \
-red=; grn=; lgn=; blu=; std=
+am__tty_colors_dummy = \
+  mgn= red= grn= lgn= blu= brg= std=; \
+  am__color_tests=no
+am__tty_colors = { \
+  $(am__tty_colors_dummy); \
+  if test "X$(AM_COLOR_TESTS)" = Xno; then \
+    am__color_tests=no; \
+  elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
+    am__color_tests=yes; \
+  elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
+    am__color_tests=yes; \
+  fi; \
+  if test $$am__color_tests = yes; then \
+    red=''; \
+    grn=''; \
+    lgn=''; \
+    blu=''; \
+    mgn=''; \
+    brg=''; \
+    std=''; \
+  fi; \
+}
+am__recheck_rx = ^[ 	]*:recheck:[ 	]*
+am__global_test_result_rx = ^[ 	]*:global-test-result:[ 	]*
+am__copy_in_global_log_rx = ^[ 	]*:copy-in-global-log:[ 	]*
+# A command that, given a newline-separated list of test names on the
+# standard input, print the name of the tests that are to be re-run
+# upon "make recheck".
+am__list_recheck_tests = $(AWK) '{ \
+  recheck = 1; \
+  while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+    { \
+      if (rc < 0) \
+        { \
+          if ((getline line2 < ($$0 ".log")) < 0) \
+	    recheck = 0; \
+          break; \
+        } \
+      else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+        { \
+          recheck = 0; \
+          break; \
+        } \
+      else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+        { \
+          break; \
+        } \
+    }; \
+  if (recheck) \
+    print $$0; \
+  close ($$0 ".trs"); \
+  close ($$0 ".log"); \
+}'
+# A command that, given a newline-separated list of test names on the
+# standard input, create the global log from their .trs and .log files.
+am__create_global_log = $(AWK) ' \
+function fatal(msg) \
+{ \
+  print "fatal: making $@: " msg | "cat >&2"; \
+  exit 1; \
+} \
+function rst_section(header) \
+{ \
+  print header; \
+  len = length(header); \
+  for (i = 1; i <= len; i = i + 1) \
+    printf "="; \
+  printf "\n\n"; \
+} \
+{ \
+  copy_in_global_log = 1; \
+  global_test_result = "RUN"; \
+  while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+    { \
+      if (rc < 0) \
+         fatal("failed to read from " $$0 ".trs"); \
+      if (line ~ /$(am__global_test_result_rx)/) \
+        { \
+          sub("$(am__global_test_result_rx)", "", line); \
+          sub("[ 	]*$$", "", line); \
+          global_test_result = line; \
+        } \
+      else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+        copy_in_global_log = 0; \
+    }; \
+  if (copy_in_global_log) \
+    { \
+      rst_section(global_test_result ": " $$0); \
+      while ((rc = (getline line < ($$0 ".log"))) != 0) \
+      { \
+        if (rc < 0) \
+          fatal("failed to read from " $$0 ".log"); \
+        print line; \
+      }; \
+      printf "\n"; \
+    }; \
+  close ($$0 ".trs"); \
+  close ($$0 ".log"); \
+}'
+# Restructured Text title.
+am__rst_title = { sed 's/.*/   &   /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL), and POSIX 2008 even requires this.  Work around it
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+  --color-tests "$$am__color_tests" \
+  --enable-hard-errors "$$am__enable_hard_errors" \
+  --expect-failure "$$am__expect_failure"
+# To be inserted before the command running the test.  Creates the
+# directory for the log if needed.  Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log.  Executes the
+# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
+# passes TESTS_ENVIRONMENT.  Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
+am__check_pre = \
+$(am__sh_e_setup);					\
+$(am__vpath_adj_setup) $(am__vpath_adj)			\
+$(am__tty_colors);					\
+srcdir=$(srcdir); export srcdir;			\
+case "$@" in						\
+  */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;;	\
+    *) am__odir=.;; 					\
+esac;							\
+test "x$$am__odir" = x"." || test -d "$$am__odir" 	\
+  || $(MKDIR_P) "$$am__odir" || exit $$?;		\
+if test -f "./$$f"; then dir=./;			\
+elif test -f "$$f"; then dir=;				\
+else dir="$(srcdir)/"; fi;				\
+tst=$$dir$$f; log='$@'; 				\
+if test -n '$(DISABLE_HARD_ERRORS)'; then		\
+  am__enable_hard_errors=no; 				\
+else							\
+  am__enable_hard_errors=yes; 				\
+fi; 							\
+case " $(XFAIL_TESTS) " in				\
+  *[\ \	]$$f[\ \	]* | *[\ \	]$$dir$$f[\ \	]*) \
+    am__expect_failure=yes;;				\
+  *)							\
+    am__expect_failure=no;;				\
+esac; 							\
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the '.log' extension removed).  The result is saved in the shell variable
+# '$bases'.  This honors runtime overriding of TESTS and TEST_LOGS.  Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
+am__set_TESTS_bases = \
+  bases='$(TEST_LOGS)'; \
+  bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+  bases=`echo $$bases`
+RECHECK_LOGS = $(TEST_LOGS)
+AM_RECURSIVE_TARGETS = check recheck
+TEST_SUITE_LOG = test-suite.log
+TEST_EXTENSIONS = @EXEEXT@ .test
+LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
+am__set_b = \
+  case '$@' in \
+    */*) \
+      case '$*' in \
+        */*) b='$*';; \
+          *) b=`echo '$@' | sed 's/\.log$$//'`; \
+       esac;; \
+    *) \
+      b='$*';; \
+  esac
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT at .log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+	$(TEST_LOG_FLAGS)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -167,7 +435,6 @@ LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
@@ -257,17 +524,17 @@ top_srcdir = @top_srcdir@
 AM_CPPFLAGS = -I at top_srcdir@/include
 LDADD = libfolia.la
 lib_LTLIBRARIES = libfolia.la
-libfolia_la_LDFLAGS = -version-info 2:0:0
+libfolia_la_LDFLAGS = -version-info 2:1:0
 libfolia_la_SOURCES = folia.cxx document.cxx foliautils.cxx
 folialint_SOURCES = folialint.cxx
-TESTS = $(check_PROGRAMS) 
-TESTS_ENVIRONMENT = topsrcdir=$(top_srcdir)
+TESTS = $(check_PROGRAMS)
+#TESTS_ENVIRONMENT = topsrcdir=$(top_srcdir)
 simpletest_SOURCES = simpletest.cxx
 CLEANFILES = simpletest.out
 all: all-am
 
 .SUFFIXES:
-.SUFFIXES: .cxx .lo .o .obj
+.SUFFIXES: .cxx .lo .log .o .obj .test .test$(EXEEXT) .trs
 $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -298,9 +565,9 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
-	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
 	list2=; for p in $$list; do \
 	  if test -f $$p; then \
@@ -308,6 +575,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	  else :; fi; \
 	done; \
 	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
 	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
 	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
 	}
@@ -323,24 +592,32 @@ uninstall-libLTLIBRARIES:
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
 libfolia.la: $(libfolia_la_OBJECTS) $(libfolia_la_DEPENDENCIES) $(EXTRA_libfolia_la_DEPENDENCIES) 
-	$(libfolia_la_LINK) -rpath $(libdir) $(libfolia_la_OBJECTS) $(libfolia_la_LIBADD) $(LIBS)
+	$(AM_V_CXXLD)$(libfolia_la_LINK) -rpath $(libdir) $(libfolia_la_OBJECTS) $(libfolia_la_LIBADD) $(LIBS)
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
-	test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
 	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+	fi; \
 	for p in $$list; do echo "$$p $$p"; done | \
 	sed 's/$(EXEEXT)$$//' | \
-	while read p p1; do if test -f $$p || test -f $$p1; \
-	  then echo "$$p"; echo "$$p"; else :; fi; \
+	while read p p1; do if test -f $$p \
+	 || test -f $$p1 \
+	  ; then echo "$$p"; echo "$$p"; else :; fi; \
 	done | \
-	sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+	sed -e 'p;s,.*/,,;n;h' \
+	    -e 's|.*|.|' \
 	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
 	sed 'N;N;N;s,\n, ,g' | \
 	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
@@ -361,7 +638,8 @@ uninstall-binPROGRAMS:
 	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
 	files=`for p in $$list; do echo "$$p"; done | \
 	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-	      -e 's/$$/$(EXEEXT)/' `; \
+	      -e 's/$$/$(EXEEXT)/' \
+	`; \
 	test -n "$$list" || exit 0; \
 	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
 	cd "$(DESTDIR)$(bindir)" && rm -f $$files
@@ -383,12 +661,14 @@ clean-checkPROGRAMS:
 	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
 	echo " rm -f" $$list; \
 	rm -f $$list
+
 folialint$(EXEEXT): $(folialint_OBJECTS) $(folialint_DEPENDENCIES) $(EXTRA_folialint_DEPENDENCIES) 
 	@rm -f folialint$(EXEEXT)
-	$(CXXLINK) $(folialint_OBJECTS) $(folialint_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(folialint_OBJECTS) $(folialint_LDADD) $(LIBS)
+
 simpletest$(EXEEXT): $(simpletest_OBJECTS) $(simpletest_DEPENDENCIES) $(EXTRA_simpletest_DEPENDENCIES) 
 	@rm -f simpletest$(EXEEXT)
-	$(CXXLINK) $(simpletest_OBJECTS) $(simpletest_LDADD) $(LIBS)
+	$(AM_V_CXXLD)$(CXXLINK) $(simpletest_OBJECTS) $(simpletest_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -403,25 +683,25 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/simpletest.Po at am__quote@
 
 .cxx.o:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
 
 .cxx.obj:
- at am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cxx.lo:
- at am__fastdepCXX_TRUE@	$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
- at am__fastdepCXX_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -429,26 +709,15 @@ mostlyclean-libtool:
 clean-libtool:
 	-rm -rf .libs _libs
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -460,15 +729,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -477,102 +742,187 @@ GTAGS:
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-check-TESTS: $(TESTS)
-	@failed=0; all=0; xfail=0; xpass=0; skip=0; \
-	srcdir=$(srcdir); export srcdir; \
-	list=' $(TESTS) '; \
-	$(am__tty_colors); \
-	if test -n "$$list"; then \
-	  for tst in $$list; do \
-	    if test -f ./$$tst; then dir=./; \
-	    elif test -f $$tst; then dir=; \
-	    else dir="$(srcdir)/"; fi; \
-	    if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *[\ \	]$$tst[\ \	]*) \
-		xpass=`expr $$xpass + 1`; \
-		failed=`expr $$failed + 1`; \
-		col=$$red; res=XPASS; \
-	      ;; \
-	      *) \
-		col=$$grn; res=PASS; \
-	      ;; \
-	      esac; \
-	    elif test $$? -ne 77; then \
-	      all=`expr $$all + 1`; \
-	      case " $(XFAIL_TESTS) " in \
-	      *[\ \	]$$tst[\ \	]*) \
-		xfail=`expr $$xfail + 1`; \
-		col=$$lgn; res=XFAIL; \
-	      ;; \
-	      *) \
-		failed=`expr $$failed + 1`; \
-		col=$$red; res=FAIL; \
-	      ;; \
-	      esac; \
-	    else \
-	      skip=`expr $$skip + 1`; \
-	      col=$$blu; res=SKIP; \
-	    fi; \
-	    echo "$${col}$$res$${std}: $$tst"; \
-	  done; \
-	  if test "$$all" -eq 1; then \
-	    tests="test"; \
-	    All=""; \
-	  else \
-	    tests="tests"; \
-	    All="All "; \
+# Recover from deleted '.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
+# both 'foo.log' and 'foo.trs'.  Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+	rm -f $< $@
+	$(MAKE) $(AM_MAKEFLAGS) $<
+
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# expand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+	@:
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+	@$(am__set_TESTS_bases); \
+	am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+	redo_bases=`for i in $$bases; do \
+	              am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+	            done`; \
+	if test -n "$$redo_bases"; then \
+	  redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+	  redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+	  if $(am__make_dryrun); then :; else \
+	    rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
 	  fi; \
-	  if test "$$failed" -eq 0; then \
-	    if test "$$xfail" -eq 0; then \
-	      banner="$$All$$all $$tests passed"; \
-	    else \
-	      if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
-	      banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
-	    fi; \
-	  else \
-	    if test "$$xpass" -eq 0; then \
-	      banner="$$failed of $$all $$tests failed"; \
+	fi; \
+	if test -n "$$am__remaking_logs"; then \
+	  echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+	       "recursion detected" >&2; \
+	else \
+	  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+	fi; \
+	if $(am__make_dryrun); then :; else \
+	  st=0;  \
+	  errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+	  for i in $$redo_bases; do \
+	    test -f $$i.trs && test -r $$i.trs \
+	      || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
+	    test -f $$i.log && test -r $$i.log \
+	      || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+	  done; \
+	  test $$st -eq 0 || exit 1; \
+	fi
+	@$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+	ws='[ 	]'; \
+	results=`for b in $$bases; do echo $$b.trs; done`; \
+	test -n "$$results" || results=/dev/null; \
+	all=`  grep "^$$ws*:test-result:"           $$results | wc -l`; \
+	pass=` grep "^$$ws*:test-result:$$ws*PASS"  $$results | wc -l`; \
+	fail=` grep "^$$ws*:test-result:$$ws*FAIL"  $$results | wc -l`; \
+	skip=` grep "^$$ws*:test-result:$$ws*SKIP"  $$results | wc -l`; \
+	xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+	xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+	error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+	if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+	  success=true; \
+	else \
+	  success=false; \
+	fi; \
+	br='==================='; br=$$br$$br$$br$$br; \
+	result_count () \
+	{ \
+	    if test x"$$1" = x"--maybe-color"; then \
+	      maybe_colorize=yes; \
+	    elif test x"$$1" = x"--no-color"; then \
+	      maybe_colorize=no; \
 	    else \
-	      if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
-	      banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+	      echo "$@: invalid 'result_count' usage" >&2; exit 4; \
 	    fi; \
-	  fi; \
-	  dashes="$$banner"; \
-	  skipped=""; \
-	  if test "$$skip" -ne 0; then \
-	    if test "$$skip" -eq 1; then \
-	      skipped="($$skip test was not run)"; \
+	    shift; \
+	    desc=$$1 count=$$2; \
+	    if test $$maybe_colorize = yes && test $$count -gt 0; then \
+	      color_start=$$3 color_end=$$std; \
 	    else \
-	      skipped="($$skip tests were not run)"; \
+	      color_start= color_end=; \
 	    fi; \
-	    test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$skipped"; \
-	  fi; \
-	  report=""; \
-	  if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
-	    report="Please report to $(PACKAGE_BUGREPORT)"; \
-	    test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
-	      dashes="$$report"; \
-	  fi; \
-	  dashes=`echo "$$dashes" | sed s/./=/g`; \
-	  if test "$$failed" -eq 0; then \
-	    col="$$grn"; \
-	  else \
-	    col="$$red"; \
-	  fi; \
-	  echo "$${col}$$dashes$${std}"; \
-	  echo "$${col}$$banner$${std}"; \
-	  test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
-	  test -z "$$report" || echo "$${col}$$report$${std}"; \
-	  echo "$${col}$$dashes$${std}"; \
-	  test "$$failed" -eq 0; \
-	else :; fi
+	    echo "$${color_start}# $$desc $$count$${color_end}"; \
+	}; \
+	create_testsuite_report () \
+	{ \
+	  result_count $$1 "TOTAL:" $$all   "$$brg"; \
+	  result_count $$1 "PASS: " $$pass  "$$grn"; \
+	  result_count $$1 "SKIP: " $$skip  "$$blu"; \
+	  result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+	  result_count $$1 "FAIL: " $$fail  "$$red"; \
+	  result_count $$1 "XPASS:" $$xpass "$$red"; \
+	  result_count $$1 "ERROR:" $$error "$$mgn"; \
+	}; \
+	{								\
+	  echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |	\
+	    $(am__rst_title);						\
+	  create_testsuite_report --no-color;				\
+	  echo;								\
+	  echo ".. contents:: :depth: 2";				\
+	  echo;								\
+	  for b in $$bases; do echo $$b; done				\
+	    | $(am__create_global_log);					\
+	} >$(TEST_SUITE_LOG).tmp || exit 1;				\
+	mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);			\
+	if $$success; then						\
+	  col="$$grn";							\
+	 else								\
+	  col="$$red";							\
+	  test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG);		\
+	fi;								\
+	echo "$${col}$$br$${std}"; 					\
+	echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}";	\
+	echo "$${col}$$br$${std}"; 					\
+	create_testsuite_report --maybe-color;				\
+	echo "$$col$$br$$std";						\
+	if $$success; then :; else					\
+	  echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}";		\
+	  if test -n "$(PACKAGE_BUGREPORT)"; then			\
+	    echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}";	\
+	  fi;								\
+	  echo "$$col$$br$$std";					\
+	fi;								\
+	$$success || exit 1
+
+check-TESTS:
+	@list='$(RECHECK_LOGS)';           test -z "$$list" || rm -f $$list
+	@list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+	@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+	@set +e; $(am__set_TESTS_bases); \
+	log_list=`for i in $$bases; do echo $$i.log; done`; \
+	trs_list=`for i in $$bases; do echo $$i.trs; done`; \
+	log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
+	$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+	exit $$?;
+recheck: all $(check_PROGRAMS)
+	@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+	@set +e; $(am__set_TESTS_bases); \
+	bases=`for i in $$bases; do echo $$i; done \
+	         | $(am__list_recheck_tests)` || exit 1; \
+	log_list=`for i in $$bases; do echo $$i.log; done`; \
+	log_list=`echo $$log_list`; \
+	$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+	        am__force_recheck=am--force-recheck \
+	        TEST_LOGS="$$log_list"; \
+	exit $$?
+simpletest.log: simpletest$(EXEEXT)
+	@p='simpletest$(EXEEXT)'; \
+	b='simpletest'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+.test.log:
+	@p='$<'; \
+	$(am__set_b); \
+	$(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+ at am__EXEEXT_TRUE@.test$(EXEEXT).log:
+ at am__EXEEXT_TRUE@	@p='$<'; \
+ at am__EXEEXT_TRUE@	$(am__set_b); \
+ at am__EXEEXT_TRUE@	$(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+ at am__EXEEXT_TRUE@	--log-file $$b.log --trs-file $$b.trs \
+ at am__EXEEXT_TRUE@	$(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+ at am__EXEEXT_TRUE@	"$$tst" $(AM_TESTS_FD_REDIRECT)
 
 distdir: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -635,6 +985,9 @@ install-strip:
 	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
 	fi
 mostlyclean-generic:
+	-test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+	-test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
+	-test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
 
 clean-generic:
 	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
@@ -719,20 +1072,21 @@ uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES
 
 .MAKE: check-am install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \
 	clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
-	clean-libLTLIBRARIES clean-libtool ctags distclean \
-	distclean-compile distclean-generic distclean-libtool \
-	distclean-tags distdir dvi dvi-am html html-am info info-am \
-	install install-am install-binPROGRAMS install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-libLTLIBRARIES install-man install-pdf \
-	install-pdf-am install-ps install-ps-am install-strip \
-	installcheck installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-compile \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags uninstall uninstall-am uninstall-binPROGRAMS \
+	clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \
+	ctags-am distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-binPROGRAMS \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-libLTLIBRARIES \
+	install-man install-pdf install-pdf-am install-ps \
+	install-ps-am install-strip installcheck installcheck-am \
+	installdirs maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \
+	uninstall uninstall-am uninstall-binPROGRAMS \
 	uninstall-libLTLIBRARIES
 
 
diff --git a/src/document.cxx b/src/document.cxx
index 2f1fc1c..d38ef52 100644
--- a/src/document.cxx
+++ b/src/document.cxx
@@ -1,11 +1,11 @@
 /*
-  $Id: document.cxx 15909 2013-04-03 13:52:24Z sloot $
+  $Id: document.cxx 17507 2014-08-13 15:20:36Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/document.cxx $
 
-  Copyright (c) 1998 - 2013
+  Copyright (c) 1998 - 2014
   ILK   - Tilburg University
   CLiPS - University of Antwerp
- 
+
   This file is part of libfolia
 
   libfolia is free software; you can redistribute it and/or modify
@@ -38,6 +38,8 @@
 #include <algorithm>
 #include <stdexcept>
 #include "ticcutils/XMLtools.h"
+#include "ticcutils/StringOps.h"
+#include "ticcutils/zipper.h"
 #include "libfolia/document.h"
 #include "config.h"
 
@@ -46,7 +48,19 @@ using namespace TiCC;
 
 namespace folia {
 
-  const string FOLIAVERSION = "0.8.2"; // the FoLiA version we implement
+  void initMT(){
+    try {
+      Document doc( "string='<?xml version=\"1.0\" encoding=\"UTF-8\"?><FoLiA xmlns=\"http://ilk.uvt.nl/folia\" xml:id=\"ID\"><text xml:id=\"text\"><div xml:id=\"head\"><w xml:id=\"w1\"><t>test</t></w></div></text></FoLiA>'" );
+    }
+    catch( exception& e ){
+      cerr << "serious initialization problem: " << e.what() << endl;
+      exit(EXIT_FAILURE);
+    };
+  }
+
+  const int MAJOR_VERSION = 0;
+  const int MINOR_VERSION = 11;
+  const int SUB_VERSION   = 1;
   const string NSFOLIA = "http://ilk.uvt.nl/folia";
   const string NSDCOI = "http://lands.let.ru.nl/projects/d-coi/ns/1.0";
   const string NSIMDI = "http://www.mpi.nl/IMDI/Schema/IMDI";
@@ -62,6 +76,12 @@ namespace folia {
       foliadoc = new FoLiA( this, args );
   }
 
+  string versionstring(){
+    stringstream ss;
+    ss << MAJOR_VERSION << "." << MINOR_VERSION << "." << SUB_VERSION;
+    return ss.str();
+  }
+
   void Document::init(){
     _metadatatype = NATIVE;
     metadata = 0;
@@ -70,7 +90,7 @@ namespace folia {
     _foliaNsIn = 0;
     _foliaNsOut = 0;
     debug = 0;
-    version = FOLIAVERSION;
+    version = versionstring();
   }
 
   Document::~Document(){
@@ -92,23 +112,23 @@ namespace folia {
     }
     return true;
   }
-  
+
   bool operator==( const FoliaElement& a1, const FoliaElement& a2){
-    if ( a1._element_id != a2._element_id )
+    if ( a1.element_id() != a2.element_id() )
       return false;
-    if ( a1._id != a2._id )
+    if ( a1.id() != a2.id() )
       return false;
-    if ( a1._set != a2._set )
+    if ( a1.sett() != a2.sett() )
       return false;
-    if ( a1._class != a2._class )
+    if ( a1.cls() != a2.cls() )
       return false;
-    if ( a1._annotator != a2._annotator )
+    if ( a1.annotator() != a2.annotator() )
       return false;
-    if ( a1._annotator_type != a2._annotator_type )
+    if ( a1.annotatortype() != a2.annotatortype() )
       return false;
-    if ( a1.data.size() == a2.data.size() ) {
-      for ( size_t i = 0; i < a1.data.size(); ++i ){
-	if ( *a1.data[i] != *a2.data[i] )
+    if ( a1.size() == a2.size() ) {
+      for ( size_t i = 0; i < a1.size(); ++i ){
+	if ( *a1.index(i) != *a2.index(i) )
 	  return false;
       }
     }
@@ -120,21 +140,24 @@ namespace folia {
     KWargs::const_iterator it = kwargs.find( "debug" );
     if ( it != kwargs.end() )
       debug = stringTo<int>( it->second );
-    else
-      debug = 0;
     it = kwargs.find( "load" );
     if ( it != kwargs.end() )
       loadall = stringTo<bool>( it->second );
     else
       loadall = true;
+    it = kwargs.find( "external" );
+    if ( it != kwargs.end() )
+      external = stringTo<bool>( it->second );
+    else
+      external = false;
     it = kwargs.find( "version" );
     if ( it != kwargs.end() ){
       version = it->second;
     }
-    else
-      version.clear();
-    
-    it = kwargs.find( "id" );
+    it = kwargs.find( "_id" );
+    if ( it == kwargs.end() ){
+      it = kwargs.find( "id" );
+    }
     if ( it != kwargs.end() ){
       if ( isNCName( it->second ) ){
 	_id = it->second;
@@ -163,12 +186,38 @@ namespace folia {
   }
 
   void Document::addDocIndex( FoliaElement* el, const string& s ){
+    if ( s.empty() ) {
+      return;
+    }
+    // cerr << _id << "-add docindex " << el << " (" << s << ")" << endl;
+    // using TiCC::operator <<;
+    // cerr << "VOOR: " << sindex << endl;
     if ( sindex.find( s ) == sindex.end() ){
       sindex[s] = el;
       iindex.push_back( el );
     }
     else
       throw DuplicateIDError( s );
+    //    cerr << "NA  : " << sindex << endl;
+  }
+
+  void Document::delDocIndex( const FoliaElement* el, const string& s ){
+    if ( s.empty() ) {
+      return;
+    }
+    // cerr << _id << "-del docindex " << el << " (" << s << ")" << endl;
+    // using TiCC::operator <<;
+    // cerr << "VOOR: " << sindex << endl;
+    sindex.erase(s);
+    //    cerr << "NA  : " << sindex << endl;
+    vector<FoliaElement*>::iterator pos = iindex.begin();
+    while( pos != iindex.end() ){
+      if ( *pos == el ){
+	iindex.erase( pos );
+	return;
+      }
+      ++pos;
+    }
   }
 
   static int error_sink(void *mydata, xmlError *error ){
@@ -181,10 +230,22 @@ namespace folia {
   }
 
   bool Document::readFromFile( const string& s ){
+    ifstream is( s.c_str() );
+    if ( !is.good() ){
+      throw runtime_error( "file not found: " + s );
+    }
     if ( xmldoc ){
-      throw runtime_error( "Document is aready initialized" );
+      throw runtime_error( "Document is already initialized" );
       return false;
     }
+    if ( match_back( s, ".bz2" ) ){
+      string buffer = bz2ReadFile( s );
+      return readFromString( buffer );
+    }
+    else if ( match_back( s, ".gz" ) ) {
+      string buffer = gzReadFile( s );
+      return readFromString( buffer );
+    }
     int cnt = 0;
     xmlSetStructuredErrorFunc( &cnt, (xmlStructuredErrorFunc)error_sink );
     xmldoc = xmlReadFile( s.c_str(), 0, XML_PARSE_NOBLANKS );
@@ -206,12 +267,12 @@ namespace folia {
     }
     if ( debug )
       cout << "Failed to read a doc from " << s << endl;
-    return false;
+    throw XmlError( "No XML document read" );
   }
 
   bool Document::readFromString( const string& s ){
     if ( xmldoc ){
-      throw runtime_error( "Document is aready initialized" );
+      throw runtime_error( "Document is already initialized" );
       return false;
     }
     int cnt = 0;
@@ -238,9 +299,14 @@ namespace folia {
     return false;
   }
 
-  ostream& operator<<( ostream& os, const Document& d ){
-    string s = d.toXml();
-    os << s << endl;
+  ostream& operator<<( ostream& os, const Document *d ){
+    if ( d ){
+      string s = d->toXml();
+      os << s << endl;
+    }
+    else {
+      os << "MISSING DOCUMENT" << endl;
+    }
     return os;
   }
 
@@ -251,6 +317,14 @@ namespace folia {
   }
 
   bool Document::save( const string& fn, const string& nsLabel, bool kanon ) {
+    if ( match_back( fn, ".bz2" ) ){
+      string s = toXml( nsLabel, kanon );
+      return bz2WriteFile( fn, s );
+    }
+    else  if ( match_back( fn, ".gz" ) ){
+      string s = toXml( nsLabel, kanon );
+      return gzWriteFile( fn, s );
+    }
     ofstream os( fn.c_str() );
     if ( os.good() ) {
       return save( os, nsLabel, kanon );
@@ -261,7 +335,7 @@ namespace folia {
 
   int Document::size() const {
     if ( foliadoc )
-      return foliadoc->size(); 
+      return foliadoc->size();
     else
       return 0;
   }
@@ -296,13 +370,13 @@ namespace folia {
     }
     return foliadoc->select<Sentence>( excludeSet );
   }
-  
+
   vector<Sentence*> Document::sentenceParts() const {
     static set<ElementType> excludeSet;
     vector<Sentence*> sents = foliadoc->select<Sentence>( excludeSet );
     return sents;
   }
-  
+
   Sentence *Document::sentences( size_t index ) const {
     vector<Sentence*> v = sentences();
     if ( index < v.size() ){
@@ -322,24 +396,9 @@ namespace folia {
   }
 
   vector<Word*> Document::words() const {
-    static set<ElementType> excludeSet;
-    if ( excludeSet.empty() ){
-      excludeSet.insert( Original_t );
-      excludeSet.insert( Suggestion_t );
-      excludeSet.insert( Alternative_t );
-      excludeSet.insert( Chunk_t );
-      excludeSet.insert( SyntacticUnit_t );
-      excludeSet.insert( Coreferences_t );
-      excludeSet.insert( Semroles_t );
-      excludeSet.insert( Entity_t );
-      excludeSet.insert( Headwords_t );
-      excludeSet.insert( TimingLayer_t );
-      excludeSet.insert( DependencyDependent_t );
-      excludeSet.insert( TimeSegment_t );
-    }
-    return foliadoc->select<Word>( excludeSet );
-  }
-  
+    return foliadoc->select<Word>( default_ignore_structure );
+  }
+
   Word *Document::words( size_t index ) const {
     vector<Word*> v = words();
     if ( index < v.size() ){
@@ -376,14 +435,6 @@ namespace folia {
       throw range_error( "rparagraphs() index out of range" );
   }
 
-  FoliaElement *Document::append( FoliaElement *txt ){
-    if ( !isinstance( txt, Text_t ) )
-      throw runtime_error( "can only append() a Text_t element to a Document" );
-    else {
-      return foliadoc->append( txt );
-    }
-  }
-
   void Document::setimdi( xmlNode *node ){
     xmlNode *n = xPath( node, "//imdi:Session/imdi:Title" );
     if ( n ){
@@ -393,12 +444,12 @@ namespace folia {
     if ( n ){
       _date = XmlContent( n);
     }
-  
+
     n = xPath( node, "//imdi:Source/imdi:Access/imdi:Publisher" );
     if ( n ){
       _publisher = XmlContent( n );
     }
-  
+
     n = xPath( node, "//imdi:Source/imdi:Access/imdi:Availability" );
     if ( n ){
       _license = XmlContent( n );
@@ -408,6 +459,73 @@ namespace folia {
       _language = XmlContent( n );
   }
 
+  void Document::parsemeta( xmlNode *node ){
+    if ( node ){
+      KWargs att = getAttributes( node );
+      string type = att["id"];
+      string val = XmlContent( node );
+      if ( type == "title" )
+	_title = val;
+      else if ( type == "date" )
+	_date = val;
+      else if ( type == "language" )
+	_language = val;
+      else if ( type == "publisher" )
+	_publisher = val;
+      else if ( type == "licence" )
+	_license = val;
+      else if ( _metadatatype != NATIVE ){
+	throw runtime_error( "meta tag with id=" + type
+			     + " requires NATIVE metadataype." );
+      }
+      else if ( meta_atts[type] != "" ){
+	throw runtime_error( "meta tag with id=" + type
+			     + " is defined more then once " );
+      }
+      else
+	meta_atts[type] = val;
+    }
+  }
+
+  void Document::set_metadata( const string& type, const string& value ){
+    if ( type == "title" )
+      _title = value;
+    else if ( type == "date" )
+      _date = value;
+    else if ( type == "language" )
+      _language = value;
+    else if ( type == "publisher" )
+      _publisher = value;
+    else if ( type == "licence" )
+      _license = value;
+    else if ( _metadatatype != NATIVE ){
+      throw runtime_error( "meta tag with id=" + type
+			   + " requires NATIVE metadataype." );
+    }
+    else
+      meta_atts[type] = value;
+  }
+
+  const string Document::get_metadata( const string& type ) const {
+    if ( type == "title" )
+      return _title;
+    else if ( type == "date" )
+      return _date;
+    else if ( type == "language" )
+      return _language;
+    else if ( type == "publisher" )
+      return _publisher;
+    else if ( type == "licence" )
+      return _license;
+    else {
+      map<string,string>::const_iterator it = meta_atts.find( type );
+      if ( it != meta_atts.end() )
+	return it->second;
+      else
+	return "";
+    }
+  }
+
   void Document::parseannotations( xmlNode *node ){
     xmlNode *n = node->children;
     while ( n ){
@@ -454,14 +572,49 @@ namespace folia {
     return false;
   }
 
+  bool check_version( const string& vers ){
+    vector<string> vec;
+    const int myVersion = MAJOR_VERSION * 10000 + MINOR_VERSION * 100 + SUB_VERSION;
+    int readVersion = 0;
+    split_at( vers, vec, "." );
+    for ( size_t i=0; i < vec.size(); ++i ){
+      int val = stringTo<int>( vec[i] );
+      if ( i == 0 )
+	readVersion += 10000 * val;
+      else if ( i == 1 )
+	readVersion += 100 * val;
+      else
+	readVersion += val;
+    }
+    if ( readVersion <= myVersion )
+      return true;
+    else
+      return false;
+  }
+
+  FoliaElement *Document::resolveExternals( FoliaElement* result ){
+    if ( !externals.empty() ){
+      for ( size_t i= 0;i < externals.size(); ++i ){
+	externals[i]->resolve();
+      }
+    }
+    return result;
+  }
+
   FoliaElement* Document::parseFoliaDoc( xmlNode *root ){
     KWargs att = getAttributes( root );
-    if ( att["id"] == "" ){
+    if ( att["_id"] == "" ){
       throw XmlError("FoLiA Document has no ID!");
       return 0;
     }
+    string vers = att["version"];
+    if ( !check_version( vers ) ){
+      throw XmlError( "FoLiA Document has unsupported version: " + vers
+		      + " (" + version + " is supported.)" );
+      return 0;
+    }
     setAttributes( att );
-    FoliaElement *result = FoliaElement::createElement( this, Name(root) );
+    FoliaElement *result = FoliaImpl::createElement( this, Name(root) );
     if ( debug > 2 )
       cerr << "created " << root << endl;
     result->setAttributes( att );
@@ -503,13 +656,19 @@ namespace folia {
 		cerr << "found annotations" << endl;
 	      parseannotations( m );
 	    }
+	    else if ( Name( m ) == "meta" &&
+		      checkNS( m, NSFOLIA ) ){
+	      if ( debug > 1 )
+		cerr << "found meta node" << endl;
+	      parsemeta( m );
+	    }
 	    m = m->next;
 	  }
 	}
 	else {
 	  if ( p && getNS(p) == NSFOLIA ){
 	    string tag = Name( p );
-	    FoliaElement *t = FoliaElement::createElement( this, tag );
+	    FoliaElement *t = FoliaImpl::createElement( this, tag );
 	    if ( t ){
 	      if ( debug > 2 )
 		cerr << "created " << t << endl;
@@ -525,9 +684,10 @@ namespace folia {
       }
       p = p->next;
     }
+    result = resolveExternals( result );
     return result;
   }
-  
+
   void Document::addStyle( const std::string& type, const std::string& href ){
     if ( type == "text/xsl" ){
       multimap<string,string>::iterator it = styles.find( type );
@@ -536,8 +696,8 @@ namespace folia {
     }
     styles.insert( make_pair( type, href ) );
   }
-  
-  void Document::replaceStyle( const std::string& type, 
+
+  void Document::replaceStyle( const std::string& type,
 			       const std::string& href ){
     multimap<string,string>::iterator it = styles.find( type );
     if ( it != styles.end() ){
@@ -620,7 +780,7 @@ namespace folia {
     return result;
   }
 
-  void Document::declare( AnnotationType::AnnotationType type, 
+  void Document::declare( AnnotationType::AnnotationType type,
 			  const string& setname, const string& args ){
     string st = setname;
     if ( st.empty() )
@@ -648,34 +808,40 @@ namespace folia {
     string res = buf;
     return res;
   }
-  
-  void Document::declare( AnnotationType::AnnotationType type, 
-			  const string& s, const string& a, 
+
+  void Document::declare( AnnotationType::AnnotationType type,
+			  const string& s, const string& a,
 			  const string& t, const string& ds ){
-    string d = ds;
-    if ( d == "now()" ){
-      d = getNow();
-    }
-    if ( !isDeclared( type, s, a, t, d ) ){
+    if ( !isDeclared( type, s, a, t ) ){
+      string d = ds;
+      if ( d == "now()" ){
+	d = getNow();
+      }
       annotationdefaults[type].insert( make_pair(s, at_t(a,t,d) ) );
       //    cerr << "inserted [" << type << "][" << st << "](" << a << "," << t << "," << d ")" << endl;
       //    cerr << "annotation defaults now: " <<  annotationdefaults << endl;
-      
+
     }
   }
 
-  FoliaElement* Document::addNode( ElementType et, const KWargs& kwargs ){
-    FoliaElement *res = FoliaElement::createElement( this, et );
-    res->setAttributes( kwargs );
+  Text* Document::addText( const KWargs& kwargs ){
+    Text *res = new Text( this, kwargs );
     foliadoc->append( res );
     return res;
   }
 
+  Text* Document::addText( Text *t ){
+    foliadoc->append( t );
+    return t;
+  }
+
   bool Document::isDeclared( AnnotationType::AnnotationType type,
-			     const string& s, 
+			     const string& s,
 			     const string& a,
-			     const string& t,
-			     const string& d ){
+			     const string& t){
+    //
+    // We DO NOT check the date. if all parameters match, it is OK
+    //
     if ( type == AnnotationType::NO_ANN ){
       return true;
     }
@@ -685,7 +851,7 @@ namespace folia {
 	throw runtime_error("isDeclared with empty set.");
       multimap<string,at_t>::const_iterator mit2 = mit1->second.lower_bound(s);
       while ( mit2 != mit1->second.upper_bound(s) ){
-	if ( mit2->second.a == a && mit2->second.t == t && mit2->second.d == d )
+	if ( mit2->second.a == a && mit2->second.t == t )
 	  return true;
 	++mit2;
       }
@@ -803,7 +969,7 @@ namespace folia {
     while ( mit != annotationdefaults.end() ){
       map<string,at_t>::const_iterator it = mit->second.begin();
       while ( it != mit->second.end() ){
-	// Find the 'label' 
+	// Find the 'label'
 	string label = toString( mit->first );
 	label += "-annotation";
 	xmlNode *n = XmlNewNode( foliaNs(), label );
@@ -829,29 +995,68 @@ namespace folia {
   }
 
   void Document::setmetadata( xmlNode *node ) const{
-    KWargs atts;
-    if ( _metadatatype == NATIVE )
-      atts["type"] = "native";
-    else if ( _metadatatype == IMDI )
-      atts["type"] = "imdi";
-    else if ( _metadatatype == CMDI )
-      atts["type"] = "cmdi";
-
     if ( _metadatatype == NATIVE ){
-      if ( !_title.empty() )
-	atts["title"] = _title;
-      if ( !_date.empty() )
-	atts["date"] = _date;
-      if ( !_language.empty() )
-	atts["language"] = _language;
-      if ( !_license.empty() )
-	atts["license"] = _license;
-      if ( !_publisher.empty() )
-	atts["publisher"] = _publisher;
+      KWargs atts;
+      atts["type"] = "native";
       addAttributes( node, atts );
+      if ( !_title.empty() ){
+	xmlNode *m = XmlNewNode( foliaNs(), "meta" );
+	xmlAddChild( m, xmlNewText( (const xmlChar*)_title.c_str()) );
+	KWargs atts;
+	atts["id"] = "title";
+	addAttributes( m, atts );
+	xmlAddChild( node, m );
+      }
+      if ( !_date.empty() ){
+	xmlNode *m = XmlNewNode( foliaNs(), "meta" );
+	xmlAddChild( m, xmlNewText( (const xmlChar*)_date.c_str()) );
+	KWargs atts;
+	atts["id"] = "date";
+	addAttributes( m, atts );
+	xmlAddChild( node, m );
+      }
+      if ( !_language.empty() ){
+	xmlNode *m = XmlNewNode( foliaNs(), "meta" );
+	xmlAddChild( m, xmlNewText( (const xmlChar*)_language.c_str()) );
+	KWargs atts;
+	atts["id"] = "language";
+	addAttributes( m, atts );
+	xmlAddChild( node, m );
+      }
+      if ( !_license.empty() ){
+	xmlNode *m = XmlNewNode( foliaNs(), "meta" );
+	xmlAddChild( m, xmlNewText( (const xmlChar*)_license.c_str()) );
+	KWargs atts;
+	atts["id"] = "license";
+	addAttributes( m, atts );
+	xmlAddChild( node, m );
+      }
+      if ( !_publisher.empty() ){
+	xmlNode *m = XmlNewNode( foliaNs(), "meta" );
+	xmlAddChild( m, xmlNewText( (const xmlChar*)_publisher.c_str()) );
+	KWargs atts;
+	atts["id"] = "publisher";
+	addAttributes( m, atts );
+	xmlAddChild( node, m );
+      }
+      map<string,string>::const_iterator it = meta_atts.begin();
+      while ( it != meta_atts.end() ){
+	xmlNode *m = XmlNewNode( foliaNs(), "meta" );
+	xmlAddChild( m, xmlNewText( (const xmlChar*)it->second.c_str()) );
+	KWargs atts;
+	atts["id"] = it->first;
+	addAttributes( m, atts );
+	xmlAddChild( node, m );
+	++it;
+      }
     }
     else if ( _metadatatype == IMDI  ||
 	      _metadatatype == CMDI ){
+      KWargs atts;
+      if ( _metadatatype == IMDI )
+	atts["type"] = "imdi";
+      else if ( _metadatatype == CMDI )
+	atts["type"] = "cmdi";
       if ( !_metadatafile.empty() )
 	atts["src"] = _metadatafile;
       addAttributes( node, atts );
@@ -862,11 +1067,11 @@ namespace folia {
   void Document::setstyles( xmlDoc* doc ) const {
     multimap<string,string>::const_iterator it = styles.begin();
     while ( it != styles.end() ){
-      string content = "type=\"" + it->first 
+      string content = "type=\"" + it->first
 	+ "\" href=\"" + it->second + "\"";
       xmlAddChild( (xmlNode*)doc,
 		   xmlNewDocPI( doc,
-				(const xmlChar*)"xml-stylesheet", 
+				(const xmlChar*)"xml-stylesheet",
 				(const xmlChar*)content.c_str() ) );
       ++it;
     }
@@ -879,7 +1084,7 @@ namespace folia {
       setstyles( outDoc );
       xmlNode *root = xmlNewDocNode( outDoc, 0, (const xmlChar*)"FoLiA", 0 );
       xmlDocSetRootElement( outDoc, root );
-      xmlNs *xl = xmlNewNs( root, (const xmlChar *)"http://www.w3.org/1999/xlink", 
+      xmlNs *xl = xmlNewNs( root, (const xmlChar *)"http://www.w3.org/1999/xlink",
 			    (const xmlChar *)"xlink" );
       xmlSetNs( root, xl );
       if ( !_foliaNsIn ){
@@ -899,16 +1104,17 @@ namespace folia {
       attribs["generator"] = string("libfolia-v") + VERSION;
       if ( !version.empty() )
 	attribs["version"] = version;
+      if ( external )
+	attribs["external"] = "yes";
       addAttributes( root, attribs );
 
-      xmlNode *md = xmlAddChild( root, XmlNewNode( foliaNs(), "metadata" ) );  
+      xmlNode *md = xmlAddChild( root, XmlNewNode( foliaNs(), "metadata" ) );
       xmlNode *an = xmlAddChild( md, XmlNewNode( foliaNs(), "annotations" ) );
       setannotations( an );
       setmetadata( md );
-      vector<FoliaElement*>::const_iterator it= foliadoc->data.begin();
-      while ( it != foliadoc->data.end() ){
-	xmlAddChild( root, (*it)->xml( true, kanon ) );
-	++it;
+      for ( size_t i=0; i < foliadoc->size(); ++i ){
+	FoliaElement* el = foliadoc->index(i);
+	xmlAddChild( root, el->xml( true, kanon ) );
       }
       xmlChar *buf; int size;
       xmlDocDumpFormatMemoryEnc( outDoc, &buf, &size, "UTF-8", 1 );
@@ -1007,7 +1213,7 @@ namespace folia {
   }
 
   vector<vector<Word*> > Document::findwords( list<Pattern>& pats,
-						      const string& args ) const {
+					      const string& args ) const {
     size_t prevsize = 0;
     bool start = true;
     bool unsetwildcards = false;
@@ -1027,7 +1233,7 @@ namespace folia {
 	if ( index > 0 && variablewildcards.empty() )
 	  unsetwildcards = true;
 	else {
-	  if ( !variablewildcards.empty() && 
+	  if ( !variablewildcards.empty() &&
 	       variablewildcards != it->variablewildcards() ){
 	    throw runtime_error("If multiple patterns are provided with variable wildcards, then these wildcards must all be in the same positions!");
 	  }
@@ -1061,7 +1267,7 @@ namespace folia {
     return result;
   }
 
-  Pattern::Pattern( const std::vector<std::string>&v, 
+  Pattern::Pattern( const std::vector<std::string>&v,
 		    const ElementType at,
 		    const string& args ):matchannotation(at) {
     regexp = false;
@@ -1099,10 +1305,10 @@ namespace folia {
     }
   }
 
-  Pattern::Pattern( const std::vector<std::string>&v, 
+  Pattern::Pattern( const std::vector<std::string>&v,
 		    const string& args ):matchannotation(BASE) {
 
-    // code duplication 
+    // code duplication
     // BAD BAD BAD
     //
     regexp = false;
@@ -1141,7 +1347,7 @@ namespace folia {
   }
 
   Pattern::~Pattern(){
-    for ( size_t i=0; i < matchers.size(); ++i ){  
+    for ( size_t i=0; i < matchers.size(); ++i ){
       delete matchers[i];
     }
   }
@@ -1152,7 +1358,7 @@ namespace folia {
     return os;
   }
 
-  bool Pattern::match( const UnicodeString& us, size_t& pos, int& gap, 
+  bool Pattern::match( const UnicodeString& us, size_t& pos, int& gap,
 		       bool& done, bool& flag ) const {
     UnicodeString s = us;
     //  cerr << "gap = " << gap << "cursor=" << pos << " vergelijk '" <<  sequence[pos] << "' met '" << us << "'" << endl;
diff --git a/src/folia.cxx b/src/folia.cxx
index 647032c..d6dfd62 100644
--- a/src/folia.cxx
+++ b/src/folia.cxx
@@ -1,11 +1,11 @@
 /*
-  $Id: folia.cxx 15909 2013-04-03 13:52:24Z sloot $
+  $Id: folia.cxx 17521 2014-08-14 14:44:01Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/folia.cxx $
 
-  Copyright (c) 1998 - 2013
+  Copyright (c) 1998 - 2014
   ILK   - Tilburg University
   CLiPS - University of Antwerp
- 
+
   This file is part of libfolia
 
   libfolia is free software; you can redistribute it and/or modify
@@ -27,6 +27,7 @@
       timbl at uvt.nl
 */
 
+#include <cassert>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
@@ -48,15 +49,15 @@ using namespace std;
 using namespace TiCC;
 
 namespace folia {
-  
+
   string VersionName() { return PACKAGE_STRING; }
   string Version() { return VERSION; }
 
   ostream& operator<<( ostream& os, const FoliaElement& ae ){
     os << " <" << ae.classname();
     KWargs ats = ae.collectAttributes();
-    if ( !ae._id.empty() )
-      ats["id"] = ae._id;
+    if ( !ae.id().empty() )
+      ats["id"] = ae.id();
 
     KWargs::const_iterator it = ats.begin();
     while ( it != ats.end() ){
@@ -64,8 +65,8 @@ namespace folia {
       ++it;
     }
     os << " > {";
-    for( size_t i=0; i < ae.data.size(); ++i ){
-      os << "<" << ae.data[i]->classname() << ">,";
+    for( size_t i=0; i < ae.size(); ++i ){
+      os << "<" << ae.index(i)->classname() << ">,";
     }
     os << "}";
     return os;
@@ -79,11 +80,11 @@ namespace folia {
     return os;
   }
 
-  FoliaElement::FoliaElement( Document *d ){
+  FoliaImpl::FoliaImpl( Document *d ){
     mydoc = d;
     _confidence = -1;
     _element_id = BASE;
-    refcount = 0;
+    _refcount = 0;
     _parent = 0;
     _auth = true;
     _required_attributes = NO_ATT;
@@ -91,32 +92,40 @@ namespace folia {
     _annotation_type = AnnotationType::NO_ANN;
     _annotator_type = UNDEFINED;
     _xmltag = "ThIsIsSoWrOnG";
-    occurrences = 0;  //#Number of times this element may occur in its parent (0=unlimited, default=0)
-    occurrences_per_set = 1; // #Number of times this element may occur per set (0=unlimited, default=1)
-    TEXTDELIMITER = " " ;
+    _occurrences = 0;  //#Number of times this element may occur in its parent (0=unlimited, default=0)
+    _occurrences_per_set = 1; // #Number of times this element may occur per set (0=unlimited, default=1)
+    TEXTDELIMITER = "NONE" ;
     PRINTABLE = true;
     AUTH = true;
   }
 
-  FoliaElement::~FoliaElement( ){
-    //  cerr << "delete element " << _xmltag << " *= " << (void*)this << endl;
+  FoliaImpl::~FoliaImpl( ){
+    // cerr << "delete element id=" << _id << " tag = " << _xmltag << " *= "
+    //  	 << (void*)this << " datasize= " << data.size() << endl;
     for ( size_t i=0; i < data.size(); ++i ){
-      if ( data[i]->refcount == 0 ) // probably only for words
+      if ( data[i]->refcount() == 0 ) {
+	// probably only for words
 	delete data[i];
-      else {
+      }
+      else if ( mydoc ){
 	mydoc->keepForDeletion( data[i] );
       }
     }
+    //    cerr << "\t\tdelete element id=" << _id << " tag = " << _xmltag << " *= "
+    //	 << (void*)this << " datasize= " << data.size() << endl;
+    if ( mydoc ){
+      mydoc->delDocIndex( this, _id );
+    }
   }
 
-  xmlNs *FoliaElement::foliaNs() const {
+  xmlNs *FoliaImpl::foliaNs() const {
     if ( mydoc )
       return mydoc->foliaNs();
     else
       return 0;
   }
 
-  void FoliaElement::setAttributes( const KWargs& kwargs ){
+  void FoliaImpl::setAttributes( const KWargs& kwargs ){
     Attrib supported = _required_attributes | _optional_attributes;
     // if ( _element_id == Feature_t ){
     //   cerr << "set attributes: " << kwargs << " on " << toString(_element_id) << endl;
@@ -130,13 +139,13 @@ namespace folia {
       using TiCC::operator <<;
       cerr << "set attributes: " << kwargs << " on " << toString(_element_id) << endl;
     }
-  
+
     KWargs::const_iterator it = kwargs.find( "generate_id" );
     if ( it != kwargs.end() ) {
       if ( !mydoc ){
 	throw runtime_error( "can't generate an ID without a doc" );
       }
-      FoliaElement * e = (*mydoc)[it->second];
+      FoliaElement *e = (*mydoc)[it->second];
       if ( e ){
 	_id = e->generateId( _xmltag );
       }
@@ -144,7 +153,13 @@ namespace folia {
 	throw ValueError("Unable to generate an id from ID= " + it->second );
     }
     else {
-      it = kwargs.find( "id" );
+      it = kwargs.find( "_id" );
+      KWargs::const_iterator it2 = kwargs.find( "id" );
+      if ( it == kwargs.end() )
+	it = it2;
+      else if ( it2 != kwargs.end() ){
+	throw ValueError("Both 'id' and 'xml:id found for " + classname() );
+      }
       if ( it != kwargs.end() ) {
 	if ( !ID & supported )
 	  throw ValueError("ID is not supported for " + classname() );
@@ -178,7 +193,7 @@ namespace folia {
     }
     else
       _set = "";
-    
+
     it = kwargs.find( "class" );
     if ( it == kwargs.end() )
       it = kwargs.find( "cls" );
@@ -190,8 +205,8 @@ namespace folia {
 	if ( !mydoc ){
 	  throw ValueError( "Class=" + _class + " is used on a node without a document." );
 	}
-	else if ( _set == "" && 
-		  mydoc->defaultset( _annotation_type ) == "" && 
+	else if ( _set == "" &&
+		  mydoc->defaultset( _annotation_type ) == "" &&
 		  mydoc->isDeclared( _annotation_type ) ){
 	  throw ValueError( "Class " + _class + " is used but has no default declaration " +
 			    "for " + toString( _annotation_type ) + "-annotation" );
@@ -203,10 +218,10 @@ namespace folia {
 
     if ( _element_id != TextContent_t ){
       if ( !_class.empty() && _set.empty() )
-	throw ValueError("Set is required for " + classname() + 
+	throw ValueError("Set is required for " + classname() +
 			 " class=\"" + _class + "\" assigned without set."  );
     }
-    it = kwargs.find( "annotator" );    
+    it = kwargs.find( "annotator" );
     if ( it != kwargs.end() ) {
       if ( !(ANNOTATOR & supported) )
 	throw ValueError("Annotator is not supported for " + classname() );
@@ -220,8 +235,8 @@ namespace folia {
     }
     else
       _annotator = "";
-  
-    it = kwargs.find( "annotatortype" );    
+
+    it = kwargs.find( "annotatortype" );
     if ( it != kwargs.end() ) {
       if ( ! (ANNOTATOR & supported) )
 	throw ValueError("Annotatortype is not supported for " + classname() );
@@ -241,7 +256,7 @@ namespace folia {
     else
       _annotator_type = UNDEFINED;
 
-        
+
     it = kwargs.find( "confidence" );
     if ( it != kwargs.end() ) {
       if ( !(CONFIDENCE & supported) )
@@ -250,7 +265,7 @@ namespace folia {
 	try {
 	  _confidence = stringTo<double>(it->second);
 	  if ( _confidence < 0 || _confidence > 1.0 )
-	    throw ValueError("Confidence must be a floating point number between 0 and 1, got " + TiCC::toString(_confidence) );	    
+	    throw ValueError("Confidence must be a floating point number between 0 and 1, got " + TiCC::toString(_confidence) );
 	}
 	catch (...){
 	  throw ValueError("invalid Confidence value, (not a number?)");
@@ -270,7 +285,7 @@ namespace folia {
     }
     else
       _n = "";
-  
+
     it = kwargs.find( "datetime" );
     if ( it != kwargs.end() ) {
       if ( !(DATETIME & supported) )
@@ -293,94 +308,41 @@ namespace folia {
     if ( it != kwargs.end() ){
       _auth = stringTo<bool>( it->second );
     }
-    
+
     if ( mydoc && !_id.empty() )
       mydoc->addDocIndex( this, _id );
-    
-    it = kwargs.find( "actor" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new ActorFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "head" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new HeadFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "value" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new ValueFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "function" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new FunctionFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "level" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new LevelFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "time" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new TimeFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "modality" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new ModalityFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "synset" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new SynsetFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "begindatetime" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new BeginDateTimeFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
-    }
-    it = kwargs.find( "enddatetime" );
-    if ( it != kwargs.end() ){
-      KWargs newa;
-      newa["class"] = it->second;
-      FoliaElement *tmp = new EndDateTimeFeature();
-      tmp->setAttributes( newa );
-      append( tmp );
+
+    addFeatureNodes( kwargs );
+  }
+
+  void FoliaImpl::addFeatureNodes( const KWargs& kwargs ){
+    KWargs::const_iterator it = kwargs.begin();
+    while ( it != kwargs.end() ){
+      string tag = it->first;
+      if ( tag == "head" ){
+	// "head" is special because the tag is "headfeature"
+	// this to avoid conflicts withe the "head" tag!
+	KWargs newa;
+	newa["class"] = it->second;
+	FoliaElement *tmp = new HeadFeature();
+	tmp->setAttributes( newa );
+	append( tmp );
+      }
+      else if ( tag == "actor" || tag == "value"|| tag == "function" ||
+		tag == "level" || tag == "time" || tag == "modality" ||
+		tag == "synset" || tag == "begindatetime" ||
+		tag == "enddatetime" ){
+	KWargs newa;
+	newa["class"] = it->second;
+	FoliaElement *tmp = createElement( mydoc, tag );
+	tmp->setAttributes( newa );
+	append( tmp );
+      }
+      ++it;
     }
-  
   }
 
-  KWargs FoliaElement::collectAttributes() const {
+  KWargs FoliaImpl::collectAttributes() const {
     KWargs attribs;
     bool isDefaultSet = true;
     bool isDefaultAnn = true;
@@ -415,10 +377,10 @@ namespace folia {
 	  attribs["annotatortype"] = "manual";
       }
     }
-  
+
     if ( _confidence >= 0 )
       attribs["confidence"] = TiCC::toString(_confidence);
-  
+
     if ( !_n.empty() )
       attribs["n"] = _n;
 
@@ -441,49 +403,49 @@ namespace folia {
   }
 
   string tagToAtt( const FoliaElement* c ){
-    if ( c->isinstance(SynsetFeature_t) )
-      return "synset";
-    else if ( c->isinstance(ActorFeature_t) )
-      return "actor";
-    else if ( c->isinstance(HeadFeature_t) )
-      return "head";
-    else if ( c->isinstance(ValueFeature_t) )
-      return "value";
-    else if ( c->isinstance(FunctionFeature_t) )
-      return "function";
-    else if ( c->isinstance(BeginDateTimeFeature_t) )
-      return "begindatetime";
-    else if ( c->isinstance(EndDateTimeFeature_t) )
-      return "enddatetime";
-    return "";
+    string att;
+    if ( c->isSubClass( Feature_t ) ){
+      att = c->xmltag();
+      if ( att == "feat" ){
+	// "feat" is a Feature_t too. exclude!
+	att = "";
+      }
+      else if ( att == "headfeature" )
+	// "head" is special
+	att = "head";
+    }
+    return att;
   }
 
-  xmlNode *FoliaElement::xml( bool recursive, bool kanon ) const {
+  xmlNode *FoliaImpl::xml( bool recursive, bool kanon ) const {
     xmlNode *e = XmlNewNode( foliaNs(), _xmltag );
     KWargs attribs = collectAttributes();
-    set<FoliaElement *> skipelements;
+    set<FoliaElement *> attribute_elements;
+    // nodes that can be represented as attributes are converted to atributes
+    // and excluded of 'normal' output.
     vector<FoliaElement*>::const_iterator it=data.begin();
     while ( it != data.end() ){
       string at = tagToAtt( *it );
       if ( !at.empty() ){
 	attribs[at] = (*it)->cls();
-	skipelements.insert( *it );
+	attribute_elements.insert( *it );
       }
       ++it;
     }
     addAttributes( e, attribs );
     if ( recursive ){
       // append children:
-      // we want make sure that text elements are in the right order, 
+      // we want make sure that text elements are in the right order,
       // in front and the 'current' class first
       list<FoliaElement *> textelements;
       list<FoliaElement *> otherelements;
+      list<FoliaElement *> commentelements;
       multimap<ElementType, FoliaElement *> otherelementsMap;
       vector<FoliaElement*>::const_iterator it=data.begin();
       while ( it != data.end() ){
-	if ( skipelements.find(*it) == skipelements.end() ){
+	if ( attribute_elements.find(*it) == attribute_elements.end() ){
 	  if ( (*it)->isinstance(TextContent_t) ){
-	    if ( (*it)->_class == "current" )
+	    if ( (*it)->cls() == "current" )
 	      textelements.push_front( *it );
 	    else
 	      textelements.push_back( *it );
@@ -491,13 +453,23 @@ namespace folia {
 	  else {
 	    if ( kanon )
 	      otherelementsMap.insert( make_pair( (*it)->element_id(), *it ) );
-	    else
-	      otherelements.push_back( *it );
+	    else {
+	      if ( (*it)->isinstance(XmlComment_t) && textelements.empty() ){
+		commentelements.push_back( *it );
+	      }
+	      else
+		otherelements.push_back( *it );
+	    }
 	  }
 	}
 	++it;
       }
-      list<FoliaElement*>::const_iterator lit=textelements.begin();
+      list<FoliaElement*>::const_iterator lit=commentelements.begin();
+      while ( lit != commentelements.end() ){
+	xmlAddChild( e, (*lit)->xml( recursive, kanon ) );
+	++lit;
+      }
+      lit=textelements.begin();
       while ( lit != textelements.end() ){
 	xmlAddChild( e, (*lit)->xml( recursive, kanon ) );
 	++lit;
@@ -521,7 +493,8 @@ namespace folia {
     return e;
   }
 
-  string FoliaElement::str() const {
+  string FoliaImpl::str() const {
+    cerr << "Impl::str()" << endl;
     return _xmltag;
   }
 
@@ -535,86 +508,151 @@ namespace folia {
       return false;
     }
   }
-  
-  UnicodeString FoliaElement::text( const string& cls, bool retaintok ) const {
+
+  //#define DEBUG_TEXT
+  //#define DEBUG_TEXT_DEL
+
+  string FoliaImpl::getTextDelimiter( bool retaintok ) const {
+#ifdef DEBUG_TEXT_DEL
+    cerr << "IN " << xmltag() << "::gettextdelimiter (" << retaintok << ")" << endl;
+#endif
+    if ( TEXTDELIMITER == "NONE" ){
+      if ( data.size() > 0 ){
+	// attempt to get a delimiter form the last child
+	string det = data[data.size()-1]->getTextDelimiter( retaintok );
+#ifdef DEBUG_TEXT_DEL
+	cerr << "out" << xmltag() << "::gettextdelimiter ==> '" << det << "'" << endl;
+#endif
+	return det;
+      }
+      else
+#ifdef DEBUG_TEXT_DEL
+	cerr << "out" << xmltag() << "::gettextdelimiter ==> ''" << endl;
+#endif
+	return "";
+    }
+    return TEXTDELIMITER;
+  }
+
+  UnicodeString FoliaImpl::text( const string& cls, bool retaintok ) const {
     // get the UnicodeString value of underlying elements
     // default cls="current"
-    if ( !PRINTABLE )
-      throw NoSuchText( _xmltag );
-    //  cerr << (void*)this << ":text() for " << _xmltag << " and class= " << cls << " step 1 " << endl;
-    
-    UnicodeString result;    
+#ifdef DEBUG_TEXT
+    cerr << "TEXT(" << cls << ") op node : " << xmltag() << " id ( " << id() << ")" << endl;
+#endif
+    UnicodeString result;
     try {
-      result = this->textcontent(cls)->text(cls, retaintok );
+      result = this->stricttext(cls);
     } catch (NoSuchText& e ) {
-      for( size_t i=0; i < data.size(); ++i ){
-	// try to get text dynamically from children
-	// skip TextContent elements
-	if ( data[i]->PRINTABLE && !data[i]->isinstance( TextContent_t ) ){
-	  try {
-	    UnicodeString tmp = data[i]->text( cls, retaintok );
-	    //	cerr << "text() for " << _xmltag << " step 2, tmp= " << tmp << endl;
-	    result += tmp;
-	    if ( !tmp.isEmpty() ){
-	      result += UTF8ToUnicode( data[i]->getTextDelimiter( retaintok ) );
-	    }
-	  } catch ( NoSuchText& e ){
-	  }
+#ifdef DEBUG_TEXT
+      cerr << "No direct textcontent found: try children" << endl;
+#endif
+      result = deeptext( cls, retaintok );
+    }
+    return result;
+  }
+
+  UnicodeString FoliaImpl::deeptext( const string& cls,
+				     bool retaintok ) const {
+    // get the UnicodeString value of underlying elements
+    // default cls="current"
+#ifdef DEBUG_TEXT
+    cerr << "deepTEXT(" << cls << ") op node : " << _xmltag << " id(" << id() << ")" << endl;
+#endif
+#ifdef DEBUG_TEXT
+    cerr << "deeptext: node has " << data.size() << " children." << endl;
+#endif
+    vector<UnicodeString> parts;
+    vector<UnicodeString> seps;
+    for( size_t i=0; i < data.size(); ++i ){
+      // try to get text dynamically from children
+      // skip TextContent elements
+      if ( data[i]->printable() && !data[i]->isinstance( TextContent_t ) ){
+#ifdef DEBUG_TEXT
+	cerr << "deeptext:bekijk node[" << i << "] " << data[i]->xmltag() << endl;
+#endif
+	try {
+	  UnicodeString tmp = data[i]->text( cls, retaintok );
+#ifdef DEBUG_TEXT
+	  cerr << "deeptext found '" << tmp << "'" << endl;
+#endif
+	  if ( !isSubClass(AbstractTextMarkup_t) )
+	    tmp.trim();
+	  parts.push_back(tmp);
+	  // get the delimiter
+	  string delim = data[i]->getTextDelimiter( retaintok );
+#ifdef DEBUG_TEXT
+	  cerr << "deeptext:delimiter van "<< data[i]->xmltag() << " ='" << delim << "'" << endl;
+#endif
+	  seps.push_back(UTF8ToUnicode(delim));
+	} catch ( NoSuchText& e ){
+#ifdef DEBUG_TEXT
+	  cerr << "HELAAS" << endl;
+#endif
 	}
       }
     }
-    
-    //  cerr << "text() for " << _xmltag << " step 3 >> " << endl;
-    
-    result.trim();
+
+    // now construct the result;
+    UnicodeString result;
+    for( size_t i=0; i < parts.size(); ++i ){
+      result += parts[i];
+      if ( i < parts.size()-1)
+	result += seps[i];
+    }
+#ifdef DEBUG_TEXT
+    cerr << "deeptext() for " << _xmltag << " step 3 " << endl;
+#endif
     if ( !result.isEmpty() ){
-      //    cerr << "text() for " << _xmltag << " result= " << result << endl;
+#ifdef DEBUG_TEXT
+      cerr << "deeptext() for " << _xmltag << " result= '" << result << "'" << endl;
+#endif
       return result;
     }
     else
-      throw NoSuchText( ": empty!" );
+      throw NoSuchText( "(class=" + cls +"): empty!" );
   }
-  
+
   UnicodeString FoliaElement::stricttext( const string& cls ) const {
-    // get UnicoeString content of TextContent children only
+    // get UnicodeString content of TextContent children only
     // default cls="current"
     return this->textcontent(cls)->text(cls);
   }
 
-  TextContent *FoliaElement::textcontent( const string& cls ) const {
+  TextContent *FoliaImpl::textcontent( const string& cls ) const {
     // Get the text explicitly associated with this element (of the specified class).
     // the default class is 'current'
     // Returns the TextContent instance rather than the actual text. Does not recurse into children
     // with sole exception of Correction
-    // Raises NoSuchText exception if not found. 
-    
+    // Raises NoSuchText exception if not found.
+
     if ( !PRINTABLE )
-      throw NoSuchText( _xmltag );
-    
+      throw NoSuchText( "non-printable tag: " +  _xmltag );
+
     for( size_t i=0; i < data.size(); ++i ){
-      if ( data[i]->isinstance(TextContent_t) && (data[i]->_class == cls) ){
+      if ( data[i]->isinstance(TextContent_t) && (data[i]->cls() == cls) ){
 	return dynamic_cast<TextContent*>(data[i]);
       }
       else if ( data[i]->element_id() == Correction_t) {
-	try {	    
+	try {
 	  return data[i]->textcontent(cls);
 	} catch ( NoSuchText& e ){
 	  // continue search for other Corrections or a TextContent
 	}
       }
-    }    
-    throw NoSuchText( "textcontent()" );
+    }
+    throw NoSuchText( _xmltag + "::textcontent()" );
   }
 
-  vector<FoliaElement *>FoliaElement::findreplacables( FoliaElement *par ) const {
-    return par->select( element_id(), _set, false );
+  vector<FoliaElement *>FoliaImpl::findreplacables( FoliaElement *par ) const {
+    return par->select( element_id(), sett(), false );
   }
 
-  void FoliaElement::replace( FoliaElement *child ){
-    // Appends a child element like append(), but replaces any existing child 
-    // element of the same type and set. 
+  void FoliaImpl::replace( FoliaElement *child ){
+    // Appends a child element like append(), but replaces any existing child
+    // element of the same type and set.
     // If no such child element exists, this will act the same as append()
-  
+
     vector<FoliaElement*> replace = child->findreplacables( this );
     if ( replace.empty() ){
       // nothing to replace, simply call append
@@ -627,22 +665,45 @@ namespace folia {
       remove( replace[0], true );
       append( child );
     }
-  }                
+  }
+
+  FoliaElement* FoliaImpl::replace( FoliaElement *old,
+				    FoliaElement* _new ){
+    // replaced old by _new
+    // returns old
+    // when not found does nothing and returns 0;
+    for( size_t i=0; i < data.size(); ++i ){
+      if ( data[i] == old ){
+	data[i] = _new;
+	_new->setParent( this );
+	return old;
+      }
+    }
+    return 0;
+  }
 
-  TextContent *FoliaElement::settext( const string& txt, 
+  TextContent *FoliaElement::settext( const string& txt,
 				      const string& cls ){
     // create a TextContent child of class 'cls'
     // Default cls="current"
     KWargs args;
     args["value"] = txt;
     args["class"] = cls;
-    TextContent *node = new TextContent( mydoc );
+    TextContent *node = new TextContent( doc() );
     node->setAttributes( args );
     replace( node );
     return node;
   }
 
-  TextContent *FoliaElement::settext( const string& txt, 
+  TextContent *FoliaElement::setutext( const UnicodeString& txt,
+				       const string& cls ){
+    // create a TextContent child of class 'cls'
+    // Default cls="current"
+    string utf8 = UnicodeToUTF8(txt);
+    return settext( utf8, cls );
+  }
+
+  TextContent *FoliaElement::settext( const string& txt,
 				      int offset,
 				      const string& cls ){
     // create a TextContent child of class 'cls'
@@ -652,12 +713,21 @@ namespace folia {
     args["value"] = txt;
     args["class"] = cls;
     args["offset"] = TiCC::toString(offset);
-    TextContent *node = new TextContent( mydoc );
+    TextContent *node = new TextContent( doc() );
     node->setAttributes( args );
     replace( node );
     return node;
   }
 
+  TextContent *FoliaElement::setutext( const UnicodeString& txt,
+				       int offset,
+				       const string& cls ){
+    // create a TextContent child of class 'cls'
+    // Default cls="current"
+    string utf8 = UnicodeToUTF8(txt);
+    return settext( utf8, offset, cls );
+  }
+
   string FoliaElement::description() const {
     vector<FoliaElement *> v =  select( Description_t, false );
     if ( v.size() == 0 )
@@ -666,27 +736,69 @@ namespace folia {
       return v[0]->description();
   }
 
-  void fillSM( map<ElementType,set<ElementType> >& sm ){
-    static ElementType featureSet[] = { SynsetFeature_t, 
-					ActorFeature_t, HeadFeature_t, 
-					ValueFeature_t, TimeFeature_t, 
+  bool isSubClass( const ElementType e1, const ElementType e2 ){
+    static map<ElementType,set<ElementType> > sm;
+    static ElementType structureSet[] = { Head_t, Division_t,
+					  TableHead_t, Table_t,
+					  Row_t, Cell_t,
+					  LineBreak_t, WhiteSpace_t,
+					  Word_t, WordReference_t,
+					  Sentence_t, Paragraph_t,
+					  Quote_t, Morpheme_t,
+					  Text_t, Event_t, Reference_t,
+					  External_t,
+					  Caption_t, Label_t,
+					  Item_t, List_t,
+					  Figure_t, Alternative_t, Note_t };
+    static ElementType featureSet[] = { SynsetFeature_t,
+					ActorFeature_t, HeadFeature_t,
+					ValueFeature_t, TimeFeature_t,
 					ModalityFeature_t, LevelFeature_t,
-					BeginDateTimeFeature_t, 
+					BeginDateTimeFeature_t,
 					EndDateTimeFeature_t,
 					FunctionFeature_t };
-    sm[Feature_t] = set<ElementType>(featureSet, featureSet + 10 );
-    static ElementType annolaySet[] = { SyntaxLayer_t, 
-					Chunking_t, Entities_t, 
-					TimingLayer_t, Dependencies_t, 
+    static ElementType tokenAnnoSet[] = { Pos_t, Lemma_t, Morphology_t,
+					  Sense_t, Phon_t, Str_t, Lang_t,
+					  Correction_t, Subjectivity_t,
+					  ErrorDetection_t };
+    static ElementType spanAnnoSet[] = { SyntacticUnit_t,
+					 Chunk_t, Entity_t,
+					 Headwords_t,
+					 DependencyDependent_t,Dependency_t,
+					 CoreferenceLink_t, CoreferenceChain_t,
+					 Semrole_t, TimeSegment_t };
+    static ElementType annolaySet[] = { SyntaxLayer_t,
+					Chunking_t, Entities_t,
+					TimingLayer_t, Morphology_t,
+					Dependencies_t,
 					Coreferences_t, Semroles_t };
-    sm[AnnotationLayer_t] = set<ElementType>( annolaySet, 
-					      annolaySet + 7 );
-  }
-
-  bool isSubClass( ElementType e1, ElementType e2 ){
-    static map<ElementType,set<ElementType> > sm;
-    if ( sm.empty() )
-      fillSM( sm );
+    static ElementType markupSet[] = { TextMarkupString_t, TextMarkupGap_t,
+				       TextMarkupCorrection_t,
+				       TextMarkupError_t, TextMarkupStyle_t };
+    static bool filled = false;
+    if ( !filled ){
+      sm[Structure_t]
+	= set<ElementType>( structureSet,
+			    structureSet + sizeof(structureSet)/sizeof(ElementType) );
+      sm[Feature_t]
+	= set<ElementType>(featureSet,
+			   featureSet + sizeof(featureSet)/sizeof(ElementType) );
+      sm[TokenAnnotation_t]
+	= set<ElementType>( tokenAnnoSet,
+			    tokenAnnoSet + sizeof(tokenAnnoSet)/sizeof(ElementType) );
+      sm[SpanAnnotation_t]
+	= set<ElementType>( spanAnnoSet,
+			    spanAnnoSet + sizeof(spanAnnoSet)/sizeof(ElementType) );
+      sm[AnnotationLayer_t]
+	= set<ElementType>( annolaySet,
+			    annolaySet + sizeof(annolaySet)/sizeof(ElementType) );
+      sm[AbstractTextMarkup_t]
+	= set<ElementType>( markupSet,
+			    markupSet + sizeof(markupSet)/sizeof(ElementType) );
+      filled = true;
+    }
+    if ( e1 == e2 )
+      return true;
     map<ElementType,set<ElementType> >::const_iterator it = sm.find( e2 );
     if ( it != sm.end() ){
       return it->second.find( e1 ) != it->second.end();
@@ -694,51 +806,74 @@ namespace folia {
     return false;
   }
 
-  bool FoliaElement::acceptable( ElementType t ) const {
-    set<ElementType>::const_iterator it = _accepted_data.find( t );
-    if ( it == _accepted_data.end() ){
-      return false;
-      // it = _accepted_data.begin();
-      // while ( it != _accepted_data.end() ){
-      // 	if ( isSubClass( t, *it ) )
-      // 	  return true;
-      // 	++it;
-      // }
-      // return false;
+  bool FoliaElement::isSubClass( ElementType t ) const {
+    return folia::isSubClass( element_id(), t );
+  }
+
+  bool FoliaImpl::acceptable( ElementType t ) const {
+    if ( t == XmlComment_t )
+      return true;
+    else {
+      set<ElementType>::const_iterator it = _accepted_data.find( t );
+      if ( it == _accepted_data.end() ){
+	it = _accepted_data.begin();
+	while ( it != _accepted_data.end() ){
+	  if ( folia::isSubClass( t, *it ) )
+	    return true;
+	  ++it;
+	}
+	return false;
+      }
+      return true;
     }
-    return true;
   }
- 
-  bool FoliaElement::addable( const FoliaElement *c ) const {
-    if ( !acceptable( c->_element_id ) ){
+
+  bool FoliaImpl::addable( const FoliaElement *c ) const {
+    if ( !acceptable( c->element_id() ) ){
       throw ValueError( "Unable to append object of type " + c->classname()
 			+ " to a " + classname() );
     }
-    if ( c->occurrences > 0 ){
-      vector<FoliaElement*> v = select( c->_element_id );
+    if ( c->occurrences() > 0 ){
+      vector<FoliaElement*> v = select( c->element_id(), false );
       size_t count = v.size();
-      if ( count > c->occurrences ){
+      if ( count >= c->occurrences() ){
 	throw DuplicateAnnotationError( "Unable to add another object of type " + c->classname() + " to " + classname() + ". There are already " + TiCC::toString(count) + " instances of this class, which is the maximum." );
       }
     }
-    if ( c->occurrences_per_set > 0 &&
-	 ( (CLASS|SETONLY) & c->_required_attributes ) ){
-      vector<FoliaElement*> v = select( c->_element_id, c->_set );
+    if ( c->occurrences_per_set() > 0 &&
+	 ( (CLASS|SETONLY) & c->required_attributes() ) ){
+      vector<FoliaElement*> v = select( c->element_id(), c->sett(), false );
       size_t count = v.size();
-      if ( count > c->occurrences_per_set )
+      if ( count >= c->occurrences_per_set() ){
 	throw DuplicateAnnotationError( "Unable to add another object of type " + c->classname() + " to " + classname() + ". There are already " + TiCC::toString(count) + " instances of this class, which is the maximum." );
+      }
+    }
+    if ( c->parent() &&
+	 !(c->element_id() == Word_t || c->element_id() == Morpheme_t ) ){
+      // Only for WordRef i hope
+      throw XmlError( "attempt to reconnect node " + c->classname()
+		      + " to a " + classname() + " node, id=" + _id
+		      + ", it was already connected to a "
+		      +  c->parent()->classname() + " id=" + c->parent()->id() );
+    }
+    if ( c->element_id() == TextContent_t && _element_id == Word_t ){
+      string val = c->str();
+      val = trim( val );
+      if ( val.empty() ){
+	throw ValueError( "attempt to add an empty <t> to word: " + _id );
+      }
     }
     return true;
   }
- 
-  void FoliaElement::fixupDoc( Document* doc ) {
+
+  void FoliaImpl::fixupDoc( Document* doc ) {
     if ( !mydoc ){
       mydoc = doc;
       string myid = id();
-      if ( !_set.empty() 
+      if ( !_set.empty()
 	   && (CLASS & _required_attributes )
 	   && !mydoc->isDeclared( _annotation_type, _set ) )
-	throw ValueError( "Set " + _set + " is used in " + _xmltag 
+	throw ValueError( "Set " + _set + " is used in " + _xmltag
 			  + "element: " + myid + " but has no declaration " +
 			  "for " + toString( _annotation_type ) + "-annotation" );
       if ( !myid.empty() )
@@ -748,8 +883,8 @@ namespace folia {
 	data[i]->fixupDoc( doc );
     }
   }
-  
-  bool FoliaElement::checkAtts(){
+
+  bool FoliaImpl::checkAtts(){
     if ( _id.empty() && (ID & _required_attributes ) ){
       throw ValueError( "ID is required for " + classname() );
     }
@@ -777,12 +912,17 @@ namespace folia {
     return true;
   }
 
-  FoliaElement *FoliaElement::append( FoliaElement *child ){
+  FoliaElement *FoliaImpl::append( FoliaElement *child ){
     bool ok = false;
     try {
       ok = child->checkAtts();
       ok = addable( child );
     }
+    catch ( XmlError& ){
+      // don't delethe the offending child in case of illegal reconnection
+      // it will be deleted by the true parent
+      throw;
+    }
     catch ( exception& ){
       delete child;
       throw;
@@ -790,47 +930,62 @@ namespace folia {
     if ( ok ){
       child->fixupDoc( mydoc );
       data.push_back(child);
-      if ( !child->_parent ) // Only for WordRef i hope
-	child->_parent = this;
+      if ( !child->parent() ) // Only for WordRef and Morpheme
+	child->setParent(this);
+      else
+	child->increfcount();
       return child->postappend();
     }
     return 0;
   }
 
 
-  void FoliaElement::remove( FoliaElement *child, bool del ){
+  void FoliaImpl::remove( FoliaElement *child, bool del ){
     vector<FoliaElement*>::iterator it = std::remove( data.begin(), data.end(), child );
     data.erase( it, data.end() );
     if ( del )
       delete child;
   }
 
-  FoliaElement* FoliaElement::index( size_t i ) const {
+  void FoliaImpl::remove( size_t pos, bool del ){
+    if ( pos < data.size() ){
+      vector<FoliaElement*>::iterator it = data.begin();
+      while ( pos > 0 ){
+	++it;
+	--pos;
+      }
+      if ( del )
+	delete *it;
+      data.erase(it);
+    }
+  }
+
+  FoliaElement* FoliaImpl::index( size_t i ) const {
     if ( i < data.size() )
       return data[i];
     else
       throw range_error( "[] index out of range" );
   }
 
-  FoliaElement* FoliaElement::rindex( size_t i ) const {
+  FoliaElement* FoliaImpl::rindex( size_t i ) const {
     if ( i < data.size() )
       return data[data.size()-1-i];
     else
       throw range_error( "[] rindex out of range" );
   }
 
-  vector<FoliaElement*> FoliaElement::select( ElementType et,
-					      const string& st,
-					      const set<ElementType>& exclude,
-					      bool recurse ) const {
+  vector<FoliaElement*> FoliaImpl::select( ElementType et,
+					   const string& st,
+					   const set<ElementType>& exclude,
+					   bool recurse ) const {
     vector<FoliaElement*> res;
     for ( size_t i = 0; i < data.size(); ++i ){
-      if ( data[i]->_element_id == et && 
-	   ( st.empty() || data[i]->_set == st ) ){
+      if ( data[i]->element_id() == et &&
+	   ( st.empty() || data[i]->sett() == st ) ){
 	res.push_back( data[i] );
       }
       if ( recurse ){
-	if ( exclude.find( data[i]->_element_id ) == exclude.end() ){
+	if ( exclude.find( data[i]->element_id() ) == exclude.end() ){
 	  vector<FoliaElement*> tmp = data[i]->select( et, st, exclude, recurse );
 	  res.insert( res.end(), tmp.begin(), tmp.end() );
 	}
@@ -839,28 +994,51 @@ namespace folia {
     return res;
   }
 
-  vector<FoliaElement*> FoliaElement::select( ElementType et,
-					      const string& st,
-					      bool recurse ) const {
-    static set<ElementType> excludeSet;
-    if ( excludeSet.empty() ){
-      excludeSet.insert( Original_t );
-      excludeSet.insert( Suggestion_t );
-      excludeSet.insert( Alternative_t );
-    }
-    return select( et, st, excludeSet, recurse );
-  }
-
-  vector<FoliaElement*> FoliaElement::select( ElementType et,
-					      const set<ElementType>& exclude,
-					      bool recurse ) const {
+  static ElementType ignoreList[] = { Original_t,
+				      Suggestion_t,
+				      Alternative_t };
+  set<ElementType> default_ignore( ignoreList,
+				   ignoreList + sizeof( ignoreList )/sizeof( ElementType ) );
+
+  static ElementType ignoreAnnList[] = { Original_t,
+					 Suggestion_t,
+					 Alternative_t,
+					 Morphology_t };
+  set<ElementType> default_ignore_annotations( ignoreAnnList,
+					       ignoreAnnList + sizeof( ignoreAnnList )/sizeof( ElementType ) );
+
+  static ElementType ignoreStrList[] = { Original_t,
+					 Suggestion_t,
+					 Alternative_t,
+					 Chunk_t,
+					 SyntacticUnit_t,
+					 Coreferences_t,
+					 Semroles_t,
+					 Entity_t,
+					 Headwords_t,
+					 TimingLayer_t,
+					 DependencyDependent_t,
+					 TimeSegment_t };
+  set<ElementType> default_ignore_structure( ignoreStrList,
+					     ignoreStrList + sizeof( ignoreStrList )/sizeof( ElementType ) );
+
+
+  vector<FoliaElement*> FoliaImpl::select( ElementType et,
+					   const string& st,
+					   bool recurse ) const {
+    return select( et, st, default_ignore, recurse );
+  }
+
+  vector<FoliaElement*> FoliaImpl::select( ElementType et,
+					   const set<ElementType>& exclude,
+					   bool recurse ) const {
     vector<FoliaElement*> res;
     for ( size_t i = 0; i < data.size(); ++i ){
-      if ( data[i]->_element_id == et ){
+      if ( data[i]->element_id() == et ){
 	res.push_back( data[i] );
       }
       if ( recurse ){
-	if ( exclude.find( data[i]->_element_id ) == exclude.end() ){
+	if ( exclude.find( data[i]->element_id() ) == exclude.end() ){
 	  vector<FoliaElement*> tmp = data[i]->select( et, exclude, recurse );
 	  res.insert( res.end(), tmp.begin(), tmp.end() );
 	}
@@ -869,39 +1047,54 @@ namespace folia {
     return res;
   }
 
-  vector<FoliaElement*> FoliaElement::select( ElementType et,
+  vector<FoliaElement*> FoliaImpl::select( ElementType et,
 					      bool recurse ) const {
-    static set<ElementType> excludeSet;
-    if ( excludeSet.empty() ){
-      excludeSet.insert( Quote_t );
-      excludeSet.insert( Original_t );
-      excludeSet.insert( Suggestion_t );
-      excludeSet.insert( Alternative_t );
-      excludeSet.insert( Chunk_t );
-      excludeSet.insert( SyntacticUnit_t );
-      excludeSet.insert( Entity_t );
-      excludeSet.insert( Headwords_t );
-      excludeSet.insert( DependencyDependent_t );
-    }
-    return select( et, excludeSet, recurse );
+    return select( et, default_ignore, recurse );
   }
-  
-  FoliaElement* FoliaElement::parseXml( const xmlNode *node ){
+
+  FoliaElement* FoliaImpl::parseXml( const xmlNode *node ){
     KWargs att = getAttributes( node );
-    //    cerr << "got attributes " << att << endl;
     setAttributes( att );
     xmlNode *p = node->children;
     while ( p ){
       if ( p->type == XML_ELEMENT_NODE ){
 	string tag = Name( p );
-	FoliaElement *t = createElement( mydoc, tag );
+	FoliaElement *t = createElement( doc(), tag );
+	if ( t ){
+	  if ( doc() && doc()->debug > 2 )
+	    cerr << "created " << t << endl;
+	  t = t->parseXml( p );
+	  if ( t ){
+	    if ( doc() && doc()->debug > 2 )
+	      cerr << "extend " << this << " met " << t << endl;
+	    append( t );
+	  }
+	}
+      }
+      else if ( p->type == XML_COMMENT_NODE ){
+	string tag = "xml-comment";
+	FoliaElement *t = createElement( doc(), tag );
+	if ( t ){
+	  if ( doc() && doc()->debug > 2 )
+	    cerr << "created " << t << endl;
+	  t = t->parseXml( p );
+	  if ( t ){
+	    if ( doc() && doc()->debug > 2 )
+	      cerr << "extend " << this << " met " << t << endl;
+	    append( t );
+	  }
+	}
+      }
+      else if ( p->type == XML_TEXT_NODE ){
+	string tag = "xml-text";
+	FoliaElement *t = createElement( doc(), tag );
 	if ( t ){
-	  if ( mydoc && mydoc->debug > 2 )
+	  if ( doc() && doc()->debug > 2 )
 	    cerr << "created " << t << endl;
 	  t = t->parseXml( p );
 	  if ( t ){
-	    if ( mydoc && mydoc->debug > 2 )
-	      cerr << "extend " << this << " met " << tag << endl;
+	    if ( doc() && doc()->debug > 2 )
+	      cerr << "extend " << this << " met " << t << endl;
 	    append( t );
 	  }
 	}
@@ -911,7 +1104,7 @@ namespace folia {
     return this;
   }
 
-  void FoliaElement::setDateTime( const string& s ){
+  void FoliaImpl::setDateTime( const string& s ){
     Attrib supported = _required_attributes | _optional_attributes;
     if ( !(DATETIME & supported) )
       throw ValueError("datetime is not supported for " + classname() );
@@ -923,27 +1116,27 @@ namespace folia {
     }
   }
 
-  string FoliaElement::getDateTime() const {
+  string FoliaImpl::getDateTime() const {
     return _datetime;
   }
 
-  string FoliaElement::pos( const string& st ) const { 
-    return annotation<PosAnnotation>( st )->cls(); 
+  string FoliaImpl::pos( const string& st ) const {
+    return annotation<PosAnnotation>( st )->cls();
   }
-  
-  string FoliaElement::lemma( const string& st ) const { 
-    return annotation<LemmaAnnotation>( st )->cls(); 
+
+  string FoliaImpl::lemma( const string& st ) const {
+    return annotation<LemmaAnnotation>( st )->cls();
   }
 
-  PosAnnotation *FoliaElement::addPosAnnotation( const KWargs& args ){
+  PosAnnotation *FoliaImpl::addPosAnnotation( const KWargs& args ){
     return addAnnotation<PosAnnotation>( args );
   }
 
-  LemmaAnnotation *FoliaElement::addLemmaAnnotation( const KWargs& args ){
+  LemmaAnnotation *FoliaImpl::addLemmaAnnotation( const KWargs& args ){
     return addAnnotation<LemmaAnnotation>( args );
   }
 
-  Sentence *FoliaElement::addSentence( const KWargs& args ){
+  Sentence *FoliaImpl::addSentence( const KWargs& args ){
     Sentence *res = new Sentence( mydoc );
     KWargs kw = args;
     if ( kw["id"].empty() ){
@@ -961,7 +1154,7 @@ namespace folia {
     return res;
   }
 
-  Word *FoliaElement::addWord( const KWargs& args ){
+  Word *FoliaImpl::addWord( const KWargs& args ){
     Word *res = new Word( mydoc );
     KWargs kw = args;
     if ( kw["id"].empty() ){
@@ -979,6 +1172,31 @@ namespace folia {
     return res;
   }
 
+  std::string Quote::getTextDelimiter( bool retaintok ) const {
+#ifdef DEBUG_TEXT_DEL
+    cerr << "IN " << xmltag() << "::gettextdelimiter (" << retaintok << ")" << endl;
+#endif
+    std::vector<FoliaElement*>::const_reverse_iterator it = data.rbegin();
+    while ( it != data.rend() ){
+      if ( (*it)->isinstance( Sentence_t ) ){
+	// if a quote ends in a sentence, we don't want any delimiter
+#ifdef DEBUG_TEXT_DEL
+	cerr << "OUT " << xmltag() << "::gettextdelimiter ==>''" << endl;
+#endif
+	return "";
+      }
+      else {
+	string res = (*it)->getTextDelimiter( retaintok );
+#ifdef DEBUG_TEXT_DEL
+	cerr << "OUT " << xmltag() << "::gettextdelimiter ==> '"
+	     << res << "'" << endl;
+#endif
+	return res;
+      }
+      ++it;
+    }
+    return " ";
+  }
 
   vector<Word*> Quote::wordParts() const {
     vector<Word*> result;
@@ -987,7 +1205,7 @@ namespace folia {
       if ( pnt->isinstance( Word_t ) )
 	result.push_back( dynamic_cast<Word*>(pnt) );
       else if ( pnt->isinstance( Sentence_t ) ){
-	PlaceHolder *p = new PlaceHolder( mydoc, "text='" + 
+	PlaceHolder *p = new PlaceHolder( mydoc, "text='" +
 					  pnt->id() + "'");
 	mydoc->keepForDeletion( p );
 	result.push_back( p );
@@ -1000,7 +1218,7 @@ namespace folia {
 	// ignore
       }
       else {
-	throw XmlError( "Word or Sentence expected in Quote. got: " 
+	throw XmlError( "Word or Sentence expected in Quote. got: "
 			+ pnt->classname() );
       }
     }
@@ -1013,7 +1231,7 @@ namespace folia {
       FoliaElement *pnt = data[i];
       if ( pnt->isinstance( Word_t ) )
 	result.push_back( dynamic_cast<Word*>(pnt) );
-      else if ( pnt->isinstance( Quote_t ) ){	
+      else if ( pnt->isinstance( Quote_t ) ){
 	vector<Word*> v = pnt->wordParts();
 	result.insert( result.end(), v.begin(),v.end() );
       }
@@ -1023,35 +1241,33 @@ namespace folia {
     }
     return result;
   }
-  
+
   Correction *Sentence::splitWord( FoliaElement *orig, FoliaElement *p1, FoliaElement *p2, const KWargs& args ){
     vector<FoliaElement*> ov;
     ov.push_back( orig );
     vector<FoliaElement*> nv;
     nv.push_back( p1 );
     nv.push_back( p2 );
-    vector<FoliaElement*> nil;
-    return correctWords( ov, nv, nil, args );
+    return correctWords( ov, nv, args );
   }
 
-  Correction *Sentence::mergewords( FoliaElement *nw, 
+  Correction *Sentence::mergewords( FoliaElement *nw,
 				    const vector<FoliaElement *>& orig,
 				    const string& args ){
     vector<FoliaElement*> nv;
     nv.push_back( nw );
-    vector<FoliaElement*> nil;
-    return correctWords( orig, nv, nil, getArgs(args) );
+    return correctWords( orig, nv, getArgs(args) );
   }
 
-  Correction *Sentence::deleteword( FoliaElement *w, 
+  Correction *Sentence::deleteword( FoliaElement *w,
 				    const string& args ){
     vector<FoliaElement*> ov;
     ov.push_back( w );
-    vector<FoliaElement*> nil;
-    return correctWords( ov, nil, nil, getArgs(args) );
+    vector<FoliaElement*> nil1;
+    return correctWords( ov, nil1, getArgs(args) );
   }
 
-  Correction *Sentence::insertword( FoliaElement *w, 
+  Correction *Sentence::insertword( FoliaElement *w,
 				    FoliaElement *p,
 				    const string& args ){
     if ( !p || !p->isinstance( Word_t ) )
@@ -1060,7 +1276,7 @@ namespace folia {
       throw runtime_error( "insertword(): new word is not a Word " );
     Word *tmp = new Word( "text='dummy', id='dummy'" );
     tmp->setParent( this ); // we create a dummy Word as member of the
-    // Sentence. This makes correct() happy
+    // Sentence. This makes correctWords() happy
     vector<FoliaElement *>::iterator it = data.begin();
     while ( it != data.end() ){
       if ( *it == p ){
@@ -1075,17 +1291,15 @@ namespace folia {
     ov.push_back( *it );
     vector<FoliaElement *> nv;
     nv.push_back( w );
-    vector<FoliaElement*> nil;
-    return correctWords( ov, nv, nil, getArgs(args) );  
+    return correctWords( ov, nv, getArgs(args) );
   }
 
   Correction *Sentence::correctWords( const vector<FoliaElement *>& orig,
 				      const vector<FoliaElement *>& _new,
-				      const vector<FoliaElement *>& current, 
 				      const KWargs& args ){
     // Generic correction method for words. You most likely want to use the helper functions
     //      splitword() , mergewords(), deleteword(), insertword() instead
-  
+
     // sanity check:
     vector<FoliaElement *>::const_iterator it = orig.begin();
     while ( it != orig.end() ){
@@ -1101,20 +1315,27 @@ namespace folia {
 	throw runtime_error("new word is not a Word instance" );
       ++it;
     }
-    it = current.begin();
-    while ( it != current.end() ){
-      if ( ! (*it)->isinstance( Word_t) )
-	throw runtime_error("current word is not a Word instance" );
-      ++it;
-    }
     KWargs::const_iterator ait = args.find("suggest");
     if ( ait != args.end() && ait->second == "true" ){
-      vector<FoliaElement *> nil;
-      return correct( nil, orig, nil, _new, args );
+      FoliaElement *sugg = new Suggestion();
+      it = _new.begin();
+      while ( it != _new.end() ){
+	sugg->append( *it );
+	++it;
+      }
+      vector<FoliaElement *> nil1;
+      vector<FoliaElement *> nil2;
+      vector<FoliaElement *> sv;
+      vector<FoliaElement *> tmp = orig;
+      sv.push_back( sugg );
+      return correct( nil1, tmp, nil2, sv, args );
     }
     else {
-      vector<FoliaElement *> nil;
-      return correct( orig, nil, _new, nil, args );
+      vector<FoliaElement *> nil1;
+      vector<FoliaElement *> nil2;
+      vector<FoliaElement *> o_tmp = orig;
+      vector<FoliaElement *> n_tmp = _new;
+      return correct( o_tmp, nil1, n_tmp, nil2, args );
     }
   }
 
@@ -1122,11 +1343,16 @@ namespace folia {
     KWargs kwargs = args; // need to copy
     KWargs::const_iterator it = kwargs.find( "value" );
     if ( it != kwargs.end() ) {
-      _text = UTF8ToUnicode(it->second);
+      XmlText *t = new XmlText();
+      string value = it->second;
+      if ( value.empty() ){
+	// can this ever happen?
+	throw ValueError( "TextContent: 'value' attribute may not be empty." );
+      }
+      t->setvalue( value );
+      append( t );
       kwargs.erase("value");
     }
-    else
-      throw ValueError( "TextContent expects 'value' attribute" );
     it = kwargs.find( "offset" );
     if ( it != kwargs.end() ) {
       _offset = stringTo<int>(it->second);
@@ -1134,34 +1360,30 @@ namespace folia {
     }
     else
       _offset = -1;
-    it = kwargs.find( "lang" );
-    if ( it != kwargs.end() ) {
-      _lang = it->second;
-      kwargs.erase("lang");
-    }
-    else
-      _lang.clear();
     it = kwargs.find( "ref" );
     if ( it != kwargs.end() ) {
       throw NotImplementedError( "ref attribute in TextContent" );
     }
     it = kwargs.find( "cls" );
-    if ( it == kwargs.end() ) 
+    if ( it == kwargs.end() )
       it = kwargs.find( "class" );
     if ( it == kwargs.end() ) {
       kwargs["class"] = "current";
     }
-    FoliaElement::setAttributes(kwargs);
+    FoliaImpl::setAttributes(kwargs);
   }
 
-  FoliaElement* TextContent::parseXml( const xmlNode *node ){
-    KWargs att = getAttributes( node );
-    using TiCC::operator<<;
-    att["value"] = XmlContent( node );
-    setAttributes( att );
-    if ( mydoc && mydoc->debug > 2 )
-      cerr << "set textcontent to " << _text << endl;
-    return this;
+  KWargs TextContent::collectAttributes() const {
+    KWargs attribs = FoliaImpl::collectAttributes();
+    if ( _class == "current" )
+      attribs.erase( "class" );
+    else if ( _class == "original" && parent() && parent()->isinstance( Original_t ) )
+      attribs.erase( "class" );
+
+    if ( _offset >= 0 ){
+      attribs["offset"] = TiCC::toString( _offset );
+    }
+    return attribs;
   }
 
   TextContent *TextContent::postappend(){
@@ -1174,11 +1396,11 @@ namespace folia {
 
   vector<FoliaElement *>TextContent::findreplacables( FoliaElement *par ) const {
     vector<FoliaElement *> result;
-    vector<TextContent*> v = par->select<TextContent>( _set, false );
+    vector<TextContent*> v = par->FoliaElement::select<TextContent>( _set, false );
     // cerr << "TextContent::findreplacable found " << v << endl;
     vector<TextContent*>::iterator it = v.begin();
     while ( it != v.end() ){
-      // cerr << "TextContent::findreplacable bekijkt " << *it << " (" 
+      // cerr << "TextContent::findreplacable bekijkt " << *it << " ("
       if ( (*it)->cls() == _class )
 	result.push_back( *it );
       ++it;
@@ -1189,15 +1411,56 @@ namespace folia {
 
 
   string TextContent::str() const{
-    return UnicodeToUTF8(_text);
+#ifdef DEBUG_TEXT
+    cerr << "textContent::str() this=" << this << endl;
+#endif
+    return UnicodeToUTF8(text());
   }
 
-  UnicodeString TextContent::text( const string&, bool ) const{
-    return _text;
+  UnicodeString TextContent::text( const string& cls, bool retaintok ) const {
+    // get the UnicodeString value of underlying elements
+    // default cls="current"
+#ifdef DEBUG_TEXT
+    cerr << "TextContent::TEXT(" << cls << ") " << endl;
+#endif
+    UnicodeString result;
+    for( size_t i=0; i < data.size(); ++i ){
+      // try to get text dynamically from children
+#ifdef DEBUG_TEXT
+      cerr << "TextContent: bekijk node[" << i+1 << "] " << data[i]->str() << endl;
+#endif
+      try {
+#ifdef DEBUG_TEXT
+	cerr << "roep text(" << cls << ") aan op " << data[i] << endl;
+#endif
+	UnicodeString tmp = data[i]->text( cls, retaintok );
+#ifdef DEBUG_TEXT
+	cerr << "TextContent found '" << tmp << "'" << endl;
+#endif
+	result += tmp;
+      } catch ( NoSuchText& e ){
+#ifdef DEBUG_TEXT
+	cerr << "TextContent::HELAAS" << endl;
+#endif
+      }
+    }
+    result.trim();
+#ifdef DEBUG_TEXT
+    cerr << "TextContent return " << result << endl;
+#endif
+    return result;
   }
 
-  string AllowGenerateID::IGgen( const string& tag, 
-				 const string& nodeId ){
+  string AllowGenerateID::IDgen( const string& tag,
+				 const FoliaElement* parent ){
+    string nodeId = parent->id();
+    if ( nodeId.empty() ){
+      // search nearest parent WITH an id
+      const FoliaElement *p = parent;
+      while ( p && p->id().empty() )
+	p = p->parent();
+      nodeId = p->id();
+    }
     //    cerr << "generateId," << tag << " nodeId = " << nodeId << endl;
     int max = getMaxId(tag);
     //    cerr << "MAX = " << max << endl;
@@ -1206,11 +1469,6 @@ namespace folia {
     return id;
   }
 
-  string AbstractStructureElement::str() const{
-    UnicodeString result = text();
-    return UnicodeToUTF8(result);
-  }
-  
   void AllowGenerateID::setMaxId( FoliaElement *child ) {
     if ( !child->id().empty() && !child->xmltag().empty() ){
       vector<string> parts;
@@ -1247,17 +1505,11 @@ namespace folia {
     return res;
   }
 
-  FoliaElement *AbstractStructureElement::append( FoliaElement *child ){
-    FoliaElement::append( child );
-    setMaxId( child );
-    return child;
-  }
-
-  Correction *AbstractStructureElement::correct( vector<FoliaElement*> original,
-						 vector<FoliaElement*> current,
-						 vector<FoliaElement*> _new,
-						 vector<FoliaElement*> suggestions,
-						 const KWargs& args_in ){
+  Correction * AllowCorrection::correct( const vector<FoliaElement*>& _original,
+					 const vector<FoliaElement*>& current,
+					 const vector<FoliaElement*>& _newv,
+					 const vector<FoliaElement*>& _suggestions,
+					 const KWargs& args_in ){
     // cerr << "correct " << this << endl;
     // cerr << "original= " << original << endl;
     // cerr << "current = " << current << endl;
@@ -1265,11 +1517,15 @@ namespace folia {
     // cerr << "suggestions     = " << suggestions << endl;
     //  cerr << "args in     = " << args_in << endl;
     // Apply a correction
+    Document *mydoc = doc();
     Correction *c = 0;
     bool suggestionsonly = false;
     bool hooked = false;
     FoliaElement * addnew = 0;
     KWargs args = args_in;
+    vector<FoliaElement*> original = _original;
+    vector<FoliaElement*> _new = _newv;
+    vector<FoliaElement*> suggestions = _suggestions;
     KWargs::const_iterator it = args.find("new");
     if ( it != args.end() ){
       TextContent *t = new TextContent( mydoc, "value='" +  it->second + "'" );
@@ -1286,7 +1542,7 @@ namespace folia {
     if ( it != args.end() ){
       // reuse an existing correction instead of making a new one
       try {
-	c = dynamic_cast<Correction*>(mydoc->index(it->second)); 
+	c = dynamic_cast<Correction*>(mydoc->index(it->second));
       }
       catch ( exception& e ){
 	throw ValueError("reuse= must point to an existing correction id!");
@@ -1298,7 +1554,7 @@ namespace folia {
       suggestionsonly = (!c->hasNew() && !c->hasOriginal() && c->hasSuggestions() );
       if ( !_new.empty() && c->hasCurrent() ){
 	// can't add new if there's current, so first set original to current, and then delete current
-      
+
 	if ( !current.empty() )
 	  throw runtime_error( "Can't set both new= and current= !");
 	if ( original.empty() ){
@@ -1317,20 +1573,20 @@ namespace folia {
       c = new Correction(mydoc );
       c->setAttributes( args2 );
     }
-  
+
     if ( !current.empty() ){
       if ( !original.empty() || !_new.empty() )
 	throw runtime_error("When setting current=, original= and new= can not be set!");
-      vector<FoliaElement *>::iterator cit = current.begin();
+      vector<FoliaElement *>::const_iterator cit = current.begin();
       while ( cit != current.end() ){
 	FoliaElement *add = new Current( mydoc );
+	(*cit)->setParent(0);
 	add->append( *cit );
 	c->replace( add );
 	if ( !hooked ) {
-	  for ( size_t i=0; i < data.size(); ++i ){
-	    if ( data[i] == *cit ){
-	      //	    delete data[i];
-	      data[i] = c;
+	  for ( size_t i=0; i < size(); ++i ){
+	    if ( index(i) == *cit ){
+	      replace( index(i), c );
 	      hooked = true;
 	    }
 	  }
@@ -1342,15 +1598,16 @@ namespace folia {
       //    cerr << "there is new! " << endl;
       addnew = new NewElement( mydoc );
       c->append(addnew);
-      vector<FoliaElement *>::iterator nit = _new.begin();    
+      vector<FoliaElement *>::iterator nit = _new.begin();
       while ( nit != _new.end() ){
+	(*nit)->setParent(0);
 	addnew->append( *nit );
 	++nit;
       }
       //    cerr << "after adding " << c << endl;
-      vector<Current*> v = c->select<Current>();
+      vector<Current*> v = c->FoliaElement::select<Current>();
       //delete current if present
-      vector<Current*>::iterator cit = v.begin();    
+      vector<Current*>::iterator cit = v.begin();
       while ( cit != v.end() ){
 	c->remove( *cit, false );
 	++cit;
@@ -1362,17 +1619,19 @@ namespace folia {
       vector<FoliaElement *>::iterator nit = original.begin();
       while ( nit != original.end() ){
 	bool dummyNode = ( (*nit)->id() == "dummy" );
-	if ( !dummyNode )
+	if ( !dummyNode ){
+	  (*nit)->setParent(0);
 	  add->append( *nit );
-	for ( size_t i=0; i < data.size(); ++i ){
-	  if ( data[i] == *nit ){
+	}
+	for ( size_t i=0; i < size(); ++i ){
+	  if ( index(i) == *nit ){
 	    if ( !hooked ) {
+	      FoliaElement *tmp = replace( index(i), c );
 	      if ( dummyNode )
-		delete data[i];
-	      data[i] = c;
+		delete tmp;
 	      hooked = true;
 	    }
-	    else 
+	    else
 	      remove( *nit, false );
 	  }
 	}
@@ -1387,7 +1646,7 @@ namespace folia {
 	FoliaElement *p = addnew->index(i);
 	//      cerr << "bekijk " << p << endl;
 	vector<FoliaElement*> v = p->findreplacables( this );
-	vector<FoliaElement*>::iterator vit=v.begin();      
+	vector<FoliaElement*>::iterator vit=v.begin();
 	while ( vit != v.end() ){
 	  orig.push_back( *vit );
 	  ++vit;
@@ -1403,21 +1662,21 @@ namespace folia {
 	vector<FoliaElement *>::iterator oit = orig.begin();
 	while ( oit != orig.end() ){
 	  //	cerr << " an original is : " << *oit << endl;
+	  (*oit)->setParent( 0 );
 	  add->append( *oit );
-	  for ( size_t i=0; i < data.size(); ++i ){
-	    if ( data[i] == *oit ){
+	  for ( size_t i=0; i < size(); ++i ){
+	    if ( index(i) == *oit ){
 	      if ( !hooked ) {
-		//delete data[i];
-		data[i] = c;
+		replace( index(i), c );
 		hooked = true;
 	      }
-	      else 
+	      else
 		remove( *oit, false );
 	    }
 	  }
 	  ++oit;
 	}
-	vector<Current*> v = c->select<Current>();
+	vector<Current*> v = c->FoliaElement::select<Current>();
 	vector<Current*>::iterator cit = v.begin();
 	//delete current if present
 	while ( cit != v.end() ){
@@ -1426,7 +1685,7 @@ namespace folia {
 	}
       }
     }
-  
+
     if ( addnew ){
       vector<FoliaElement*>::iterator oit = original.begin();
       while ( oit != original.end() ){
@@ -1436,17 +1695,24 @@ namespace folia {
     }
 
     if ( !suggestions.empty() ){
-      FoliaElement *add = new Suggestion( mydoc );
-      c->append(add);
       if ( !hooked )
 	append(c);
       vector<FoliaElement *>::iterator nit = suggestions.begin();
       while ( nit != suggestions.end() ){
-	add->append( *nit );
+	if ( (*nit)->isinstance( Suggestion_t ) ){
+	  (*nit)->setParent(0);
+	  c->append( *nit );
+	}
+	else {
+	  FoliaElement *add = new Suggestion( mydoc );
+	  (*nit)->setParent(0);
+	  add->append( *nit );
+	  c->append( add );
+	}
 	++nit;
       }
     }
-  
+
     it = args.find("reuse");
     if ( it != args.end() ){
       if ( addnew && suggestionsonly ){
@@ -1454,7 +1720,7 @@ namespace folia {
 	for ( size_t i=0; i < sv.size(); ++i ){
 	  if ( !c->annotator().empty() && sv[i]->annotator().empty() )
 	    sv[i]->annotator( c->annotator() );
-	  if ( !(c->annotatortype() == UNDEFINED) && 
+	  if ( !(c->annotatortype() == UNDEFINED) &&
 	       (sv[i]->annotatortype() == UNDEFINED ) )
 	    sv[i]->annotatortype( c->annotatortype() );
 	}
@@ -1470,58 +1736,58 @@ namespace folia {
 	c->confidence( stringTo<double>(it->second) );
 
     }
-
     return c;
   }
 
+  Correction *AllowCorrection::correct( const string& s ){
+    vector<FoliaElement*> nil1;
+    vector<FoliaElement*> nil2;
+    vector<FoliaElement*> nil3;
+    vector<FoliaElement*> nil4;
+    KWargs args = getArgs( s );
+    //    cerr << xmltag() << "::correct() <== " << this << endl;
+    Correction *tmp = correct( nil1, nil2, nil3, nil4, args );
+    //    cerr << xmltag() << "::correct() ==> " << this << endl;
+    return tmp;
+  }
+
+  Correction *AllowCorrection::correct( FoliaElement *_old,
+					FoliaElement *_new,
+					const vector<FoliaElement*>& sugg,
+					const KWargs& args ){
+    vector<FoliaElement *> nv;
+    nv.push_back( _new );
+    vector<FoliaElement *> ov;
+    ov.push_back( _old );
+    vector<FoliaElement *> nil;
+    //    cerr << xmltag() << "::correct() <== " << this << endl;
+    Correction *tmp = correct( ov, nil, nv, sugg, args );
+    //    cerr << xmltag() << "::correct() ==> " << this << endl;
+    return tmp;
+  }
+
+
+  string AbstractStructureElement::str() const{
+    UnicodeString result = text();
+    return UnicodeToUTF8(result);
+  }
+
+  FoliaElement *AbstractStructureElement::append( FoliaElement *child ){
+    FoliaImpl::append( child );
+    setMaxId( child );
+    return child;
+  }
+
   vector<Paragraph*> AbstractStructureElement::paragraphs() const{
-    static set<ElementType> excludeSet;
-    if ( excludeSet.empty() ){
-      excludeSet.insert( Original_t );
-      excludeSet.insert( Suggestion_t );
-      excludeSet.insert( Alternative_t );
-      excludeSet.insert( Chunk_t );
-      excludeSet.insert( SyntacticUnit_t );
-      excludeSet.insert( Entity_t );
-      excludeSet.insert( Headwords_t );
-      excludeSet.insert( DependencyDependent_t );
-    }
-    return select<Paragraph>( excludeSet );
+    return FoliaElement::select<Paragraph>( default_ignore_structure );
   }
 
   vector<Sentence*> AbstractStructureElement::sentences() const{
-    static set<ElementType> excludeSet;
-    if ( excludeSet.empty() ){
-      excludeSet.insert( Quote_t );
-      excludeSet.insert( Original_t );
-      excludeSet.insert( Suggestion_t );
-      excludeSet.insert( Alternative_t );
-      excludeSet.insert( Chunk_t );
-      excludeSet.insert( SyntacticUnit_t );
-      excludeSet.insert( Entity_t );
-      excludeSet.insert( Headwords_t );
-      excludeSet.insert( DependencyDependent_t );
-    }
-    return select<Sentence>( excludeSet );
+    return FoliaElement::select<Sentence>( default_ignore_structure );
   }
 
   vector<Word*> AbstractStructureElement::words() const{
-    static set<ElementType> excludeSet;
-    if ( excludeSet.empty() ){
-      excludeSet.insert( Original_t );
-      excludeSet.insert( Suggestion_t );
-      excludeSet.insert( Alternative_t );
-      excludeSet.insert( Chunk_t );
-      excludeSet.insert( SyntacticUnit_t );
-      excludeSet.insert( Coreferences_t );
-      excludeSet.insert( Semroles_t );
-      excludeSet.insert( Entity_t );
-      excludeSet.insert( Headwords_t );
-      excludeSet.insert( TimingLayer_t );
-      excludeSet.insert( DependencyDependent_t );
-      excludeSet.insert( TimeSegment_t );
-    }
-    return select<Word>( excludeSet );
+    return FoliaElement::select<Word>( default_ignore_structure );
   }
 
   Sentence *AbstractStructureElement::sentences( size_t index ) const {
@@ -1590,7 +1856,7 @@ namespace folia {
       excludeSet.insert( Original_t );
       excludeSet.insert( Suggestion_t );
     }
-    vector<Alternative *> alts = select<Alternative>( excludeSet );
+    vector<Alternative *> alts = FoliaElement::select<Alternative>( excludeSet );
     if ( elt == BASE ){
       return alts;
     }
@@ -1611,28 +1877,6 @@ namespace folia {
     }
   }
 
-  void Word::setAttributes( const KWargs& args ){
-    KWargs::const_iterator it = args.find( "space" );
-    if ( it != args.end() ){
-      if ( it->second == "no" ){
-	space = false;
-      }
-    }
-    it = args.find( "text" );
-    if ( it != args.end() ) {
-      settext( it->second );
-    }
-    FoliaElement::setAttributes( args );
-  }
-
-  KWargs Word::collectAttributes() const {
-    KWargs atts = FoliaElement::collectAttributes();
-    if ( !space ){
-      atts["space"] = "no";
-    }
-    return atts;
-  }
-
   KWargs AlignReference::collectAttributes() const {
     KWargs atts;
     atts["id"] = refId;
@@ -1668,7 +1912,7 @@ namespace folia {
 
 
   KWargs Alignment::collectAttributes() const {
-    KWargs atts = FoliaElement::collectAttributes();
+    KWargs atts = FoliaImpl::collectAttributes();
     if ( !_href.empty() ){
       atts["xlink:href"] = _href;
       if ( !_type.empty() )
@@ -1678,62 +1922,67 @@ namespace folia {
     }
     return atts;
   }
-  
+
   void Alignment::setAttributes( const KWargs& args ){
     KWargs::const_iterator it = args.find( "href" );
     if ( it != args.end() ){
       _href = it->second;
     }
-    FoliaElement::setAttributes( args );
+    FoliaImpl::setAttributes( args );
   }
 
-  Correction *Word::correct( const string& s ){
-    vector<FoliaElement*> nil;
-    KWargs args = getArgs( s );
-    //  cerr << "word::correct() <== " << this << endl;
-    Correction *tmp = AbstractStructureElement::correct( nil, nil, nil, nil, args );
-    //  cerr << "word::correct() ==> " << this << endl;
-    return tmp;
+  void Word::setAttributes( const KWargs& args ){
+    KWargs::const_iterator it = args.find( "space" );
+    if ( it != args.end() ){
+      if ( it->second == "no" ){
+	space = false;
+      }
+    }
+    it = args.find( "text" );
+    if ( it != args.end() ) {
+      settext( it->second );
+    }
+    FoliaImpl::setAttributes( args );
   }
 
-  Correction *Word::correct( FoliaElement *old,
-			     FoliaElement *_new,
-			     const KWargs& args ){
-    vector<FoliaElement *> nv;
-    nv.push_back( _new );
-    vector<FoliaElement *> ov;
-    ov.push_back( old );
-    vector<FoliaElement *> nil;
-    //  cerr << "correct() <== " << this;
-    Correction *tmp =AbstractStructureElement::correct( ov, nil, nv, nil, args );
-    //  cerr << "correct() ==> " << this;
-    return tmp;
+  KWargs Word::collectAttributes() const {
+    KWargs atts = FoliaImpl::collectAttributes();
+    if ( !space ){
+      atts["space"] = "no";
+    }
+    return atts;
+  }
+
+  string Word::getTextDelimiter( bool retaintok ) const {
+    if ( space || retaintok )
+      return TEXTDELIMITER;
+    else {
+      return "";
+    }
   }
 
   FoliaElement *Word::split( FoliaElement *part1, FoliaElement *part2,
-				const string& args ){
+			     const string& args ){
     return sentence()->splitWord( this, part1, part2, getArgs(args) );
   }
 
   FoliaElement *Word::append( FoliaElement *child ) {
-    if ( child->element_id() == Pos_t ||
-    	 child->element_id() == Lemma_t ||
-    	 child->element_id() == Morphology_t ){
+    if ( child->isSubClass( TokenAnnotation_t ) ){
       // sanity check, there may be no other child within the same set
       vector<FoliaElement*> v = select( child->element_id(), child->sett() );
       if ( v.empty() ) {
     	// OK!
-    	return FoliaElement::append( child );
+    	return FoliaImpl::append( child );
       }
       delete child;
       throw DuplicateAnnotationError( "Word::append" );
     }
-    return FoliaElement::append( child );
+    return FoliaImpl::append( child );
   }
 
   Sentence *Word::sentence( ) const {
     // return the sentence this word is a part of, otherwise return null
-    FoliaElement *p = _parent; 
+    FoliaElement *p = _parent;
     while( p ){
       if ( p->isinstance( Sentence_t ) )
 	return dynamic_cast<Sentence*>(p);
@@ -1744,7 +1993,7 @@ namespace folia {
 
   Paragraph *Word::paragraph( ) const {
     // return the sentence this word is a part of, otherwise return null
-    FoliaElement *p = _parent; 
+    FoliaElement *p = _parent;
     while( p ){
       if ( p->isinstance( Paragraph_t ) )
 	return dynamic_cast<Paragraph*>(p);
@@ -1755,7 +2004,7 @@ namespace folia {
 
   Division *Word::division() const {
     // return the <div> this word is a part of, otherwise return null
-    FoliaElement *p = _parent; 
+    FoliaElement *p = _parent;
     while( p ){
       if ( p->isinstance( Division_t ) )
 	return dynamic_cast<Division*>(p);
@@ -1766,9 +2015,9 @@ namespace folia {
 
   vector<Morpheme *> Word::morphemes( const string& set ) const {
     vector<Morpheme *> result;
-    vector<MorphologyLayer*> mv = select<MorphologyLayer>();
+    vector<MorphologyLayer*> mv = FoliaElement::select<MorphologyLayer>();
     for( size_t i=0; i < mv.size(); ++i ){
-      vector<Morpheme*> tmp = mv[i]->select<Morpheme>( set );
+      vector<Morpheme*> tmp = mv[i]->FoliaElement::select<Morpheme>( set );
       result.insert( result.end(), tmp.begin(), tmp.end() );
     }
     return result;
@@ -1776,7 +2025,7 @@ namespace folia {
 
   Morpheme * Word::morpheme( size_t pos, const string& set ) const {
     vector<Morpheme *> tmp = morphemes( set );
-    if ( pos >=0 && pos < tmp.size() )
+    if ( pos < tmp.size() )
       return tmp[pos];
     else
       throw range_error( "morpheme() index out of range" );
@@ -1784,7 +2033,7 @@ namespace folia {
 
   Correction *Word::incorrection( ) const {
     // Is the Word part of a correction? If it is, it returns the Correction element, otherwise it returns 0;
-    FoliaElement *p = _parent; 
+    FoliaElement *p = _parent;
     while( p ){
       if ( p->isinstance( Correction_t ) )
 	return dynamic_cast<Correction*>(p);
@@ -1802,14 +2051,14 @@ namespace folia {
       if ( words[i] == this ){
 	if ( i > 0 )
 	  return words[i-1];
-	else 
+	else
 	  return 0;
-	break;	
+	break;
       }
     }
     return 0;
   }
-  
+
   Word *Word::next() const{
     Sentence *s = sentence();
     vector<Word*> words = s->words();
@@ -1817,15 +2066,15 @@ namespace folia {
       if ( words[i] == this ){
 	if ( i+1 < words.size() )
 	  return words[i+1];
-	else 
+	else
 	  return 0;
-	break;	
+	break;
       }
     }
     return 0;
   }
 
-  vector<Word*> Word::context( size_t size, 
+  vector<Word*> Word::context( size_t size,
 			       const string& val ) const {
     vector<Word*> result;
     if ( size > 0 ){
@@ -1867,7 +2116,7 @@ namespace folia {
   }
 
 
-  vector<Word*> Word::leftcontext( size_t size, 
+  vector<Word*> Word::leftcontext( size_t size,
 				   const string& val ) const {
     //  cerr << "leftcontext : " << size << endl;
     vector<Word*> result;
@@ -1898,7 +2147,7 @@ namespace folia {
     return result;
   }
 
-  vector<Word*> Word::rightcontext( size_t size, 
+  vector<Word*> Word::rightcontext( size_t size,
 				    const string& val ) const {
     vector<Word*> result;
     //  cerr << "rightcontext : " << size << endl;
@@ -1930,22 +2179,53 @@ namespace folia {
     return result;
   }
 
-  const Word* Word::resolveword( const string& id ) const{
+  const Word* Word::resolveword( const string& id ) const {
     if ( _id == id )
       return this;
     return 0;
   }
 
+  vector<FoliaElement*> Word::findspans( ElementType et,
+					 const string& st ) const {
+    vector<FoliaElement *> result;
+    if ( !folia::isSubClass( et , AnnotationLayer_t ) ){
+      throw NotImplementedError( "findspans(" + toString( et ) +
+				 ") is not supported. " +
+				 " (Not an AnnotationLayer type)" );
+    }
+    else {
+      const FoliaElement *e = parent();
+      if ( e ){
+	vector<FoliaElement*> v = e->select( et, st, false );
+	for ( size_t i=0; i < v.size(); ++i ){
+	  for ( size_t k=0; k < v[i]->size(); ++k ){
+	    FoliaElement *f = v[i]->index(k);
+	    AbstractSpanAnnotation *as = dynamic_cast<AbstractSpanAnnotation*>(f);
+	    if ( as ){
+	      vector<FoliaElement*> wv = f->wrefs();
+	      for ( size_t j=0; j < wv.size(); ++j ){
+		if ( wv[j] == this ){
+		  result.push_back(f);
+		}
+	      }
+	    }
+	  }
+	}
+      }
+    }
+    return result;
+  }
+
   FoliaElement* WordReference::parseXml( const xmlNode *node ){
     KWargs att = getAttributes( node );
     string id = att["id"];
     if ( id.empty() )
       throw XmlError( "empty id in WordReference" );
-    if ( mydoc->debug ) 
+    if ( mydoc->debug )
       cerr << "Found word reference" << id << endl;
     FoliaElement *res = (*mydoc)[id];
     if ( res ){
-      // To DO: check juiste type. Woord, morpheme, dat mag, maar andere?
+      // To DO: check type. Word_t and Morpheme_t
       res->increfcount();
     }
     else {
@@ -1963,7 +2243,7 @@ namespace folia {
     if ( val.empty() )
       throw XmlError( "ID required for AlignReference" );
     refId = val;
-    if ( mydoc->debug ) 
+    if ( mydoc->debug )
       cerr << "Found AlignReference ID " << refId << endl;
     val = att["type"];
     if ( val.empty() )
@@ -1972,7 +2252,8 @@ namespace folia {
       stringTo<ElementType>( val );
     }
     catch (...){
-      throw XmlError( "type must be an Element Type" );
+      throw XmlError( "AlignReference:type must be an Element Type ("
+		      + val + ")" );
     }
     _type = val;
     val = att["t"];
@@ -1984,13 +2265,13 @@ namespace folia {
 
   FoliaElement *AlignReference::resolve( const Alignment *ref ) const {
     if ( ref->href().empty() )
-      return (*mydoc)[refId]; 
+      return (*mydoc)[refId];
     else
-      throw NotImplementedError( "resolve for external doc" );
+      throw NotImplementedError( "AlignReference::resolve() for external doc" );
   }
 
   vector<FoliaElement *> Alignment::resolve() const {
-    vector<AlignReference*> v = select<AlignReference>();
+    vector<AlignReference*> v = FoliaElement::select<AlignReference>();
     vector<FoliaElement*> result;
     for ( size_t i=0; i < v.size(); ++i ){
       result.push_back( v[i]->resolve( this ) );
@@ -2009,30 +2290,8 @@ namespace folia {
     Word::setAttributes( args );
   }
 
-  KWargs TextContent::collectAttributes() const {
-    KWargs attribs = FoliaElement::collectAttributes();
-    if ( _class == "current" )
-      attribs.erase( "class" );
-    else if ( _class == "original" && parent()->isinstance( Original_t ) )
-      attribs.erase( "class" );    
-      
-    if ( _offset >= 0 ){
-      attribs["offset"] = TiCC::toString( _offset );
-    }
-    if ( !_lang.empty() ){
-      attribs["lang"] = _lang;
-    }
-    return attribs;
-  }
-
-  xmlNode *TextContent::xml( bool, bool ) const {
-    xmlNode *e = FoliaElement::xml( false, false );
-    xmlAddChild( e, xmlNewText( (const xmlChar*)str().c_str()) );
-    return e;
-  }
-
   KWargs Figure::collectAttributes() const {
-    KWargs atts = FoliaElement::collectAttributes();
+    KWargs atts = FoliaImpl::collectAttributes();
     if ( !_src.empty() ){
       atts["src"] = _src;
     }
@@ -2047,7 +2306,7 @@ namespace folia {
       _src = it->second;
       kwargs.erase( "src" );
     }
-    FoliaElement::setAttributes(kwargs);
+    FoliaImpl::setAttributes(kwargs);
   }
 
   UnicodeString Figure::caption() const {
@@ -2068,7 +2327,7 @@ namespace folia {
   }
 
   xmlNode *Description::xml( bool, bool ) const {
-    xmlNode *e = FoliaElement::xml( false, false );
+    xmlNode *e = FoliaImpl::xml( false, false );
     xmlAddChild( e, xmlNewText( (const xmlChar*)_value.c_str()) );
     return e;
   }
@@ -2084,17 +2343,16 @@ namespace folia {
   }
 
   FoliaElement *AbstractSpanAnnotation::append( FoliaElement *child ){
-    if ( child->isinstance(PlaceHolder_t) ||
-	 ( ( child->isinstance(Word_t) || child->isinstance(Morpheme_t) )
-	   && acceptable( WordReference_t ) ) )
+    FoliaImpl::append( child );
+    if ( child->isinstance(PlaceHolder_t) ){
       child->increfcount();
-    FoliaElement::append( child );
+    }
     return child;
   }
 
   xmlNode *AbstractSpanAnnotation::xml( bool recursive, bool kanon ) const {
-    xmlNode *e = FoliaElement::xml( false, false );
-    // append Word children as WREFS
+    xmlNode *e = FoliaImpl::xml( false, false );
+    // append Word and Morpheme children as WREFS
     vector<FoliaElement*>::const_iterator it=data.begin();
     while ( it != data.end() ){
       if ( (*it)->element_id() == Word_t ||
@@ -2121,15 +2379,15 @@ namespace folia {
   }
 
   FoliaElement *Quote::append( FoliaElement *child ){
+    FoliaImpl::append( child );
     if ( child->isinstance(Sentence_t) )
       child->setAuth( false ); // Sentences under quotes are non-authoritative
-    FoliaElement::append( child );
     return child;
   }
 
 
-  xmlNode *Content::xml( bool, bool ) const {
-    xmlNode *e = FoliaElement::xml( false, false );
+  xmlNode *Content::xml( bool recurse, bool ) const {
+    xmlNode *e = FoliaImpl::xml( recurse, false );
     xmlAddChild( e, xmlNewCDataBlock( 0,
 				      (const xmlChar*)value.c_str() ,
 				      value.length() ) );
@@ -2155,6 +2413,14 @@ namespace folia {
 	isText = true;
 	value += (char*)p->content;
       }
+      else if ( p->type == XML_COMMENT_NODE ){
+	string tag = "xml-comment";
+	FoliaElement *t = createElement( mydoc, tag );
+	if ( t ){
+	  t = t->parseXml( p );
+	  append( t );
+	}
+      }
       p = p->next;
     }
     if ( value.empty() )
@@ -2163,16 +2429,23 @@ namespace folia {
   }
 
   UnicodeString Correction::text( const string& cls, bool retaintok ) const {
+#ifdef DEBUG_TEXT
+    cerr << "TEXT(" << cls << ") op node : " << _xmltag << " id ( " << id() << ")" << endl;
+#endif
     if ( cls == "current" ){
       for( size_t i=0; i < data.size(); ++i ){
-	//    cerr << "data[" << i << "]=" << data[i] << endl;
+#ifdef DEBUG_TEXT
+	cerr << "data[" << i << "]=" << data[i] << endl;
+#endif
 	if ( data[i]->isinstance( New_t ) || data[i]->isinstance( Current_t ) )
 	  return data[i]->text( cls, retaintok );
       }
     }
     else if ( cls == "original" ){
       for( size_t i=0; i < data.size(); ++i ){
-	//    cerr << "data[" << i << "]=" << data[i] << endl;
+#ifdef DEBUG_TEXT
+	cerr << "data[" << i << "]=" << data[i] << endl;
+#endif
 	if ( data[i]->isinstance( Original_t ) )
 	  return data[i]->text( cls, retaintok );
       }
@@ -2180,6 +2453,15 @@ namespace folia {
     throw NoSuchText("wrong cls");
   }
 
+  string Correction::getTextDelimiter( bool retaintok ) const {
+    for( size_t i=0; i < data.size(); ++i ){
+      //    cerr << "data[" << i << "]=" << data[i] << endl;
+      if ( data[i]->isinstance( New_t ) || data[i]->isinstance( Current_t ) )
+	return data[i]->getTextDelimiter( retaintok );
+    }
+    return "";
+  }
+
   TextContent *Correction::textcontent( const string& cls ) const {
     if ( cls == "current" ){
       for( size_t i=0; i < data.size(); ++i ){
@@ -2196,57 +2478,57 @@ namespace folia {
       }
     }
     throw NoSuchText("wrong cls");
-  }    
-  
+  }
+
   bool Correction::hasNew( ) const {
     vector<FoliaElement*> v = select( New_t, false );
     return !v.empty();
   }
 
   NewElement *Correction::getNew() const {
-    vector<NewElement*> v = select<NewElement>( false );
+    vector<NewElement*> v = FoliaElement::select<NewElement>( false );
     if ( v.empty() )
       throw NoSuchAnnotation("new");
     else
       return v[0];
   }
 
-  bool Correction::hasOriginal() const { 
+  bool Correction::hasOriginal() const {
     vector<FoliaElement*> v = select( Original_t, false );
     return !v.empty();
   }
 
-  Original *Correction::getOriginal() const { 
-    vector<Original*> v = select<Original>( false );
+  Original *Correction::getOriginal() const {
+    vector<Original*> v = FoliaElement::select<Original>( false );
     if ( v.empty() )
       throw NoSuchAnnotation("original");
     else
       return v[0];
   }
 
-  bool Correction::hasCurrent( ) const { 
+  bool Correction::hasCurrent( ) const {
     vector<FoliaElement*> v = select( Current_t, false );
     return !v.empty();
   }
 
-  Current *Correction::getCurrent( ) const { 
-    vector<Current*> v = select<Current>( false );
+  Current *Correction::getCurrent( ) const {
+    vector<Current*> v = FoliaElement::select<Current>( false );
     if ( v.empty() )
       throw NoSuchAnnotation("current");
     else
       return v[0];
   }
 
-  bool Correction::hasSuggestions( ) const { 
+  bool Correction::hasSuggestions( ) const {
     vector<Suggestion*> v = suggestions();
     return !v.empty();
   }
-  
+
   vector<Suggestion*> Correction::suggestions( ) const {
-    return select<Suggestion>( false );
+    return FoliaElement::select<Suggestion>( false );
   }
 
-  Suggestion *Correction::suggestions( size_t index ) const { 
+  Suggestion *Correction::suggestions( size_t index ) const {
     vector<Suggestion*> v = suggestions();
     if ( v.empty() || index >= v.size() )
       throw NoSuchAnnotation("suggestion");
@@ -2262,9 +2544,9 @@ namespace folia {
       throw runtime_error( "No head" );
     return 0;
   }
-  
+
   string Gap::content() const {
-    vector<FoliaElement*> cv = select( Content_t );  
+    vector<FoliaElement*> cv = select( Content_t );
     if ( cv.size() < 1 )
       throw NoSuchAnnotation( "content" );
     else {
@@ -2273,16 +2555,16 @@ namespace folia {
   }
 
   Headwords *Dependency::head() const {
-    vector<Headwords*> v = select<Headwords>();
+    vector<Headwords*> v = FoliaElement::select<Headwords>();
     if ( v.size() < 1 )
       throw NoSuchAnnotation( "head" );
     else {
       return v[0];
     }
-  } 
-    
+  }
+
   DependencyDependent *Dependency::dependent() const {
-    vector<DependencyDependent *> v = select<DependencyDependent>();
+    vector<DependencyDependent *> v = FoliaElement::select<DependencyDependent>();
     if ( v.size() < 1 )
       throw NoSuchAnnotation( "dependent" );
     else {
@@ -2294,49 +2576,127 @@ namespace folia {
     _xmltag="FoLiA";
     _element_id = BASE;
     const ElementType accept[] = { Text_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 1 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void DCOI::init(){
     _xmltag="DCOI";
     _element_id = BASE;
     const ElementType accept[] = { Text_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 1 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void AbstractStructureElement::init(){
+    _element_id = Structure_t;
+    _xmltag = "structure";
     _required_attributes = ID;
     _optional_attributes = ALL;
-    occurrences_per_set=0;
+    _occurrences_per_set=0;
     TEXTDELIMITER = "\n\n";
   }
 
   void AbstractTokenAnnotation::init(){
+    _element_id = TokenAnnotation_t;
+    _xmltag="tokenannotation";
     _required_attributes = CLASS;
     _optional_attributes = ALL;
-    occurrences_per_set=1;
+    _occurrences_per_set=1;
   }
 
   void TextContent::init(){
     _element_id = TextContent_t;
     _xmltag="t";
     _optional_attributes = CLASS|ANNOTATOR|CONFIDENCE|DATETIME;
+    const ElementType accept[] = { AbstractTextMarkup_t,
+				   XmlText_t, LineBreak_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::TEXT;
-    occurrences = 0;
-    occurrences_per_set=0;
+    _occurrences = 0;
+    _occurrences_per_set=0;
     _offset = -1;
   }
 
   void Head::init() {
     _element_id = Head_t;
     _xmltag="head";
-    const ElementType accept[] = { Sentence_t, Description_t, Event_t, 
-				   TextContent_t, Alignment_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 5 );
-    occurrences=1;
+    const ElementType accept[] = { Structure_t, Description_t, LineBreak_t,
+				   TextContent_t, Alignment_t, Metric_t,
+				   Alternatives_t, TokenAnnotation_t, Gap_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _occurrences=1;
     TEXTDELIMITER = " ";
   }
 
+  void TableHead::init() {
+    _element_id = TableHead_t;
+    _xmltag="tablehead";
+    _required_attributes = NO_ATT;
+    const ElementType accept[] = { Row_t,
+				   Correction_t,
+				   Alternatives_t,
+				   AnnotationLayer_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _annotation_type = AnnotationType::TABLE;
+  }
+
+  void Table::init() {
+    _element_id = Table_t;
+    _xmltag="table";
+    const ElementType accept[] = { TableHead_t,
+				   Row_t,
+				   Correction_t,
+				   Alternatives_t,
+				   AnnotationLayer_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _annotation_type = AnnotationType::TABLE;
+  }
+
+  void Cell::init() {
+    _element_id = Cell_t;
+    _xmltag="cell";
+    _required_attributes = NO_ATT;
+    const ElementType accept[] = { Structure_t,
+				   TokenAnnotation_t,
+				   Entities_t,
+				   Alignment_t,
+				   Metric_t,
+				   Alternatives_t,
+				   AnnotationLayer_t,
+				   Gap_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _annotation_type = AnnotationType::TABLE;
+    TEXTDELIMITER = " | ";
+  }
+
+  void Row::init() {
+    _element_id = Row_t;
+    _xmltag="row";
+    _required_attributes = NO_ATT;
+    const ElementType accept[] = { Cell_t,
+				   Correction_t,
+				   Alternatives_t,
+				   AnnotationLayer_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _annotation_type = AnnotationType::TABLE;
+    TEXTDELIMITER = "\n";
+  }
+
   void LineBreak::init(){
     _xmltag = "br";
     _element_id = LineBreak_t;
@@ -2354,12 +2714,13 @@ namespace folia {
   void Word::init(){
     _xmltag="w";
     _element_id = Word_t;
-    const ElementType accept[] = { TextContent_t, Pos_t, Lemma_t,
-				   Sense_t, Alternative_t, 
-				   Correction_t, ErrorDetection_t, 
-				   Description_t, Morphology_t,
+    const ElementType accept[] = { TextContent_t, TokenAnnotation_t,
+				   Alternative_t, Reference_t,
+				   Description_t,
 				   Alignment_t, Metric_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 11 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::TOKEN;
     TEXTDELIMITER = " ";
     space = true;
@@ -2370,12 +2731,14 @@ namespace folia {
     _element_id = Str_t;
     _required_attributes = NO_ATT;
     _optional_attributes = ID|CLASS;
-    const ElementType accept[] = { TextContent_t, Correction_t,
+    const ElementType accept[] = { TextContent_t, Correction_t, Lang_t,
 				   Description_t, Alignment_t, Metric_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::STRING;
-    occurrences = 0;
-    occurrences_per_set=0;
+    _occurrences = 0;
+    _occurrences_per_set=0;
   }
 
   void PlaceHolder::init(){
@@ -2396,8 +2759,10 @@ namespace folia {
     _xmltag = "alignment";
     _element_id = Alignment_t;
     const ElementType accept[] = { AlignReference_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
-    occurrences_per_set=0;
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _occurrences_per_set=0;
     _annotation_type = AnnotationType::ALIGNMENT;
     PRINTABLE = false;
   }
@@ -2413,7 +2778,9 @@ namespace folia {
     _element_id = Gap_t;
     _annotation_type = AnnotationType::GAP;
     const ElementType accept[] = { Content_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _optional_attributes = CLASS|ID|ANNOTATOR|CONFIDENCE|N|DATETIME;
   }
 
@@ -2421,7 +2788,9 @@ namespace folia {
     _element_id = Metric_t;
     _xmltag = "metric";
     const ElementType accept[] = { ValueFeature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _optional_attributes = CLASS|ANNOTATOR|CONFIDENCE;
     _annotation_type = AnnotationType::METRIC;
   }
@@ -2434,16 +2803,17 @@ namespace folia {
   void Sentence::init(){
     _xmltag="s";
     _element_id = Sentence_t;
-    const ElementType accept[] = { LineBreak_t, WhiteSpace_t, Word_t, 
-				   Str_t,
-				   TextContent_t, AnnotationLayer_t, 
-				   SyntaxLayer_t, Chunking_t, Dependencies_t,
-				   Entities_t, Semroles_t,
-				   Quote_t, Event_t, TimingLayer_t,
+    const ElementType accept[] = { Structure_t,
+				   TokenAnnotation_t,
+				   TextContent_t, AnnotationLayer_t,
 				   Correction_t,
-				   Description_t, Alignment_t, Metric_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 18 );
+				   Description_t, Alignment_t, Metric_t,
+				   Gap_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::SENTENCE;
+    TEXTDELIMITER = " ";
   }
 
   void Division::init(){
@@ -2451,12 +2821,14 @@ namespace folia {
     _element_id = Division_t;
     _required_attributes = ID;
     _optional_attributes = CLASS|N;
-    const ElementType accept[] = { Division_t, Gap_t, Head_t, Paragraph_t,
-				   Sentence_t, List_t, Figure_t, Event_t,
-				   Description_t, LineBreak_t, Str_t,
+    const ElementType accept[] = { Structure_t, Gap_t,
+				   TokenAnnotation_t,
+				   Description_t,
 				   TextContent_t,
-				   WhiteSpace_t, Metric_t, Coreferences_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 15 );
+				   Metric_t, Coreferences_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::DIVISION;
     TEXTDELIMITER = "\n\n\n";
   }
@@ -2464,11 +2836,13 @@ namespace folia {
   void Text::init(){
     _xmltag="text";
     _element_id = Text_t;
-    const ElementType accept[] = { Gap_t, Division_t, Paragraph_t, Sentence_t, 
+    const ElementType accept[] = { Gap_t, Division_t, Paragraph_t, Sentence_t,
 				   List_t, Figure_t, Description_t, Event_t,
-				   Str_t,
-				   TextContent_t, Metric_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 11 );
+				   TokenAnnotation_t,
+				   TextContent_t, Metric_t, External_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _required_attributes = ID;
     TEXTDELIMITER = "\n\n";
   }
@@ -2476,59 +2850,75 @@ namespace folia {
   void Event::init(){
     _xmltag="event";
     _element_id = Event_t;
-    const ElementType accept[] = { Gap_t, Division_t, Paragraph_t, Sentence_t, 
-				   List_t, Figure_t, Description_t, Str_t,
-				   ActorFeature_t, TextContent_t, Feature_t,
-				   BeginDateTimeFeature_t, EndDateTimeFeature_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 13 );
+    const ElementType accept[] = { Gap_t, Division_t, Structure_t,
+				   Description_t,
+				   Feature_t, TextContent_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::EVENT;
-    occurrences_per_set=0;
+    _occurrences_per_set=0;
   }
 
   void TimeSegment::init(){
     _xmltag="timesegment";
     _element_id = TimeSegment_t;
-    const ElementType accept[] = { Description_t, Feature_t, ActorFeature_t,
-				   Word_t,
-				   BeginDateTimeFeature_t, EndDateTimeFeature_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 6 );
+    const ElementType accept[] = { Description_t, Feature_t, Word_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::TIMEDEVENT;
-    occurrences_per_set=0;
+    _occurrences_per_set=0;
   }
 
   void Caption::init(){
     _xmltag="caption";
     _element_id = Caption_t;
-    const ElementType accept[] = { Sentence_t, Description_t, 
-				   Str_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 4 );
-    occurrences = 1;
+    const ElementType accept[] = { Sentence_t, Reference_t, Description_t,
+				   TokenAnnotation_t, TextContent_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _occurrences = 1;
   }
 
   void Label::init(){
     _xmltag="label";
     _element_id = Label_t;
     const ElementType accept[] = { Word_t, Description_t, TextContent_t,
-				   Str_t, Alignment_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 5 );
-  }
-
-  void ListItem::init(){
-    _xmltag="listitem";
-    _element_id = ListItem_t;
-    const ElementType accept[] = { List_t, Sentence_t, Description_t, Label_t,
-				   Event_t, Str_t, TextContent_t, Alignment_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 8 );
+				   TokenAnnotation_t, Alignment_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+  }
+
+  void Item::init(){
+    _xmltag="item";
+    _element_id = Item_t;
+    const ElementType accept[] = { Structure_t, Description_t,
+				   TokenAnnotation_t,
+				   TextContent_t, Str_t, Alignment_t,
+				   Gap_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::LIST;
   }
 
   void List::init(){
     _xmltag="list";
     _element_id = List_t;
-    const ElementType accept[] = { ListItem_t, Description_t, 
-				   Caption_t, Event_t, Str_t,
-				   TextContent_t, Alignment_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 7 );
+    const ElementType accept[] = { Item_t, Description_t,
+				   Caption_t, Event_t, Lang_t,
+				   Alignment_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+
     _annotation_type = AnnotationType::LIST;
     TEXTDELIMITER="\n";
   }
@@ -2536,20 +2926,27 @@ namespace folia {
   void Figure::init(){
     _xmltag="figure";
     _element_id = Figure_t;
-    const ElementType accept[] = { Sentence_t, Description_t, 
-				   Caption_t, Str_t, TextContent_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+    const ElementType accept[] = { Sentence_t, Description_t,
+				   Caption_t, Str_t, Lang_t,
+				   TextContent_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::FIGURE;
   }
 
   void Paragraph::init(){
     _xmltag="p";
     _element_id = Paragraph_t;
-    const ElementType accept[] = { Sentence_t, Correction_t, TextContent_t, 
-				   Str_t,
-				   Description_t, LineBreak_t, WhiteSpace_t, 
-				   List_t, Figure_t, Alignment_t, Metric_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 11 );
+    const ElementType accept[] = { Structure_t, TextContent_t,
+				   TokenAnnotation_t,
+				   Description_t,
+				   Alignment_t, Metric_t,
+				   Gap_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::PARAGRAPH;
   }
 
@@ -2560,7 +2957,9 @@ namespace folia {
     _annotation_type = AnnotationType::SYNTAX;
     const ElementType accept[] = { SyntacticUnit_t, Word_t, WordReference_t,
 				   Description_t, Feature_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void SemanticRole::init(){
@@ -2568,9 +2967,11 @@ namespace folia {
     _element_id = Semrole_t;
     _required_attributes = CLASS;
     _annotation_type = AnnotationType::SEMROLE;
-    const ElementType accept[] = { Word_t, WordReference_t, Headwords_t,
+    const ElementType accept[] = { Word_t, WordReference_t, Lang_t, Headwords_t,
 				   Alignment_t, Description_t, Metric_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 6 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void Chunk::init(){
@@ -2578,9 +2979,11 @@ namespace folia {
     _xmltag = "chunk";
     _element_id = Chunk_t;
     _annotation_type = AnnotationType::CHUNKING;
-    const ElementType accept[] = { Word_t, WordReference_t, 
+    const ElementType accept[] = { Word_t, WordReference_t, Lang_t,
 				   Description_t, Feature_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 4 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void Entity::init(){
@@ -2589,9 +2992,11 @@ namespace folia {
     _xmltag = "entity";
     _element_id = Entity_t;
     _annotation_type = AnnotationType::ENTITY;
-    const ElementType accept[] = { Word_t, WordReference_t, Morpheme_t,
+    const ElementType accept[] = { Word_t, Lang_t, WordReference_t, Morpheme_t,
 				   Description_t, Feature_t, Metric_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 6 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );;
   }
 
   void AbstractAnnotationLayer::init(){
@@ -2601,13 +3006,77 @@ namespace folia {
     PRINTABLE=false;
   }
 
+  static ElementType ASlist[] = { SyntacticUnit_t, Chunk_t,
+				  Entity_t, Headwords_t,
+				  DependencyDependent_t,
+				  CoreferenceLink_t,
+				  CoreferenceChain_t, Semrole_t,
+				  Semroles_t, TimeSegment_t };
+  static set<ElementType> asSet( ASlist,
+				 ASlist + sizeof( ASlist )/ sizeof( ElementType ) );
+
+  vector<AbstractSpanAnnotation*> FoliaImpl::selectSpan() const {
+    vector<AbstractSpanAnnotation*> res;
+    set<ElementType>::const_iterator it = asSet.begin();
+    while( it != asSet.end() ){
+      vector<FoliaElement*> tmp = select( *it, true );
+      for ( size_t i = 0; i < tmp.size(); ++i ){
+	res.push_back( dynamic_cast<AbstractSpanAnnotation*>( tmp[i]) );
+      }
+      ++it;
+    }
+    return res;
+  }
+
+  vector<FoliaElement*> AbstractSpanAnnotation::wrefs() const {
+    vector<FoliaElement*> res;
+    for ( size_t i=0; i < size(); ++ i ){
+      ElementType et = data[i]->element_id();
+      if ( et == Word_t
+	   || et == WordReference_t
+	   //	   || et == Phoneme_t
+	   || et == Morphology_t ){
+	res.push_back( data[i] );
+      }
+      else {
+	AbstractSpanAnnotation *as = dynamic_cast<AbstractSpanAnnotation*>(data[i]);
+	if ( as != 0 ){
+	  vector<FoliaElement*> sub = as->wrefs();
+	  for( size_t j=0; j < sub.size(); ++j ){
+	    res.push_back( sub[j] );
+	  }
+	}
+      }
+    }
+    return res;
+  }
+
+  FoliaElement *AbstractAnnotationLayer::findspan( const vector<FoliaElement*>& words ) const {
+    vector<AbstractSpanAnnotation*> av = selectSpan();
+    for ( size_t i=0; i < av.size(); ++i ){
+      vector<FoliaElement*> v = av[i]->wrefs();
+      if ( v.size() == words.size() ){
+	bool ok = true;
+	for ( size_t n = 0; n < v.size() && ok ; ++n ){
+	  if ( v[n] != words[n] )
+	    ok = false;
+	}
+	if ( ok )
+	  return av[i];
+      }
+    }
+    return 0;
+  }
+
   void Alternative::init(){
     _xmltag = "alt";
     _element_id = Alternative_t;
     _required_attributes = NO_ATT;
     _optional_attributes = ALL;
-    const ElementType accept[] = { Pos_t, Lemma_t, Morphology_t, Correction_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 4 );
+    const ElementType accept[] = { TokenAnnotation_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::ALTERNATIVE;
     PRINTABLE = false;
     AUTH = false;
@@ -2618,24 +3087,25 @@ namespace folia {
     _element_id = Alternatives_t;
     _optional_attributes = ALL;
     const ElementType accept[] = { AnnotationLayer_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 1 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     PRINTABLE = false;
     AUTH = false;
   }
 
   void AbstractCorrectionChild::init(){
     _optional_attributes = NO_ATT;
-    const ElementType accept[] = { Pos_t, Lemma_t,
-				   Phon_t, Domain_t,
-				   Sense_t, Subjectivity_t,
-				   Correction_t, ErrorDetection_t,
+    const ElementType accept[] = { TokenAnnotation_t, SpanAnnotation_t,
 				   Word_t, WordReference_t, Str_t,
 				   TextContent_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 13 );
-    occurrences = 1;
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _occurrences = 1;
     PRINTABLE=true;
   }
-  
+
   void NewElement::init(){
     _xmltag = "new";
     _element_id = New_t;
@@ -2656,9 +3126,9 @@ namespace folia {
     _xmltag = "suggestion";
     _element_id = Suggestion_t;
     _optional_attributes = ANNOTATOR|CONFIDENCE|DATETIME|N;
-    _annotation_type = AnnotationType::SUGGESTION;    
-    occurrences=0;
-    occurrences_per_set=0;
+    _annotation_type = AnnotationType::SUGGESTION;
+    _occurrences=0;
+    _occurrences_per_set=0;
     AUTH = false;
   }
 
@@ -2669,14 +3139,186 @@ namespace folia {
     _annotation_type = AnnotationType::CORRECTION;
     const ElementType accept[] = { New_t, Original_t, Suggestion_t, Current_t,
 				   Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 5 );
-    occurrences_per_set=0;
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _occurrences_per_set=0;
   }
 
   void Description::init(){
     _xmltag = "desc";
     _element_id = Description_t;
-    occurrences = 1;
+    _occurrences = 1;
+  }
+
+  UnicodeString XmlText::text( const string&, bool ) const {
+    return UTF8ToUnicode(_value);
+  }
+
+  xmlNode *XmlText::xml( bool, bool ) const {
+    return xmlNewText( (const xmlChar*)_value.c_str() );
+  }
+
+  FoliaElement* XmlText::parseXml( const xmlNode *node ){
+    if ( node->content ){
+      _value = (const char*)node->content;
+    }
+    if ( _value.empty() ){
+      throw ValueError( "TextContent may not be empty" );
+    }
+    return this;
+  }
+
+  void XmlText::init(){
+    _xmltag = "xml-text";
+    _element_id = XmlText_t;
+    TEXTDELIMITER = "*";
+  }
+
+  void External::init(){
+    _xmltag = "external";
+    _element_id = External_t;
+    _include = false;
+  }
+
+  void External::resolve( ) {
+    try {
+      cerr << "try to resolve: " << _src << endl;
+      Document doc( "file='"+_src +"'" );
+      xmlDoc *xmldoc = doc.XmlDoc();
+      xmlNode *root = xmlDocGetRootElement( xmldoc );
+      xmlNode *p = root->children;
+      while ( p ){
+	if ( p->type == XML_ELEMENT_NODE ){
+	  string tag = Name( p );
+	  if ( tag == "text" ){
+	    FoliaElement *parent = _parent;
+	    KWargs args = parent->collectAttributes();
+	    args["_id"] = "Arglebargleglop-glyf";
+	    Text *tmp = new Text( mydoc, args );
+	    tmp->FoliaImpl::parseXml( p );
+	    FoliaElement *old = parent->replace( this, tmp->index(0) );
+	    mydoc->delDocIndex( tmp, "Arglebargleglop-glyf" );
+	    tmp->remove( (size_t)0, false );
+	    delete tmp;
+	    delete old;
+	  }
+	  p = p->next;
+	}
+      }
+    }
+    catch ( const exception& e ){
+      throw XmlError( "resolving external " + _src + " failed: "
+		      + e.what() );
+    }
+  }
+
+  FoliaElement* External::parseXml( const xmlNode *node ){
+    KWargs att = getAttributes( node );
+    KWargs::const_iterator it = att.find("src" );
+    if ( it == att.end() ){
+      throw ValueError( "External: 'src' may not be empty" );
+    }
+    setAttributes( att );
+    if ( _include ){
+      mydoc->addExternal( this );
+    }
+    return this;
+  }
+
+  KWargs External::collectAttributes() const {
+    KWargs atts = FoliaImpl::collectAttributes();
+    if ( !_src.empty() ){
+      atts["src"] = _src;
+    }
+    if ( _include ){
+      atts["include"] = "yes";
+    }
+    return atts;
+  }
+
+  void External::setAttributes( const KWargs& kwargsin ){
+    KWargs kwargs = kwargsin;
+    KWargs::const_iterator it;
+    it = kwargs.find( "src" );
+    if ( it != kwargs.end() ) {
+      _src = it->second;
+      kwargs.erase( "src" );
+    }
+    it = kwargs.find( "include" );
+    if ( it != kwargs.end() ) {
+      _include = stringTo<bool>( it->second );
+      kwargs.erase( "include" );
+    }
+    FoliaImpl::setAttributes(kwargs);
+  }
+
+  void Note::init(){
+    _required_attributes = ID;
+    _xmltag = "note";
+    _element_id = Note_t;
+    const ElementType accept[] = { Structure_t, TextContent_t, Feature_t, Alignment_t, TokenAnnotation_t, Description_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+  }
+
+  KWargs Note::collectAttributes() const {
+    KWargs attribs = FoliaImpl::collectAttributes();
+    return attribs;
+  }
+
+  void Note::setAttributes( const KWargs& args ){
+    KWargs::const_iterator it = args.find( "_id" );
+    if ( it != args.end() ){
+      refId = it->second;
+    }
+    FoliaImpl::setAttributes( args );
+  }
+
+  void Reference::init(){
+    _xmltag = "ref";
+    _element_id = Reference_t;
+    _required_attributes = NO_ATT;
+  }
+
+  KWargs Reference::collectAttributes() const {
+    KWargs atts;
+    atts["id"] = refId;
+    atts["type"] = _type;
+    return atts;
+  }
+
+  void Reference::setAttributes( const KWargs& args ){
+    KWargs::const_iterator it = args.find( "id" );
+    if ( it != args.end() ){
+      refId = it->second;
+    }
+    it = args.find( "type" );
+    if ( it != args.end() ){
+      try {
+	stringTo<ElementType>( it->second );
+      }
+      catch (...){
+	throw XmlError( "attribute 'type' must be an Element Type" );
+      }
+      _type = it->second;
+    }
+  }
+
+  xmlNode *XmlComment::xml( bool, bool ) const {
+    return xmlNewComment( (const xmlChar*)_value.c_str() );
+  }
+
+  FoliaElement* XmlComment::parseXml( const xmlNode *node ){
+    if ( node->content )
+      _value = (const char*)node->content;
+    return this;
+  }
+
+  void XmlComment::init(){
+    _xmltag = "xml-comment";
+    _element_id = XmlComment_t;
   }
 
   void Feature::setAttributes( const KWargs& kwargs ){
@@ -2702,102 +3344,179 @@ namespace folia {
   }
 
   KWargs Feature::collectAttributes() const {
-    KWargs attribs = FoliaElement::collectAttributes();
+    KWargs attribs = FoliaImpl::collectAttributes();
     attribs["subset"] = _subset;
     return attribs;
   }
 
-  vector<string> FoliaElement::feats( const std::string& s ) const {
+  vector<string> FoliaImpl::feats( const std::string& s ) const {
     //    return all classes of the given subset
     vector<string> result;
     for ( size_t i=0; i < data.size(); ++i ){
-      if ( ( data[i]->isinstance( Feature_t ) ||
-	     data[i]->isinstance( SynsetFeature_t ) ||
-	     data[i]->isinstance( BeginDateTimeFeature_t ) ||
-	     data[i]->isinstance( EndDateTimeFeature_t ) ||
-	     data[i]->isinstance( HeadFeature_t ) ||
-	     data[i]->isinstance( ValueFeature_t ) ||
-	     data[i]->isinstance( ActorFeature_t ) ) &&
-	   data[i]->subset() == s )
+      if ( data[i]->isSubClass( Feature_t ) &&
+	   data[i]->subset() == s ) {
 	result.push_back( data[i]->cls() );
+      }
     }
     return result;
   }
-  
-  string FoliaElement::feat( const std::string& s ) const {
+
+  string FoliaImpl::feat( const std::string& s ) const {
     //    return the fist class of the given subset
     for ( size_t i=0; i < data.size(); ++i ){
-      if ( ( data[i]->isinstance( Feature_t ) ||
-	     data[i]->isinstance( SynsetFeature_t ) ||
-	     data[i]->isinstance( BeginDateTimeFeature_t ) ||
-	     data[i]->isinstance( EndDateTimeFeature_t ) ||
-	     data[i]->isinstance( HeadFeature_t ) ||
-	     data[i]->isinstance( ValueFeature_t ) ||
-	     data[i]->isinstance( ActorFeature_t ) ) &&
-	   data[i]->subset() == s )
+      if ( data[i]->isSubClass( Feature_t ) &&
+	   data[i]->subset() == s ) {
 	return data[i]->cls();
+      }
     }
     return "";
   }
-  
+
+  KWargs AbstractTextMarkup::collectAttributes() const {
+    KWargs attribs = FoliaImpl::collectAttributes();
+    if ( !idref.empty() )
+      attribs["id"] = idref;
+    return attribs;
+  }
+
+  void AbstractTextMarkup::setAttributes( const KWargs& atts ){
+    KWargs args = atts;
+    KWargs::iterator it = args.find( "id" );
+    if ( it != args.end() ){
+      KWargs::const_iterator it2 = args.find( "_id" );
+      if ( it2 != args.end() ){
+	throw ValueError("Both 'id' and 'xml:id found for " + classname() );
+      }
+      idref = it->second;
+      args.erase( it );
+    }
+    FoliaImpl::setAttributes( args );
+  }
+
+  KWargs TextMarkupCorrection::collectAttributes() const {
+    KWargs attribs = AbstractTextMarkup::collectAttributes();
+    if ( !_original.empty() )
+      attribs["original"] = _original;
+    return attribs;
+  }
+
+  void TextMarkupCorrection::setAttributes( const KWargs& args ){
+    KWargs argl = args;
+    KWargs::const_iterator it = argl.find( "id" );
+    if ( it != argl.end() ){
+      idref = it->second;
+      argl.erase( "id" );
+    }
+    it = argl.find( "original" );
+    if ( it != argl.end() ){
+      _original = it->second;
+      argl.erase( "original" );
+    }
+    FoliaImpl::setAttributes( argl );
+  }
+
+  UnicodeString AbstractTextMarkup::text( const std::string& cls,
+					  bool ) const {
+    // we assume al TextMarkup te be tokenized already
+    return FoliaImpl::text( cls, true );
+  }
+
+  UnicodeString TextMarkupCorrection::text( const std::string& cls,
+					    bool ret ) const{
+    if ( cls == "original" )
+      return UTF8ToUnicode(_original);
+    else
+      return FoliaImpl::text( cls, ret );
+  }
+
+  const FoliaElement* AbstractTextMarkup::resolveid() const {
+    if ( idref.empty() || !mydoc )
+      return this;
+    else
+      return mydoc->index(idref);
+  }
+
   void Morpheme::init(){
     _element_id = Morpheme_t;
     _xmltag = "morpheme";
     _required_attributes = NO_ATT;
     _optional_attributes = ALL;
     const ElementType accept[] = { Feature_t, FunctionFeature_t, TextContent_t,
-				   Str_t, Metric_t, Alignment_t, 
-				   Pos_t, Lemma_t, Sense_t, Subjectivity_t,
-				   Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 11 );
+				   Metric_t, Alignment_t, TokenAnnotation_t,
+				   Description_t, Morpheme_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::MORPHOLOGICAL;
   }
 
   void SyntaxLayer::init(){
     _element_id = SyntaxLayer_t;
     _xmltag = "syntax";
-    const ElementType accept[] = { SyntacticUnit_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    const ElementType accept[] = { SyntacticUnit_t,
+				   Description_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::SYNTAX;
   }
 
   void ChunkingLayer::init(){
     _element_id = Chunking_t;
     _xmltag = "chunking";
-    const ElementType accept[] = { Chunk_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    const ElementType accept[] = { Chunk_t,
+				   Description_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::CHUNKING;
   }
 
   void EntitiesLayer::init(){
     _element_id = Entities_t;
     _xmltag = "entities";
-    const ElementType accept[] = { Entity_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
-    _annotation_type = AnnotationType::ENTITY;
+    const ElementType accept[] = { Entity_t,
+				   Description_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+   _annotation_type = AnnotationType::ENTITY;
   }
 
   void TimingLayer::init(){
     _element_id = TimingLayer_t;
     _xmltag = "timing";
-    const ElementType accept[] = { TimeSegment_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    const ElementType accept[] = { TimeSegment_t,
+				   Description_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void MorphologyLayer::init(){
     _element_id = Morphology_t;
     _xmltag = "morphology";
-    const ElementType accept[] = { Morpheme_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 1 );
-    occurrences_per_set = 1; // Don't allow duplicates within the same set    
+    const ElementType accept[] = { Morpheme_t, Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _occurrences_per_set = 1; // Don't allow duplicates within the same set
     _annotation_type = AnnotationType::MORPHOLOGICAL;
   }
 
   void CoreferenceLayer::init(){
     _element_id = Coreferences_t;
     _xmltag = "coreferences";
-    const ElementType accept[] = { CoreferenceChain_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    const ElementType accept[] = { CoreferenceChain_t,
+				   Description_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::COREFERENCE;
   }
 
@@ -2806,12 +3525,14 @@ namespace folia {
     _xmltag = "coreferencelink";
     _required_attributes = NO_ATT;
     _optional_attributes = ANNOTATOR|N|DATETIME;
-    const ElementType accept[] = { Word_t, WordReference_t, Headwords_t, 
-				   Description_t,
+    const ElementType accept[] = { Word_t, WordReference_t, Headwords_t,
+				   Description_t, Lang_t,
 				   Alignment_t, TimeFeature_t, LevelFeature_t,
 				   ModalityFeature_t, Metric_t};
-    _accepted_data = std::set<ElementType>(accept, accept + 9 );
-    _annotation_type = AnnotationType::COREFERENCE;    
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _annotation_type = AnnotationType::COREFERENCE;
   }
 
   void CoreferenceChain::init(){
@@ -2820,23 +3541,33 @@ namespace folia {
     _required_attributes = NO_ATT;
     const ElementType accept[] = { CoreferenceLink_t, Description_t,
 				   Metric_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 3 );
-    _annotation_type = AnnotationType::COREFERENCE;    
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    _annotation_type = AnnotationType::COREFERENCE;
   }
 
   void SemanticRolesLayer::init(){
     _element_id = Semroles_t;
     _xmltag = "semroles";
-    const ElementType accept[] = { Semrole_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    const ElementType accept[] = { Semrole_t,
+				   Description_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::SEMROLE;
   }
 
   void DependenciesLayer::init(){
     _element_id = Dependencies_t;
     _xmltag = "dependencies";
-    const ElementType accept[] = { Dependency_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    const ElementType accept[] = { Dependency_t,
+				   Description_t,
+				   Correction_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     _annotation_type = AnnotationType::DEPENDENCY;
   }
 
@@ -2845,9 +3576,11 @@ namespace folia {
     _xmltag = "dependency";
     _required_attributes = NO_ATT;
     _annotation_type = AnnotationType::DEPENDENCY;
-    const ElementType accept[] = { DependencyDependent_t, Headwords_t, 
+    const ElementType accept[] = { DependencyDependent_t, Headwords_t,
 				   Feature_t, Description_t, Alignment_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 5 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void DependencyDependent::init(){
@@ -2858,7 +3591,9 @@ namespace folia {
     _annotation_type = AnnotationType::DEPENDENCY;
     const ElementType accept[] = { Word_t, WordReference_t, PlaceHolder_t,
 				   Description_t, Feature_t, Alignment_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 6 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void Headwords::init(){
@@ -2868,24 +3603,41 @@ namespace folia {
     _optional_attributes = NO_ATT;
     const ElementType accept[] = { Word_t, WordReference_t, PlaceHolder_t,
 				   Description_t, Feature_t, Metric_t,
-				   Alignment_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 7 );
+				   Alignment_t, Lang_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void PosAnnotation::init(){
     _xmltag="pos";
     _element_id = Pos_t;
     _annotation_type = AnnotationType::POS;
-    const ElementType accept[] = { Feature_t, HeadFeature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 3 );
+    const ElementType accept[] = { Feature_t,
+				   Metric_t, Description_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void LemmaAnnotation::init(){
     _xmltag="lemma";
     _element_id = Lemma_t;
     _annotation_type = AnnotationType::LEMMA;
-    const ElementType accept[] = { Feature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    const ElementType accept[] = { Feature_t, Metric_t, Description_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+  }
+
+  void LangAnnotation::init(){
+    _xmltag="lang";
+    _element_id = Lang_t;
+    _annotation_type = AnnotationType::LANG;
+    const ElementType accept[] = { Feature_t, Metric_t, Description_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void PhonAnnotation::init(){
@@ -2893,7 +3645,9 @@ namespace folia {
     _element_id = Phon_t;
     _annotation_type = AnnotationType::PHON;
     const ElementType accept[] = { Feature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void DomainAnnotation::init(){
@@ -2901,15 +3655,19 @@ namespace folia {
     _element_id = Domain_t;
     _annotation_type = AnnotationType::DOMEIN;
     const ElementType accept[] = { Feature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void SenseAnnotation::init(){
     _xmltag="sense";
     _element_id = Sense_t;
     _annotation_type = AnnotationType::SENSE;
-    const ElementType accept[] = { Feature_t, SynsetFeature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 3 );
+    const ElementType accept[] = { Feature_t, Description_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void SubjectivityAnnotation::init(){
@@ -2917,23 +3675,28 @@ namespace folia {
     _element_id = Subjectivity_t;
     _annotation_type = AnnotationType::SUBJECTIVITY;
     const ElementType accept[] = { Feature_t, Description_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 2 );
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
   }
 
   void Quote::init(){
     _xmltag="quote";
     _element_id = Quote_t;
     _required_attributes = NO_ATT;
-    const ElementType accept[] = { Word_t, Sentence_t, Quote_t, Str_t,
-				   TextContent_t, Description_t, Alignment_t };
-    _accepted_data = std::set<ElementType>(accept, accept + 7 );
+    const ElementType accept[] = { Structure_t, Str_t, Lang_t,
+				   TextContent_t, Description_t, Alignment_t,
+				   Gap_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
     TEXTDELIMITER = " ";
   }
 
   void Feature::init() {
     _xmltag = "feat";
     _element_id = Feature_t;
-    occurrences_per_set = 0; // Allow duplicates within the same set
+    _occurrences_per_set = 0; // Allow duplicates within the same set
   }
 
   void BeginDateTimeFeature::init(){
@@ -2997,23 +3760,64 @@ namespace folia {
     _subset = "time";
   }
 
-  void AbstractSubtokenAnnotation::init() {
-    _required_attributes = NO_ATT;
-    _optional_attributes = ALL;
-    occurrences_per_set = 0; // Allow duplicates within the same set    
-  }
-
   void AbstractSpanAnnotation::init() {
+    _xmltag = "spanannotation";
+    _element_id = SpanAnnotation_t;
     _required_attributes = NO_ATT;
     _optional_attributes = ALL;
-    occurrences_per_set = 0; // Allow duplicates within the same set
+    _occurrences_per_set = 0; // Allow duplicates within the same set
   }
 
   void ErrorDetection::init(){
     _xmltag = "errordetection";
     _element_id = ErrorDetection_t;
     _annotation_type = AnnotationType::ERRORDETECTION;
-    occurrences_per_set = 0; // Allow duplicates within the same set
+    _occurrences_per_set = 0; // Allow duplicates within the same set
+  }
+
+  void AbstractTextMarkup::init(){
+    _xmltag = "textmarkup";
+    _element_id = AbstractTextMarkup_t;
+    _required_attributes = NO_ATT;
+    _optional_attributes = ALL;
+    _annotation_type = AnnotationType::NO_ANN;
+    const ElementType accept[] = { AbstractTextMarkup_t, XmlText_t };
+    _accepted_data =
+      std::set<ElementType>( accept,
+			     accept + sizeof(accept)/sizeof(ElementType) );
+    PRINTABLE = true;
+    TEXTDELIMITER = "";
+    _occurrences_per_set = 0; // Allow duplicates within the same set
+  }
+
+  void TextMarkupString::init(){
+    _xmltag = "t-str";
+    _element_id = TextMarkupString_t;
+    _annotation_type = AnnotationType::STRING;
+  }
+
+  void TextMarkupGap::init(){
+    _xmltag = "t-gap";
+    _element_id = TextMarkupGap_t;
+    _annotation_type = AnnotationType::GAP;
+  }
+
+  void TextMarkupCorrection::init(){
+    _xmltag = "t-correction";
+    _element_id = TextMarkupCorrection_t;
+    _annotation_type = AnnotationType::CORRECTION;
+  }
+
+  void TextMarkupError::init(){
+    _xmltag = "t-error";
+    _element_id = TextMarkupError_t;
+    _annotation_type = AnnotationType::ERRORDETECTION;
+  }
+
+  void TextMarkupStyle::init(){
+    _xmltag = "t-style";
+    _element_id = TextMarkupStyle_t;
+    _annotation_type = AnnotationType::STYLE;
   }
 
 } // namespace folia
diff --git a/src/folialint.cxx b/src/folialint.cxx
index ea3b410..02efe55 100644
--- a/src/folialint.cxx
+++ b/src/folialint.cxx
@@ -1,11 +1,11 @@
 /*
-  $Id: folialint.cxx 15909 2013-04-03 13:52:24Z sloot $
+  $Id: folialint.cxx 17238 2014-05-22 14:26:29Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/folialint.cxx $
 
-  Copyright (c) 1998 - 2013
+  Copyright (c) 1998 - 2014
   ILK   - Tilburg University
   CLiPS - University of Antwerp
- 
+
   This file is part of libfolia
 
   libfolia is free software; you can redistribute it and/or modify
@@ -49,8 +49,7 @@ int main( int argc, char* argv[] ){
     outName == argv[2];
   }
   try {
-    folia::Document d;
-    d.readFromFile( argv[1] );
+    folia::Document d("file='" + string(argv[1]) + "'"); //,debug='3'");"
     if ( !outName.empty() )
       d.save( outName );
     else
diff --git a/src/foliautils.cxx b/src/foliautils.cxx
index e06f5b0..4f86cbd 100644
--- a/src/foliautils.cxx
+++ b/src/foliautils.cxx
@@ -1,11 +1,11 @@
 /*
-  $Id: foliautils.cxx 15909 2013-04-03 13:52:24Z sloot $
+  $Id: foliautils.cxx 17507 2014-08-13 15:20:36Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/foliautils.cxx $
 
-  Copyright (c) 1998 - 2013
+  Copyright (c) 1998 - 2014
   ILK   - Tilburg University
   CLiPS - University of Antwerp
- 
+
   This file is part of libfolia
 
   libfolia is free software; you can redistribute it and/or modify
@@ -35,7 +35,7 @@
 #include <set>
 #include <list>
 #include <stdexcept>
-#include <algorithm> 
+#include <algorithm>
 #include "ticcutils/StringOps.h"
 #include "ticcutils/XMLtools.h"
 #include "libfolia/document.h"
@@ -74,70 +74,70 @@ namespace folia {
     switch ( at ) {
     case AnnotationType::NO_ANN:
       result = "NoNe";
-      break; 
+      break;
     case AnnotationType::TEXT:
       result = "text";
-      break; 
+      break;
     case AnnotationType::STRING:
       result = "string";
-      break; 
+      break;
     case AnnotationType::TOKEN:
       result = "token";
-      break; 
+      break;
     case AnnotationType::DIVISION:
-      result = "div";
-      break; 
-    case AnnotationType::PARAGRAPH: 
+      result = "division"; //adapted from erroneous div
+      break;
+    case AnnotationType::PARAGRAPH:
       result = "paragraph";
-      break; 
-    case AnnotationType::LIST: 
+      break;
+    case AnnotationType::LIST:
       result = "list";
-      break; 
-    case AnnotationType::FIGURE: 
+      break;
+    case AnnotationType::FIGURE:
       result = "figure";
-      break; 
-    case AnnotationType::WHITESPACE: 
+      break;
+    case AnnotationType::WHITESPACE:
       result = "whitespace";
-      break; 
-    case AnnotationType::LINEBREAK: 
+      break;
+    case AnnotationType::LINEBREAK:
       result = "linebreak";
-      break; 
-    case AnnotationType::SENTENCE: 
+      break;
+    case AnnotationType::SENTENCE:
       result = "sentence";
-      break; 
-    case AnnotationType::POS: 
+      break;
+    case AnnotationType::POS:
       result = "pos";
-      break; 
+      break;
     case AnnotationType::LEMMA:
       result = "lemma";
-      break; 
+      break;
     case AnnotationType::DOMEIN:
       result = "domain";
-      break; 
-    case AnnotationType::SENSE: 
+      break;
+    case AnnotationType::SENSE:
       result = "sense";
-      break; 
-    case AnnotationType::SYNTAX: 
+      break;
+    case AnnotationType::SYNTAX:
       result = "syntax";
       break;
-    case AnnotationType::CHUNKING: 
+    case AnnotationType::CHUNKING:
       result = "chunking";
-      break; 
-    case AnnotationType::ENTITY: 
+      break;
+    case AnnotationType::ENTITY:
       result = "entity";
       break;
-    case AnnotationType::CORRECTION: 
+    case AnnotationType::CORRECTION:
       result = "correction";
       break;
-    case AnnotationType::SUGGESTION: 
+    case AnnotationType::SUGGESTION:
       result = "suggestion";
       break;
-    case AnnotationType::ERRORDETECTION: 
+    case AnnotationType::ERRORDETECTION:
       result = "errordetection";
       break;
-    case AnnotationType::ALTERNATIVE: 
+    case AnnotationType::ALTERNATIVE:
       result = "alternative";
-      break; 
+      break;
     case AnnotationType::PHON:
       result = "phon";
       break;
@@ -147,12 +147,12 @@ namespace folia {
     case AnnotationType::MORPHOLOGICAL:
       result = "morphological";
       break;
-    case AnnotationType::SUBENTITY: 
+    case AnnotationType::SUBENTITY:
       result = "subentity";
       break;
     case AnnotationType::EVENT:
       result = "event";
-      break; 
+      break;
     case AnnotationType::DEPENDENCY:
       result = "dependency";
       break;
@@ -161,28 +161,40 @@ namespace folia {
       break;
     case AnnotationType::GAP:
       result = "gap";
-      break; 
+      break;
     case AnnotationType::ALIGNMENT:
       result = "alignment";
-      break; 
+      break;
     case AnnotationType::COMPLEXALIGNMENT:
       result = "complexalignment";
-      break; 
+      break;
     case AnnotationType::COREFERENCE:
       result = "coreference";
-      break; 
+      break;
     case AnnotationType::SEMROLE:
       result = "semrole";
-      break; 
+      break;
     case AnnotationType::METRIC:
       result = "metric";
-      break; 
+      break;
+    case AnnotationType::TABLE:
+      result = "table";
+      break;
+    case AnnotationType::LANG:
+      result = "lang";
+      break;
+    case AnnotationType::STYLE:
+      result = "style";
+      break;
+    case AnnotationType::NOTE:
+      result = "note";
+      break;
     case AnnotationType::LAST_ANN:
       throw logic_error("LAST_ANN");
     };
     return result;
   }
- 
+
   AnnotationType::AnnotationType stringToAT( const string& at ){
     if ( at == "text" )
       return AnnotationType::TEXT;
@@ -190,7 +202,7 @@ namespace folia {
       return AnnotationType::STRING;
     if ( at == "token" )
       return AnnotationType::TOKEN;
-    if ( at == "div" )
+    if (( at == "div" ) || ( at == "division")) //patch, documentation and libraries used different terms
       return AnnotationType::DIVISION;
     if ( at == "paragraph" )
       return AnnotationType::PARAGRAPH;
@@ -219,11 +231,11 @@ namespace folia {
     if ( at == "entity" )
       return AnnotationType::ENTITY;
     if ( at == "correction" )
-      return AnnotationType::CORRECTION; 
+      return AnnotationType::CORRECTION;
     if ( at == "suggestion" )
-      return AnnotationType::SUGGESTION; 
+      return AnnotationType::SUGGESTION;
     if ( at == "errordetection" )
-      return AnnotationType::ERRORDETECTION; 
+      return AnnotationType::ERRORDETECTION;
     if ( at == "alternative" )
       return AnnotationType::ALTERNATIVE;
     if ( at == "phon" )
@@ -252,6 +264,14 @@ namespace folia {
       return AnnotationType::COREFERENCE;
     if ( at == "metric" )
       return AnnotationType::METRIC;
+    if ( at == "table" )
+      return AnnotationType::TABLE;
+    if ( at == "lang" )
+      return AnnotationType::LANG;
+    if ( at == "style" )
+      return AnnotationType::STYLE;
+    if ( at == "note" )
+      return AnnotationType::NOTE;
     throw ValueError( " unknown translation for attribute: " + at );
   }
 
@@ -267,30 +287,38 @@ namespace folia {
     case LineBreak_t: result = "br"; break;
     case WhiteSpace_t: result = "whitespace"; break;
     case Word_t: result = "w"; break;
-    case WordReference_t: result = "wref"; break; 
+    case WordReference_t: result = "wref"; break;
     case Str_t: result = "str"; break;
     case Sentence_t: result = "s"; break;
     case Paragraph_t: result = "p"; break;
     case Division_t: result = "div"; break;
     case Head_t: result = "head"; break;
+    case Table_t: result = "table"; break;
+    case TableHead_t: result = "tablehead"; break;
+    case Cell_t: result = "cell"; break;
+    case Lang_t: result = "lang"; break;
+    case Row_t: result = "row"; break;
     case Caption_t: result = "caption"; break;
     case Label_t: result = "label"; break;
     case List_t: result = "list"; break;
-    case ListItem_t: result = "listitem"; break;
+    case Item_t: result = "item"; break;
     case Figure_t: result = "figure"; break;
     case Quote_t: result = "quote"; break;
+    case TokenAnnotation_t: result = "tokenannotation"; break;
+    case Structure_t: result = "structure"; break;
     case Pos_t: result = "pos"; break;
     case Lemma_t: result = "lemma"; break;
-    case Phon_t: result = "phon"; break; 
-    case Domain_t: result = "domain"; break; 
-    case Sense_t: result = "sense"; break; 
-    case Subjectivity_t: result = "subjectivity"; break; 
+    case Phon_t: result = "phon"; break;
+    case Domain_t: result = "domain"; break;
+    case Sense_t: result = "sense"; break;
+    case Subjectivity_t: result = "subjectivity"; break;
     case Correction_t: result = "correction"; break;
-    case AnnotationLayer_t: result = "annotationlayer"; break; 
-    case SyntacticUnit_t: result = "su"; break; 
-    case SyntaxLayer_t: result = "syntax"; break; 
-    case Chunk_t: result = "chunk"; break; 
-    case Chunking_t: result = "chunking"; break; 
+    case AnnotationLayer_t: result = "annotationlayer"; break;
+    case SpanAnnotation_t: result = "spanannotation"; break;
+    case SyntacticUnit_t: result = "su"; break;
+    case SyntaxLayer_t: result = "syntax"; break;
+    case Chunk_t: result = "chunk"; break;
+    case Chunking_t: result = "chunking"; break;
     case Entity_t: result = "entity"; break;
     case Entities_t: result = "entities"; break;
     case Semroles_t: result = "semroles"; break;
@@ -298,8 +326,6 @@ namespace folia {
     case Coreferences_t: result = "coreferences"; break;
     case CoreferenceLink_t: result = "coreferencelink"; break;
     case CoreferenceChain_t: result = "coreferencechain"; break;
-    // case Subentity_t: result = "subentity"; break;
-    // case Subentities_t: result = "subentities"; break;
     case Morphology_t: result = "morphology"; break;
     case Morpheme_t: result = "morpheme"; break;
     case ErrorDetection_t: result = "errordetection"; break;
@@ -307,8 +333,13 @@ namespace folia {
     case Original_t: result = "original"; break;
     case Current_t: result = "current"; break;
     case Suggestion_t: result = "suggestion"; break;
-    case Alternative_t: result = "alt"; break; 
+    case Alternative_t: result = "alt"; break;
     case Alternatives_t: result = "altlayers"; break;
+    case XmlComment_t: result = "xml-comment"; break;
+    case XmlText_t: result = "xml-text"; break;
+    case External_t: result = "external"; break;
+    case Note_t:result = "note"; break;
+    case Reference_t: result = "ref"; break;
     case Description_t: result = "desc"; break;
     case Gap_t: result = "gap"; break;
     case Content_t: result = "content"; break;
@@ -330,7 +361,13 @@ namespace folia {
     case DependencyDependent_t: result = "dep"; break;
     case Headwords_t: result = "hd"; break;
     case Alignment_t: result = "alignment"; break;
-    case AlignReference_t: result = "aref"; break; 
+    case AlignReference_t: result = "aref"; break;
+    case AbstractTextMarkup_t: result = "textmarkup"; break;
+    case TextMarkupString_t: result = "t-str"; break;
+    case TextMarkupGap_t: result = "t-gap"; break;
+    case TextMarkupCorrection_t: result = "t-correction"; break;
+    case TextMarkupError_t: result = "t-error"; break;
+    case TextMarkupStyle_t: result = "t-style"; break;
     default:
       result = "Unknown Elementtype " + folia::toString( int(et) );
     }
@@ -383,8 +420,8 @@ namespace folia {
     if ( tag == "list" ){
       return List_t;
     }
-    if ( tag == "listitem" ){
-      return ListItem_t;
+    if ( tag == "listitem" || tag == "item" ){
+      return Item_t;
     }
     if ( tag == "p" ){
       return Paragraph_t;
@@ -404,6 +441,36 @@ namespace folia {
     if ( tag == "head" ){
       return Head_t;
     }
+    if ( tag == "table" ){
+      return Table_t;
+    }
+    if ( tag == "tablehead" ){
+      return TableHead_t;
+    }
+    if ( tag == "cell" ){
+      return Cell_t;
+    }
+    if ( tag == "row" ){
+      return Row_t;
+    }
+    if ( tag == "lang" ){
+      return Lang_t;
+    }
+    if ( tag == "xml-comment" ){
+      return XmlComment_t;
+    }
+    if ( tag == "xml-text" ){
+      return XmlText_t;
+    }
+    if ( tag == "external" ){
+      return External_t;
+    }
+    if ( tag == "note" ){
+      return Note_t;
+    }
+    if ( tag == "ref" ){
+      return Reference_t;
+    }
     if ( tag == "desc" ){
       return Description_t;
     }
@@ -422,6 +489,15 @@ namespace folia {
     if ( tag == "annotationlayer" ){
       return AnnotationLayer_t;
     }
+    if ( tag == "spanannotation" ){
+      return SpanAnnotation_t;
+    }
+    if ( tag == "tokenannotation" ){
+      return TokenAnnotation_t;
+    }
+    if ( tag == "structure" ){
+      return Structure_t;
+    }
     if ( tag == "pos" ){
       return Pos_t;
     }
@@ -470,12 +546,6 @@ namespace folia {
     if ( tag == "coreferencechain" ){
       return CoreferenceChain_t;
     }
-    // if ( tag == "subentity" ){
-    //   return Subentity_t;
-    // }
-    // if ( tag == "subentities" ){
-    //   return Subentities_t;
-    // }
     if ( tag == "alt" ){
       return Alternative_t;
     }
@@ -557,14 +627,41 @@ namespace folia {
     if ( tag == "aref" ){
       return AlignReference_t;
     }
+    if ( tag == "textmarkup" ){
+      return AbstractTextMarkup_t;
+    }
+    if ( tag == "t-str" ){
+      return TextMarkupString_t;
+    }
+    if ( tag == "t-gap" ){
+      return TextMarkupGap_t;
+    }
+    if ( tag == "t-correction" ){
+      return TextMarkupCorrection_t;
+    }
+    if ( tag == "t-error" ){
+      return TextMarkupError_t;
+    }
+    if ( tag == "t-style" ){
+      return TextMarkupStyle_t;
+    }
     else {
       throw ValueError( "unknown tag <" + tag + ">" );
     }
     return BASE;
   }
 
-  FoliaElement *FoliaElement::createElement( Document *doc, 
-					     ElementType et ){
+  FoliaElement *FoliaImpl::createElement( Document *doc,
+					  const string& tag ){
+
+    ElementType et = BASE;
+    try {
+      et = stringToET( tag );
+    }
+    catch ( ValueError& e ){
+      cerr << e.what() << endl;
+      return 0;
+    }
     switch ( et ){
     case BASE:
       return new FoLiA( doc );
@@ -596,8 +693,8 @@ namespace folia {
       return new Label( doc );
     case List_t:
       return new List( doc );
-    case ListItem_t:
-      return new ListItem( doc );
+    case Item_t:
+      return new Item( doc );
     case Paragraph_t:
       return new Paragraph( doc );
     case New_t:
@@ -610,6 +707,32 @@ namespace folia {
       return new Suggestion( doc );
     case Head_t:
       return new Head( doc );
+    case Table_t:
+      return new Table( doc );
+    case TableHead_t:
+      return new TableHead( doc );
+    case Cell_t:
+      return new Cell( doc );
+    case Row_t:
+      return new Row( doc );
+    case Lang_t:
+      return new LangAnnotation( doc );
+    case SpanAnnotation_t:
+      return new AbstractSpanAnnotation( doc );
+    case TokenAnnotation_t:
+      return new AbstractTokenAnnotation( doc );
+    case Structure_t:
+      return new AbstractStructureElement( doc );
+    case XmlComment_t:
+      return new XmlComment( doc );
+    case XmlText_t:
+      return new XmlText( doc );
+    case External_t:
+      return new External( doc );
+    case Note_t:
+      return new Note( doc );
+    case Reference_t:
+      return new Reference( doc );
     case Description_t:
       return new Description( doc );
     case Gap_t:
@@ -654,10 +777,6 @@ namespace folia {
       return new CoreferenceLink( doc );
     case CoreferenceChain_t:
       return new CoreferenceChain( doc );
-    // case Subentity_t:
-    //   return new Subentity( doc );
-    // case Subentities_t:
-    //   return new SubentitiesLayer( doc );
     case Alternative_t:
       return new Alternative( doc );
     case PlaceHolder_t:
@@ -712,25 +831,24 @@ namespace folia {
       return new Alignment( doc );
     case AlignReference_t:
       return new AlignReference( doc );
+    case AbstractTextMarkup_t:
+      return new AbstractTextMarkup( doc );
+    case TextMarkupString_t:
+      return new TextMarkupString( doc );
+    case TextMarkupGap_t:
+      return new TextMarkupGap( doc );
+    case TextMarkupCorrection_t:
+      return new TextMarkupCorrection( doc );
+    case TextMarkupError_t:
+      return new TextMarkupError( doc );
+    case TextMarkupStyle_t:
+      return new TextMarkupStyle( doc );
     default:
       throw ValueError( "unknown elementtype(" + toString(int(et)) + ")" );
     }
     return 0;
   }
 
-  FoliaElement *FoliaElement::createElement( Document *doc, 
-					     const string& tag ){
-    
-    ElementType et = BASE;
-    try {
-      et = stringToET( tag );
-    }
-    catch ( ValueError& e ){
-      cerr << e.what() << endl;
-      return 0;
-    }
-    return createElement( doc, et );
-  }
 
   KWargs getArgs( const std::string& s ){
     KWargs result;
@@ -744,7 +862,7 @@ namespace folia {
 
     for ( size_t i=0; i < s.size(); ++i ){
       //      cerr << "bekijk " << s[i] << endl;
-      //      cerr << "quoted = " << (quoted?"YES":"NO") 
+      //      cerr << "quoted = " << (quoted?"YES":"NO")
       // 	   << " parseatt = " << (parseatt?"YES":"NO")
       // 	   << " escaped = " << (escaped?"YES":"NO") << endl;
       if ( s[i] == '\\' ){
@@ -760,7 +878,7 @@ namespace folia {
 	  }
 	}
 	else
-	  throw ArgsError( s + ", stray \\" );	  
+	  throw ArgsError( s + ", stray \\" );
       }
       else if ( s[i] == '\'' ){
 	//	cerr << "handle single quote " << endl;
@@ -841,28 +959,40 @@ namespace folia {
     if ( node ){
       xmlAttr *a = node->properties;
       while ( a ){
-	atts[(char*)a->name] = (char *)a->children->content;
+	if ( a->atype == XML_ATTRIBUTE_ID && string((char*)a->name) == "id" ){
+	  atts["_id"] = (char *)a->children->content;
+	}
+	else
+	  atts[(char*)a->name] = (char *)a->children->content;
 	a = a->next;
       }
     }
     return atts;
   }
 
-  void addAttributes( xmlNode *node, const KWargs& attribs ){
-    KWargs::const_iterator it = attribs.begin();
+  void addAttributes( xmlNode *node, const KWargs& atts ){
+    KWargs attribs = atts;
+    KWargs::iterator it = attribs.find("_id");
+    if ( it != attribs.end() ){ // _id is special for xml:id
+      xmlSetProp( node, XML_XML_ID, (const xmlChar *)it->second.c_str() );
+      attribs.erase(it);
+    }
+    it = attribs.find("lang");
+    if ( it != attribs.end() ){ // lang is special too
+      xmlNodeSetLang( node, (const xmlChar*)it->second.c_str() );
+      attribs.erase(it);
+    }
+    it = attribs.find("id");
+    if ( it != attribs.end() ){ // id is te be sorted before the rest
+      xmlSetProp( node, (const xmlChar*)("id"), (const xmlChar *)it->second.c_str() );
+      attribs.erase(it);
+    }
+    // and now the rest
+    it = attribs.begin();
     while ( it != attribs.end() ){
-      //    cerr << "addAttributes(" << it->first << ", " << it->second << ")" << endl;
-      if ( it->first == "_id" ){ // id is special
-	xmlSetProp( node, XML_XML_ID, (const xmlChar *)it->second.c_str() );
-      }
-      else if ( it->first == "lang" ){ // lang is special
-	xmlNodeSetLang( node, (const xmlChar*)it->second.c_str() );
-      }
-      else {
-	xmlSetProp( node,
-		    (const xmlChar*)it->first.c_str(), 
-		    (const xmlChar*)it->second.c_str() );
-      }
+      xmlSetProp( node,
+		  (const xmlChar*)it->first.c_str(),
+		  (const xmlChar*)it->second.c_str() );
       ++it;
     }
   }
@@ -989,13 +1119,13 @@ namespace folia {
 	  stringTo<AnnotationType::AnnotationType>( s );
 	}
 	catch ( ValueError& e ){
-	  cerr << "no AnnotationType found for string '" << s << "'" << endl;	
+	  cerr << "no AnnotationType found for string '" << s << "'" << endl;
 	  sane = false;
 	}
       }
     }
     return sane;
-  };
+  }
 
   bool ET_sanity_check(){
     bool sane = true;
@@ -1017,14 +1147,14 @@ namespace folia {
 	  continue;
 	}
 	if ( et != et2 ){
-	  cerr << "Argl: toString(ET) doesn't match original:" << s 
+	  cerr << "Argl: toString(ET) doesn't match original:" << s
 	       << " vs " << toString(et2) << endl;
 	  sane = false;
 	  continue;
 	}
-	FoliaElement *tmp = FoliaElement::createElement( 0, s );
+	FoliaElement *tmp = FoliaImpl::createElement( 0, s );
 	if ( tmp == 0 ) {
-	  cerr << "no Element created found for string '" << s << "'" << endl;	
+	  cerr << "no Element created found for string '" << s << "'" << endl;
 	  sane = false;
 	}
 	else {
@@ -1040,26 +1170,26 @@ namespace folia {
       }
     }
     return sane;
-  };
+  }
 
   bool isNCName( const std::string& s ){
-    static string extra=".-_";
+    const string extra=".-_";
     if ( s.empty() )
       throw XmlError( "an empty string is not a valid NCName." );
     else if ( !isalpha(s[0]) )
-      throw XmlError( "'" 
-		      + s 
+      throw XmlError( "'"
+		      + s
 		      + "' is not a valid NCName. (must start with character)." );
     else {
       for ( size_t i=1; i < s.length(); ++i ){
 	if ( !isalnum(s[i]) &&
 	     extra.find(s[i]) == string::npos )
-	  throw XmlError( "'" + s 
-			  + "' is not a valid NCName.(invalid '" 
+	  throw XmlError( "'" + s
+			  + "' is not a valid NCName.(invalid '"
 			  + char(s[i]) + "' found" );
       }
     }
     return true;
   }
-  
+
 } //namespace folia
diff --git a/src/simpletest.cxx b/src/simpletest.cxx
index ff5648c..6973781 100644
--- a/src/simpletest.cxx
+++ b/src/simpletest.cxx
@@ -1,11 +1,11 @@
 /*
-  $Id: simpletest.cxx 15909 2013-04-03 13:52:24Z sloot $
+  $Id: simpletest.cxx 17507 2014-08-13 15:20:36Z sloot $
   $URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/src/simpletest.cxx $
 
-  Copyright (c) 1998 - 2013
+  Copyright (c) 1998 - 2014
   ILK   - Tilburg University
   CLiPS - University of Antwerp
- 
+
   This file is part of libfolia
 
   libfolia is free software; you can redistribute it and/or modify
@@ -50,14 +50,14 @@ int main() {
   cout << " Creating a document from scratch: ";
   Document d( "id='example'" );
   d.declare( AnnotationType::TOKEN, "adhocset", "annotator='proycon'" );
-  if ( d.defaultset(AnnotationType::TOKEN) != "adhocset" 
+  if ( d.defaultset(AnnotationType::TOKEN) != "adhocset"
        ||
        d.defaultannotator(AnnotationType::TOKEN) != "proycon" ){
     return EXIT_FAILURE;
   }
   string id = d.id() + ".text.1";
   KWargs kw = getArgs( "id='" + id + "'" );
-  FoliaElement *text = d.addNode( Text_t, kw );
+  FoliaElement *text = d.addText( kw );
   kw.clear();
   FoliaElement *s = new Sentence( &d, "generate_id='" + text->id() + "'" );
   text->append( s );
diff --git a/test-driver b/test-driver
new file mode 100755
index 0000000..d306056
--- /dev/null
+++ b/test-driver
@@ -0,0 +1,139 @@
+#! /bin/sh
+# test-driver - basic testsuite driver script.
+
+scriptversion=2013-07-13.22; # UTC
+
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake at gnu.org> or send patches to
+# <automake-patches at gnu.org>.
+
+# Make unconditional expansion of undefined variables an error.  This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+usage_error ()
+{
+  echo "$0: $*" >&2
+  print_usage >&2
+  exit 2
+}
+
+print_usage ()
+{
+  cat <<END
+Usage:
+  test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
+              [--expect-failure={yes|no}] [--color-tests={yes|no}]
+              [--enable-hard-errors={yes|no}] [--]
+              TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
+The '--test-name', '--log-file' and '--trs-file' options are mandatory.
+END
+}
+
+test_name= # Used for reporting.
+log_file=  # Where to save the output of the test script.
+trs_file=  # Where to save the metadata of the test run.
+expect_failure=no
+color_tests=no
+enable_hard_errors=yes
+while test $# -gt 0; do
+  case $1 in
+  --help) print_usage; exit $?;;
+  --version) echo "test-driver $scriptversion"; exit $?;;
+  --test-name) test_name=$2; shift;;
+  --log-file) log_file=$2; shift;;
+  --trs-file) trs_file=$2; shift;;
+  --color-tests) color_tests=$2; shift;;
+  --expect-failure) expect_failure=$2; shift;;
+  --enable-hard-errors) enable_hard_errors=$2; shift;;
+  --) shift; break;;
+  -*) usage_error "invalid option: '$1'";;
+   *) break;;
+  esac
+  shift
+done
+
+missing_opts=
+test x"$test_name" = x && missing_opts="$missing_opts --test-name"
+test x"$log_file"  = x && missing_opts="$missing_opts --log-file"
+test x"$trs_file"  = x && missing_opts="$missing_opts --trs-file"
+if test x"$missing_opts" != x; then
+  usage_error "the following mandatory options are missing:$missing_opts"
+fi
+
+if test $# -eq 0; then
+  usage_error "missing argument"
+fi
+
+if test $color_tests = yes; then
+  # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
+  red='' # Red.
+  grn='' # Green.
+  lgn='' # Light green.
+  blu='' # Blue.
+  mgn='' # Magenta.
+  std=''     # No color.
+else
+  red= grn= lgn= blu= mgn= std=
+fi
+
+do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
+trap "st=129; $do_exit" 1
+trap "st=130; $do_exit" 2
+trap "st=141; $do_exit" 13
+trap "st=143; $do_exit" 15
+
+# Test script is run here.
+"$@" >$log_file 2>&1
+estatus=$?
+if test $enable_hard_errors = no && test $estatus -eq 99; then
+  estatus=1
+fi
+
+case $estatus:$expect_failure in
+  0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
+  0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
+  77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
+  99:*)  col=$mgn res=ERROR recheck=yes gcopy=yes;;
+  *:yes) col=$lgn res=XFAIL recheck=no  gcopy=yes;;
+  *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
+esac
+
+# Report outcome to console.
+echo "${col}${res}${std}: $test_name"
+
+# Register the test result, and other relevant metadata.
+echo ":test-result: $res" > $trs_file
+echo ":global-test-result: $res" >> $trs_file
+echo ":recheck: $recheck" >> $trs_file
+echo ":copy-in-global-log: $gcopy" >> $trs_file
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libfolia.git



More information about the debian-science-commits mailing list