Revert "Uprev libmtp to 1.1.12"

This reverts commit 4f0c550b9e148f1760eb6d9a44112940649d885c.

The original CL has been submitted at https://crrev.com/2345493002.

BUG=649592
TEST=none
TBR=thesting@chromium.org

Review URL: https://codereview.chromium.org/2364793002 .
diff --git a/INSTALL b/INSTALL
index 203957d..0ff1ae8 100644
--- a/INSTALL
+++ b/INSTALL
@@ -87,26 +87,16 @@
 bind to the latest version of the shared library. A link to the
 latest version is always provided as $PREFIX/lib/libmtp.so.
 
-libusb support
+libusb Support
 --------------
 
-This package depends on libusb. Get libusb from sourceforge at:
+This package depends on libusb.  Get libusb from sourceforge at:
 
    http://www.sourceforge.net/projects/libusb/
 
-libusb 1.0 and later is preferred for libmtp, but currently also
-older 0.1.x versions of libusb are supported.
-
-
-libgcrypt support
------------------
-
-The MTPZ extension to libmtp requires libgcrypt to be installed.
-
-   http://www.gnu.org/software/libgcrypt/
-
-MTPZ support will not be built unless the configure script finds
-libgcrypt.
+On Linux, please use the very latest version you can get, between
+0.1.8 and 0.1.12 a lot of things happened which pertains to
+the udev hotplugging support, see below.
 
 
 BASIC BUILD PROCEDURE
@@ -214,17 +204,13 @@
 
 If you have a distro without hotplugging enabled try this as root:
 
-  % chmod -R a+w /dev/bus/usb
-
-Or if it's *really* ancient you could try:
-
   % chmod -R a+w /proc/bus/usb
 
 You have to do this again every time you unplug/replug your USB cable
 or restart the jukebox, every time you quit libnjb and restart it,
 etc etc etc an alternative is to run libmtp as root which works just fine.
 The problem is to somehow assure that you (ie the current user) always
-has write access to these files.
+has write access on  /proc/bus/usb/*
 
 You can find the Linux hotplug project at:
 http://linux-hotplug.sourceforge.net/
diff --git a/Makefile.am b/Makefile.am
index ba8f69a..7ef9597 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,22 +10,15 @@
 # build and ship it on Linux.
 #if USE_LINUX
 #udevrulesdir=@UDEV@/rules.d
-#hwdbdir=@UDEV@/hwdb.d
 #udevrules_DATA=@UDEV_RULES@
-#hwdb_DATA=69-libmtp.hwdb
 #noinst_DATA=libmtp.usermap libmtp.fdi
 #
 #libmtp.usermap: util/mtp-hotplug
 #	util/mtp-hotplug > libmtp.usermap
-#
 #@UDEV_RULES@: util/mtp-hotplug
 #	util/mtp-hotplug -u -p"@UDEV@" @UDEV_GROUP@ @UDEV_MODE@ > @UDEV_RULES@
-#
 #libmtp.fdi: util/mtp-hotplug
 #	util/mtp-hotplug -H > libmtp.fdi
 #
-#$(hwdb_DATA): util/mtp-hotplug
-#	util/mtp-hotplug -w > $(hwdb_DATA)
-#
-#CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi libmtp.hwdb
+#CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi
 #endif
diff --git a/Makefile.in b/Makefile.in
index 4575cba..c793a5e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
-
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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,61 +16,6 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__is_gnu_make = { \
-  if test -z '$(MAKELEVEL)'; then \
-    false; \
-  elif test -n '$(MAKE_HOST)'; then \
-    true; \
-  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
-    true; \
-  else \
-    false; \
-  fi; \
-}
-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@
@@ -89,6 +35,12 @@
 build_triplet = @build@
 host_triplet = @host@
 subdir = .
+DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
+	$(srcdir)/hotplug.sh.in $(srcdir)/libmtp.pc.in \
+	$(srcdir)/libmtp.sh.in $(top_srcdir)/configure AUTHORS COPYING \
+	ChangeLog INSTALL TODO config.guess config.rpath config.sub \
+	depcomp install-sh ltmain.sh missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/byteorder.m4 \
 	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/libtool.m4 \
@@ -97,41 +49,21 @@
 	$(top_srcdir)/m4/stdint.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
-	$(am__configure_deps) $(am__DIST_COMMON)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES = libmtp.sh hotplug.sh libmtp.pc
 CONFIG_CLEAN_VPATH_FILES =
-AM_V_P = $(am__v_P_@AM_V@)
-am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
-am__v_P_0 = false
-am__v_P_1 = :
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo "  GEN     " $@;
-am__v_GEN_1 = 
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
-am__v_at_0 = @
-am__v_at_1 = 
 SOURCES =
 DIST_SOURCES =
-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_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
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -163,39 +95,12 @@
 DATA = $(pkgconfig_DATA)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
-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)`
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+	distdir dist dist-all distcheck
 ETAGS = etags
 CTAGS = ctags
-CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
-am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
-	$(srcdir)/hotplug.sh.in $(srcdir)/libmtp.pc.in \
-	$(srcdir)/libmtp.sh.in AUTHORS COPYING ChangeLog INSTALL \
-	README TODO compile config.guess config.rpath config.sub \
-	depcomp install-sh ltmain.sh missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -205,7 +110,6 @@
       && 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,'; \
@@ -233,14 +137,12 @@
   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@
 AS = @AS@
 AUTOCONF = @AUTOCONF@
@@ -393,6 +295,7 @@
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign Makefile
+.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -413,8 +316,8 @@
 $(am__aclocal_m4_deps):
 
 config.h: stamp-h1
-	@test -f $@ || rm -f stamp-h1
-	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
+	@if test ! -f $@; then rm -f stamp-h1; else :; fi
+	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
 
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
@@ -441,34 +344,10 @@
 
 distclean-libtool:
 	-rm -f libtool config.lt
-install-hwdbDATA: $(hwdb_DATA)
-	@$(NORMAL_INSTALL)
-	@list='$(hwdb_DATA)'; test -n "$(hwdbdir)" || list=; \
-	if test -n "$$list"; then \
-	  echo " $(MKDIR_P) '$(DESTDIR)$(hwdbdir)'"; \
-	  $(MKDIR_P) "$(DESTDIR)$(hwdbdir)" || exit 1; \
-	fi; \
-	for p in $$list; do \
-	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  echo "$$d$$p"; \
-	done | $(am__base_list) | \
-	while read files; do \
-	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(hwdbdir)'"; \
-	  $(INSTALL_DATA) $$files "$(DESTDIR)$(hwdbdir)" || exit $$?; \
-	done
-
-uninstall-hwdbDATA:
-	@$(NORMAL_UNINSTALL)
-	@list='$(hwdb_DATA)'; test -n "$(hwdbdir)" || list=; \
-	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-	dir='$(DESTDIR)$(hwdbdir)'; $(am__uninstall_files_from_dir)
 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"; \
@@ -485,25 +364,22 @@
 	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.
-$(am__recursive_targets):
-	@fail=; \
-	if $(am__make_keepgoing); then \
-	  failcom='fail=yes'; \
-	else \
-	  failcom='exit 1'; \
-	fi; \
+# 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; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
-	case "$@" in \
-	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-	  *) list='$(SUBDIRS)' ;; \
-	esac; \
-	for subdir in $$list; do \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
 	  echo "Making $$target in $$subdir"; \
 	  if test "$$subdir" = "."; then \
 	    dot_seen=yes; \
@@ -518,12 +394,57 @@
 	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 	fi; test -z "$$fail"
 
-ID: $(am__tagged_files)
-	$(am__define_uniq_tagged_files); mkid -fID $$unique
-tags: tags-recursive
-TAGS: tags
+$(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
 
-tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+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)
 	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
@@ -539,7 +460,12 @@
 	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
-	$(am__define_uniq_tagged_files); \
+	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; }; }'`; \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -551,11 +477,15 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: ctags-recursive
-
-CTAGS: ctags
-ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
-	$(am__define_uniq_tagged_files); \
+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; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -564,31 +494,9 @@
 	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)
@@ -624,10 +532,13 @@
 	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; \
+	    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 \
 	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
 	    $(am__relativize); \
 	    new_distdir=$$reldir; \
@@ -655,43 +566,41 @@
 	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
 	|| chmod -R a+r "$(distdir)"
 dist-gzip: distdir
-	tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
-	$(am__post_remove_distdir)
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__remove_distdir)
 
 dist-bzip2: distdir
 	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
-	$(am__post_remove_distdir)
+	$(am__remove_distdir)
 
 dist-lzip: distdir
 	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
-	$(am__post_remove_distdir)
+	$(am__remove_distdir)
+
+dist-lzma: distdir
+	tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+	$(am__remove_distdir)
 
 dist-xz: distdir
 	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
-	$(am__post_remove_distdir)
+	$(am__remove_distdir)
 
 dist-tarZ: 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
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
-	$(am__post_remove_distdir)
+	$(am__remove_distdir)
 
 dist-shar: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
-	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
-	shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
-	$(am__post_remove_distdir)
+	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+	$(am__remove_distdir)
 
 dist-zip: distdir
 	-rm -f $(distdir).zip
 	zip -rq $(distdir).zip $(distdir)
-	$(am__post_remove_distdir)
+	$(am__remove_distdir)
 
-dist dist-all:
-	$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_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)
 
 # This target untars the dist file and tries a VPATH configuration.  Then
 # it guarantees that the distribution is self-contained by making another
@@ -699,9 +608,11 @@
 distcheck: dist
 	case '$(DIST_ARCHIVES)' in \
 	*.tar.gz*) \
-	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
+	  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*) \
@@ -709,23 +620,22 @@
 	*.tar.Z*) \
 	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
 	*.shar.gz*) \
-	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac
-	chmod -R a-w $(distdir)
-	chmod u+w $(distdir)
-	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
+	chmod -R a-w $(distdir); chmod a+w $(distdir)
+	mkdir $(distdir)/_build
+	mkdir $(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/sub \
-	  && ../../configure \
+	  && $(am__cd) $(distdir)/_build \
+	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=../.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -748,7 +658,7 @@
 	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
 	  && cd "$$am__cwd" \
 	  || exit 1
-	$(am__post_remove_distdir)
+	$(am__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'
@@ -886,29 +796,43 @@
 
 uninstall-am: uninstall-pkgconfigDATA
 
-.MAKE: $(am__recursive_targets) all install-am install-strip
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
+	ctags-recursive install-am install-strip tags-recursive
 
-.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-am uninstall uninstall-am \
-	uninstall-pkgconfigDATA
-
-.PRECIOUS: Makefile
+.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 \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am uninstall-pkgconfigDATA
 
 
+# This stuff only makes sense on Linux so only
+# build and ship it on Linux.
+#if USE_LINUX
+#udevrulesdir=@UDEV@/rules.d
+#udevrules_DATA=@UDEV_RULES@
+#noinst_DATA=libmtp.usermap libmtp.fdi
+#
+#libmtp.usermap: util/mtp-hotplug
+#	util/mtp-hotplug > libmtp.usermap
+#@UDEV_RULES@: util/mtp-hotplug
+#	util/mtp-hotplug -u -p"@UDEV@" @UDEV_GROUP@ @UDEV_MODE@ > @UDEV_RULES@
+#libmtp.fdi: util/mtp-hotplug
+#	util/mtp-hotplug -H > libmtp.fdi
+#
+#CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi
+#endif
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/README b/README
index 6fe143e..f67e361 100644
--- a/README
+++ b/README
@@ -14,15 +14,10 @@
 controller.
 
 If you're more interested in the MTP responders, gadgets like
-MP3 players, mobile phones etc, look into:
-- MeeGo:s Buteo Sync:
-  https://github.com/nemomobile/buteo-mtp
-  https://wiki.merproject.org/wiki/Buteo/MTP
-- Android has an MTP responder implementation:
-  https://android.googlesource.com/platform/frameworks/base/+/master/media/jni/
-- Ubuntu/Ricardo Salveti has mtp-server and libmtp-server going:
-  https://code.launchpad.net/~phablet-team/mtp/trunk
-  http://bazaar.launchpad.net/~phablet-team/mtp/trunk/files
+MP3 players, mobile phones etc, look into MeeGo:s Buteo Sync:
+http://wiki.meego.com/Buteo - these guys are creating a fully
+open source MTP responder.
+
 
 Heritage
 --------
@@ -143,25 +138,6 @@
 these whenever we can, sometimes we cannot work around it or we
 cannot test your solution.
 
-* Android locked screen: some devices just report zero files
-  and no storages when the device screen is locked, it looks like
-  so:
-
-  mtp-detect
-  Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
-  Attempting to connect device(s)
-  Error 1: Get Storage information failed.
-  Device: SHV-E210K
-  LIBMTP_Get_Storage(): No data available
-  OK.
-
-  This is probably so as not to allow the MTP access to be used
-  as a "backdoor" into the device. Unlock the device before listing
-  files, set the autolock to some large value or disabled if it
-  disturbs you, you are causing this to yourself, or should we say
-  that your vendor is prioritizing security and privacy over
-  ease-of-use. (You may talk to your vendor about this.)
-
 * mtp-* tools doesn't work because someone else is already hogging
   the device
 
@@ -174,12 +150,10 @@
 
   Then re-attach the device.
 
-  Sometimes some gvfs daemons are running on the
-  system and hogging the device, try stopping them
-  with something like these commands:
+  Sometimes the "gvfs-gphoto2-volume-monitor" is running on the
+  system and hogging the device, try something like:
 
-  killall gvfs-mtp-volume-monitor
-  killall gvfs-gphoto2-volume-monitor
+  pkill gfvs-gphoto2-volume-monitor
 
   Then plug in the device and issue "mtp-detect" to figure out if
   this may be the case.
@@ -231,6 +205,13 @@
   manufacturer and ask them to test their product with some libmtp
   program.
 
+* Android locked screen: some devices just report zero files
+  and no storages when the device is locked, probably so as not
+  to allow the MTP access to be used as a "backdoor" into the
+  device. Unlock the device before listing files, set the autolock
+  to some large value or disabled if it disturbs you, you are
+  causing this to yourself.
+
 * Samsung Android 2.3.x devices: these have a special MTP stack
   with some specific bugs that we have maybe nailed down now.
   It suffers from an "immediate connect" syndrome, i.e. you have
@@ -598,30 +579,19 @@
  6. Once mtp-detect gives you an "Ok", open either Rhythmbox or Gnomad2,
     everything should work.
 
-Linux: Try this, if you have a recent Linux kernel,
-add the file (as root):
-
-/etc/modprobe.d/no-usb-storage.conf
-
-With the contents:
-
-options usb-storage quirks=1234:4321:i
-
-This will tell usb-storage to ignore this device when it's inserted
-so it is not hogged by the mass storage interfaces. Remove and re-insert
-the device and see if it works. Usually this does the trick.
-
-For older systems, or as a bigger hammer, run (as root) something
-like:
+Linux: Try this, if you have a recent 2.6.x Linux kernel,
+run (as root) something like:
 
 > rmmod usb_storage ; mtp-detect
 
 You can run most any command or a client like gnomad2 or
 Amarok immediately after the rmmod command. This works
-sometimes. Another even more brutal approach is this:
+sometimes. Another way:
 
 * Edit /etc/modprobe.d/blacklist
+
 * Add the line "blacklist usb-storage"
+
 * Reboot.
 
 Now none of you USB disks, flash memory sticks etc will be
@@ -1028,45 +998,18 @@
 
 - Protocol overview
   - Transactional filesystem - no corruption due to unplugged cables!
-  - The host and the device can access the files simultaneously, the
-    device will always "own" the physical file system and proxy the
-    host (MTP initiator).
 - libmtp interface
 - relation to libgphoto2
 - User expectations fall short:
   - Not really a mountable filesystem.
   - Streaming does not work. (Size needs to be known beforehand due to
     transactional nature.)
-  - GVFS MTP backend to the rescue.
 - Device sins
-  - Using the same VID/PID for several modes, some of which are not MTP.
-    HTC Zopo, HD2, Bird (0x0bb4/0x0c02). Thanks for that, now we cannot
-    detect the protocol from just VID+PID but have to examine the interfaces.
   - Android bugs
   - Samsungs special Android MTP stack
   - SonyEricsson Aricent stack for Xperia Androids pre 4.0, broken headers!
   - Flat access model vs hierarchical, how Android uses MTP as an hierachical
     file system while it was previously a flat database.
-  - Old paradigm: scan the entire non-hierarchical storage for all content,
-    build a cache to speed up the (USB 1.1!) link. Usually all files were
-    stored in the root folder or a single folder named "/Music" or similar.
-  - Android introduced deeply nested folder hierarchies, not seen before
-    on MTP devices.
-  - Microsoft not using the complete metadata dump feature of the MTP
-    protocol (once introduced by creative) instead they walk directories
-    separately.
-  - So caching a big device will take long time and/or timeout.
-  - Go-MTPFS (FUSE) and GVFS MTP - doing the partial directory walk rather
-    than caching all files.
-  - Especially Android devices nowadays assume that
-    you want to index a folder at the time, whereas older MTP devices (such
-    as those from Creative) would assume that you wanted to index the entire
-    device as it was plugged in, and device firmware is now ever more tailored
-    toward per-folder filetree walking. This makes it harder for the library
-    to provide the right abstractions: do we provide an API for indexing the
-    whole device which is unacceptably slow on new devices, or do we provide
-    an API for indexing a directory at the time which will somehow work on
-    older devices too? Shall we deprecate the older API?
 - Detecting from vendor extension, can fix in newer extensions!
 - Autoprobing on Linux
   - Color devices do not like autoprobing
@@ -1075,8 +1018,7 @@
   - Multimode USB - one PID for each mode due to Windows limitations not
     applicable to Linux, SONY devices have ~5 different PIDs for a single
     device.
-  - Mode switch devices? Maybe we do this wrong.
-- MTPZ, came and went. Apparently deprecated by Microsoft with Windows
-  Phone 8.
+  - Mode switch devices?
+- MTPZ
 - Ideas??
 
diff --git a/README.windows.txt b/README.windows.txt
index d360806..81cc1d1 100644
--- a/README.windows.txt
+++ b/README.windows.txt
@@ -1,54 +1,54 @@
-This file was created by James Ravenscroft <ravenscroftj@gmail.com> as a direct revision of Farooq Zaman's work with LibMTP on Windows.

-

- CHANGELOG

-----------------

-14th January 2009: Created the first revision of this file taking information from the work of Farooq Zaman.

-

- 1.0 Compilation of LibMTP on Windows 2000/XP/NT 

------------------------------------------------------------

-LibMTP currently compiles under Windows using MingW/MSys. The source relies upon the __WIN32__ macro which is defined by MinGW by default.

-

-Libraries:

-LibMTP currently depends on LibUSB and libiconv. There are currently projects that port both of these libraries to Windows. Binary files can be

-obtained from:

-

-LibUSB Win32 - http://libusb-win32.sourceforge.net/

-

-LibIconv - http://gnuwin32.sourceforge.net/packages/libiconv.htm

-

-With both of these libraries extracted and placed in MinGW's search path, you can compile the library by opening the Msys prompt, navigating to

-the path where the extracted LibMTP source files can be found and typing:

-

-./configure

-make all

-make install

-

-

-

- 2.0 LibUSB and Driver Issues for Windows

-----------------------------------------------

-

-Unfortunately, Windows does not have abstract USB support and depends upon specific drivers for each and every device you use. Fortunately, 

-LibUSB-Win32 provide a solution to this problem. LibMTP takes advantage of the LibUSB-Win32 Device Driver package.

-

-1. Download the latest device driver binary package (libusb-win32-device-bin-x.x.x.x.tar.gz) from http://sourceforge.net/project/showfiles.php?group_id=78138

-2. Upon extraction, plug in your music device and run bin/inf-wizard.exe. Selecting your device and saving the inf file in the project root directory.

-3. Copy the files "bin/libusb0.dll" and "libusb0.sys" or "libusb0_x64.dll" and "libusb0_x64.sys" for 32-bit or 64-bit operating systems respectively.

-4. Goto Start -> Run, type "devmgmt.msc" and press "ok".

-5. Select your music device from the list and click Action -> Update Driver, Choose "No, not this time" if prompted to connect to microsoft.

-6. Choose "Install from a list or specific location".

-7.  Choose "Don't search, I will choose the driver to install

-8. Click the "Have Disk..." button in the bottom right corner of the prompt

-9. Browse to your .inf file and select it. Press Ok 

-10. The name of your music device should appear in the prompt, click it and click "Next>" (Ignore any prompts about Driver Signing, continuing 

-installation of the selected driver).

-11. Click finish to end the driver install process.

-

-To get your old driver back:

-

-1. Goto Start -> Run, type "devmgmt.msc" and press "ok".

-2. Select your music device, right click on it and click "Properties"

-3. Go to the "Driver" pane and select "Roll Back Driver".

-

- 3.0 

-----------------------------------------------

+This file was created by James Ravenscroft <ravenscroftj@gmail.com> as a direct revision of Farooq Zaman's work with LibMTP on Windows.
+
+ CHANGELOG
+----------------
+14th January 2009: Created the first revision of this file taking information from the work of Farooq Zaman.
+
+ 1.0 Compilation of LibMTP on Windows 2000/XP/NT 
+-----------------------------------------------------------
+LibMTP currently compiles under Windows using MingW/MSys. The source relies upon the __WIN32__ macro which is defined by MinGW by default.
+
+Libraries:
+LibMTP currently depends on LibUSB and libiconv. There are currently projects that port both of these libraries to Windows. Binary files can be
+obtained from:
+
+LibUSB Win32 - http://libusb-win32.sourceforge.net/
+
+LibIconv - http://gnuwin32.sourceforge.net/packages/libiconv.htm
+
+With both of these libraries extracted and placed in MinGW's search path, you can compile the library by opening the Msys prompt, navigating to
+the path where the extracted LibMTP source files can be found and typing:
+
+./configure
+make all
+make install
+
+
+
+ 2.0 LibUSB and Driver Issues for Windows
+----------------------------------------------
+
+Unfortunately, Windows does not have abstract USB support and depends upon specific drivers for each and every device you use. Fortunately, 
+LibUSB-Win32 provide a solution to this problem. LibMTP takes advantage of the LibUSB-Win32 Device Driver package.
+
+1. Download the latest device driver binary package (libusb-win32-device-bin-x.x.x.x.tar.gz) from http://sourceforge.net/project/showfiles.php?group_id=78138
+2. Upon extraction, plug in your music device and run bin/inf-wizard.exe. Selecting your device and saving the inf file in the project root directory.
+3. Copy the files "bin/libusb0.dll" and "libusb0.sys" or "libusb0_x64.dll" and "libusb0_x64.sys" for 32-bit or 64-bit operating systems respectively.
+4. Goto Start -> Run, type "devmgmt.msc" and press "ok".
+5. Select your music device from the list and click Action -> Update Driver, Choose "No, not this time" if prompted to connect to microsoft.
+6. Choose "Install from a list or specific location".
+7.  Choose "Don't search, I will choose the driver to install
+8. Click the "Have Disk..." button in the bottom right corner of the prompt
+9. Browse to your .inf file and select it. Press Ok 
+10. The name of your music device should appear in the prompt, click it and click "Next>" (Ignore any prompts about Driver Signing, continuing 
+installation of the selected driver).
+11. Click finish to end the driver install process.
+
+To get your old driver back:
+
+1. Goto Start -> Run, type "devmgmt.msc" and press "ok".
+2. Select your music device, right click on it and click "Properties"
+3. Go to the "Driver" pane and select "Roll Back Driver".
+
+ 3.0 
+----------------------------------------------
diff --git a/TODO b/TODO
index d4918d7..3bcf06e 100644
--- a/TODO
+++ b/TODO
@@ -54,8 +54,7 @@
   an open connection to the device at the same time via a handle. For example,
   it should be somehow possible to run mtp-detect at the same time as amarok or
   mtpfs is connected to a device. This would require some form of resource
-  sharing, discussions have centered on a D-Bus based connection arbiter
-  daemon.
+  sharing.
 
 5. FEATURE: Implement an OpenSync backend for devices which have
   calendaring, contact etc support. http://opensync.org/
diff --git a/aclocal.m4 b/aclocal.m4
index 857847a..aa40b32 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,7 +1,8 @@
-# generated automatically by aclocal 1.15 -*- Autoconf -*-
+# generated automatically by aclocal 1.11.3 -*- Autoconf -*-
 
-# Copyright (C) 1996-2014 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.
@@ -11,68 +12,61 @@
 # 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.69],,
-[m4_warning([this file was generated for autoconf 2.69.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
+[m4_warning([this file was generated for autoconf 2.68.
 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'.])])
 
-# lib-ld.m4 serial 6
-dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc.
+# lib-ld.m4 serial 4 (gettext-0.18)
+dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 dnl Subroutines of libtool.m4,
-dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
-dnl collision with libtool.m4.
+dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
+dnl with libtool.m4.
 
-dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
+dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
 AC_DEFUN([AC_LIB_PROG_LD_GNU],
 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
-  acl_cv_prog_gnu_ld=yes
-  ;;
+  acl_cv_prog_gnu_ld=yes ;;
 *)
-  acl_cv_prog_gnu_ld=no
-  ;;
+  acl_cv_prog_gnu_ld=no ;;
 esac])
 with_gnu_ld=$acl_cv_prog_gnu_ld
 ])
 
-dnl From libtool-2.4. Sets the variable LD.
+dnl From libtool-1.4. Sets the variable LD.
 AC_DEFUN([AC_LIB_PROG_LD],
-[AC_REQUIRE([AC_PROG_CC])dnl
+[AC_ARG_WITH([gnu-ld],
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
 AC_REQUIRE([AC_CANONICAL_HOST])dnl
-
-AC_ARG_WITH([gnu-ld],
-    [AS_HELP_STRING([--with-gnu-ld],
-        [assume the C compiler uses GNU ld [default=no]])],
-    [test "$withval" = no || with_gnu_ld=yes],
-    [with_gnu_ld=no])dnl
-
 # Prepare PATH_SEPARATOR.
 # The user is always right.
 if test "${PATH_SEPARATOR+set}" != set; then
-  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
-  # contains only /bin. Note that ksh looks also at the FPATH variable,
-  # so we have to set that as well for the test.
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
-    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
-           || PATH_SEPARATOR=';'
-       }
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
 fi
-
 ac_prog=ld
 if test "$GCC" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
-  AC_MSG_CHECKING([for ld used by $CC])
+  AC_MSG_CHECKING([for ld used by GCC])
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -82,11 +76,11 @@
   esac
   case $ac_prog in
     # Accept absolute paths.
-    [[\\/]]* | ?:[[\\/]]*)
-      re_direlt='/[[^/]][[^/]]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
-      while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
+    [[\\/]* | [A-Za-z]:[\\/]*)]
+      [re_direlt='/[^/][^/]*/\.\./']
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
       done
       test -z "$LD" && LD="$ac_prog"
@@ -107,26 +101,23 @@
 fi
 AC_CACHE_VAL([acl_cv_path_LD],
 [if test -z "$LD"; then
-  acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
   for ac_dir in $PATH; do
-    IFS="$acl_save_ifs"
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       acl_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
+      # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
+      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
       *GNU* | *'with BFD'*)
-        test "$with_gnu_ld" != no && break
-        ;;
+        test "$with_gnu_ld" != no && break ;;
       *)
-        test "$with_gnu_ld" != yes && break
-        ;;
+        test "$with_gnu_ld" != yes && break ;;
       esac
     fi
   done
-  IFS="$acl_save_ifs"
+  IFS="$ac_save_ifs"
 else
   acl_cv_path_LD="$LD" # Let the user override the test with a path.
 fi])
@@ -140,8 +131,8 @@
 AC_LIB_PROG_LD_GNU
 ])
 
-# lib-link.m4 serial 26 (gettext-0.18.2)
-dnl Copyright (C) 2001-2016 Free Software Foundation, Inc.
+# lib-link.m4 serial 21 (gettext-0.18)
+dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -160,9 +151,9 @@
 [
   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
   AC_REQUIRE([AC_LIB_RPATH])
-  pushdef([Name],[m4_translit([$1],[./+-], [____])])
-  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
-                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  pushdef([Name],[translit([$1],[./-], [___])])
+  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
     AC_LIB_LINKFLAGS_BODY([$1], [$2])
     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
@@ -200,9 +191,9 @@
 [
   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
   AC_REQUIRE([AC_LIB_RPATH])
-  pushdef([Name],[m4_translit([$1],[./+-], [____])])
-  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
-                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  pushdef([Name],[translit([$1],[./-], [___])])
+  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
 
   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
   dnl accordingly.
@@ -227,8 +218,7 @@
       *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
       *)       LIBS="$LIB[]NAME $LIBS" ;;
     esac
-    AC_LINK_IFELSE(
-      [AC_LANG_PROGRAM([[$3]], [[$4]])],
+    AC_TRY_LINK([$3], [$4],
       [ac_cv_lib[]Name=yes],
       [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
     LIBS="$ac_save_LIBS"
@@ -258,8 +248,6 @@
 dnl Determine the platform dependent parameters needed to use rpath:
 dnl   acl_libext,
 dnl   acl_shlibext,
-dnl   acl_libname_spec,
-dnl   acl_library_names_spec,
 dnl   acl_hardcode_libdir_flag_spec,
 dnl   acl_hardcode_libdir_separator,
 dnl   acl_hardcode_direct,
@@ -302,15 +290,15 @@
 dnl macro call that searches for libname.
 AC_DEFUN([AC_LIB_FROMPACKAGE],
 [
-  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
-                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
   define([acl_frompackage_]NAME, [$2])
   popdef([NAME])
   pushdef([PACK],[$2])
-  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
-                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
+                                  [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
   define([acl_libsinpackage_]PACKUP,
-    m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
+    m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
   popdef([PACKUP])
   popdef([PACK])
 ])
@@ -323,14 +311,14 @@
 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
 [
   AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
-  pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
-                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
   pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
-  pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
-                                     [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
+  pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
+                                  [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
   pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
   dnl Autoconf >= 2.61 supports dots in --with options.
-  pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
+  pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
   dnl By default, look in $includedir and $libdir.
   use_additional=yes
   AC_LIB_WITH_FINAL_PREFIX([
@@ -387,7 +375,7 @@
         names_already_handled="$names_already_handled $name"
         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
         dnl or AC_LIB_HAVE_LINKFLAGS call.
-        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
+        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
         eval value=\"\$HAVE_LIB$uppername\"
         if test -n "$value"; then
           if test "$value" = yes; then
@@ -919,7 +907,7 @@
 ])
 
 # lib-prefix.m4 serial 7 (gettext-0.18)
-dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2005, 2008-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -1143,67 +1131,35 @@
   test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
 ])
 
-dnl pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
-dnl serial 11 (pkg-config-0.29.1)
-dnl
-dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
-dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-dnl 02111-1307, USA.
-dnl
-dnl As a special exception to the GNU General Public License, if you
-dnl distribute this file as part of a program that contains a
-dnl configuration script generated by Autoconf, you may include it under
-dnl the same distribution terms that you use for the rest of that
-dnl program.
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
+# 
+# Copyright © 2004 Scott James Remnant <scott@netsplit.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 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# 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.
 
-dnl PKG_PREREQ(MIN-VERSION)
-dnl -----------------------
-dnl Since: 0.29
-dnl
-dnl Verify that the version of the pkg-config macros are at least
-dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
-dnl installed version of pkg-config, this checks the developer's version
-dnl of pkg.m4 when generating configure.
-dnl
-dnl To ensure that this macro is defined, also add:
-dnl m4_ifndef([PKG_PREREQ],
-dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
-dnl
-dnl See the "Since" comment for each macro you use to see what version
-dnl of the macros you require.
-m4_defun([PKG_PREREQ],
-[m4_define([PKG_MACROS_VERSION], [0.29.1])
-m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
-    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
-])dnl PKG_PREREQ
-
-dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
-dnl ----------------------------------
-dnl Since: 0.16
-dnl
-dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
-dnl first found in the path. Checks that the version of pkg-config found
-dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
-dnl used since that's the first version where most current features of
-dnl pkg-config existed.
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
 AC_DEFUN([PKG_PROG_PKG_CONFIG],
 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
-m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
@@ -1221,19 +1177,18 @@
 		PKG_CONFIG=""
 	fi
 fi[]dnl
-])dnl PKG_PROG_PKG_CONFIG
+])# PKG_PROG_PKG_CONFIG
 
-dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-dnl -------------------------------------------------------------------
-dnl Since: 0.18
-dnl
-dnl Check to see whether a particular set of modules exists. Similar to
-dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
-dnl
-dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-dnl only at the first occurence in configure.ac, so if the first place
-dnl it's called might be skipped (such as if it is within an "if", you
-dnl have to call PKG_CHECK_EXISTS manually
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists.  Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
 AC_DEFUN([PKG_CHECK_EXISTS],
 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 if test -n "$PKG_CONFIG" && \
@@ -1243,26 +1198,22 @@
   $3])dnl
 fi])
 
-dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-dnl ---------------------------------------------
-dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
-dnl pkg_failed based on the result.
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
 m4_define([_PKG_CONFIG],
 [if test -n "$$1"; then
     pkg_cv_[]$1="$$1"
  elif test -n "$PKG_CONFIG"; then
     PKG_CHECK_EXISTS([$3],
-                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes ],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
 		     [pkg_failed=yes])
  else
     pkg_failed=untried
 fi[]dnl
-])dnl _PKG_CONFIG
+])# _PKG_CONFIG
 
-dnl _PKG_SHORT_ERRORS_SUPPORTED
-dnl ---------------------------
-dnl Internal check to see if pkg-config supports short errors.
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -1270,17 +1221,19 @@
 else
         _pkg_short_errors_supported=no
 fi[]dnl
-])dnl _PKG_SHORT_ERRORS_SUPPORTED
+])# _PKG_SHORT_ERRORS_SUPPORTED
 
 
-dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-dnl   [ACTION-IF-NOT-FOUND])
-dnl --------------------------------------------------------------
-dnl Since: 0.4.0
-dnl
-dnl Note that if there is a possibility the first call to
-dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
-dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
 AC_DEFUN([PKG_CHECK_MODULES],
 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
@@ -1300,9 +1253,9 @@
    	AC_MSG_RESULT([no])
         _PKG_SHORT_ERRORS_SUPPORTED
         if test $_pkg_short_errors_supported = yes; then
-	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
         else 
-	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
@@ -1315,7 +1268,7 @@
 Consider adjusting the PKG_CONFIG_PATH environment variable if you
 installed software in a non-standard prefix.
 
-_PKG_TEXT])[]dnl
+_PKG_TEXT])
         ])
 elif test $pkg_failed = untried; then
      	AC_MSG_RESULT([no])
@@ -1326,7 +1279,7 @@
 
 _PKG_TEXT
 
-To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])
         ])
 else
 	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
@@ -1334,107 +1287,27 @@
         AC_MSG_RESULT([yes])
 	$3
 fi[]dnl
-])dnl PKG_CHECK_MODULES
+])# PKG_CHECK_MODULES
 
-
-dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-dnl   [ACTION-IF-NOT-FOUND])
-dnl ---------------------------------------------------------------------
-dnl Since: 0.29
-dnl
-dnl Checks for existence of MODULES and gathers its build flags with
-dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
-dnl and VARIABLE-PREFIX_LIBS from --libs.
-dnl
-dnl Note that if there is a possibility the first call to
-dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
-dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
-dnl configure.ac.
-AC_DEFUN([PKG_CHECK_MODULES_STATIC],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-_save_PKG_CONFIG=$PKG_CONFIG
-PKG_CONFIG="$PKG_CONFIG --static"
-PKG_CHECK_MODULES($@)
-PKG_CONFIG=$_save_PKG_CONFIG[]dnl
-])dnl PKG_CHECK_MODULES_STATIC
-
-
-dnl PKG_INSTALLDIR([DIRECTORY])
-dnl -------------------------
-dnl Since: 0.27
-dnl
-dnl Substitutes the variable pkgconfigdir as the location where a module
-dnl should install pkg-config .pc files. By default the directory is
-dnl $libdir/pkgconfig, but the default can be changed by passing
-dnl DIRECTORY. The user can override through the --with-pkgconfigdir
-dnl parameter.
-AC_DEFUN([PKG_INSTALLDIR],
-[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
-m4_pushdef([pkg_description],
-    [pkg-config installation directory @<:@]pkg_default[@:>@])
-AC_ARG_WITH([pkgconfigdir],
-    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
-    [with_pkgconfigdir=]pkg_default)
-AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
-m4_popdef([pkg_default])
-m4_popdef([pkg_description])
-])dnl PKG_INSTALLDIR
-
-
-dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
-dnl --------------------------------
-dnl Since: 0.27
-dnl
-dnl Substitutes the variable noarch_pkgconfigdir as the location where a
-dnl module should install arch-independent pkg-config .pc files. By
-dnl default the directory is $datadir/pkgconfig, but the default can be
-dnl changed by passing DIRECTORY. The user can override through the
-dnl --with-noarch-pkgconfigdir parameter.
-AC_DEFUN([PKG_NOARCH_INSTALLDIR],
-[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
-m4_pushdef([pkg_description],
-    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
-AC_ARG_WITH([noarch-pkgconfigdir],
-    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
-    [with_noarch_pkgconfigdir=]pkg_default)
-AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
-m4_popdef([pkg_default])
-m4_popdef([pkg_description])
-])dnl PKG_NOARCH_INSTALLDIR
-
-
-dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
-dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-dnl -------------------------------------------
-dnl Since: 0.28
-dnl
-dnl Retrieves the value of the pkg-config variable for the given module.
-AC_DEFUN([PKG_CHECK_VAR],
-[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
-
-_PKG_CONFIG([$1], [variable="][$3]["], [$2])
-AS_VAR_COPY([$1], [pkg_cv_][$1])
-
-AS_VAR_IF([$1], [""], [$5], [$4])dnl
-])dnl PKG_CHECK_VAR
-
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 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_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.15'
+[am__api_version='1.11'
 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.15], [],
+m4_if([$1], [1.11.3], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -1450,22 +1323,24 @@
 # 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.15])dnl
+[AM_AUTOMAKE_VERSION([1.11.3])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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 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
+
 # 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
@@ -1484,7 +1359,7 @@
 #
 # 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,
@@ -1502,26 +1377,30 @@
 # configured tree to be moved without reconfiguration.
 
 AC_DEFUN([AM_AUX_DIR_EXPAND],
-[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-# Expand $ac_aux_dir to an absolute path.
-am_aux_dir=`cd "$ac_aux_dir" && pwd`
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
 ])
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# 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
- m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
-       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+[AC_PREREQ(2.52)dnl
+ ifelse([$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
@@ -1540,14 +1419,16 @@
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 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.
 
+# 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
@@ -1557,7 +1438,7 @@
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
 # 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
@@ -1570,13 +1451,12 @@
 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
 AC_REQUIRE([AM_DEP_TRACK])dnl
 
-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=])
+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=])
 
 AC_CACHE_CHECK([dependency style of $depcc],
                [am_cv_$1_dependencies_compiler_type],
@@ -1584,8 +1464,8 @@
   # 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
@@ -1625,16 +1505,16 @@
     : > 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 10 /bin/sh.
-      echo '/* dummy */' > sub/conftst$i.h
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch 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
@@ -1643,8 +1523,8 @@
       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
@@ -1652,7 +1532,7 @@
       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}
@@ -1700,7 +1580,7 @@
 # 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
@@ -1710,13 +1590,9 @@
 # AM_DEP_TRACK
 # ------------
 AC_DEFUN([AM_DEP_TRACK],
-[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])])
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
 if test "x$enable_dependency_tracking" != xno; then
   am_depcomp="$ac_aux_dir/depcomp"
   AMDEPBACKSLASH='\'
@@ -1731,18 +1607,20 @@
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# 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],
 [{
-  # Older Autoconf quotes --file arguments for eval, but not when files
+  # Autoconf 2.62 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
@@ -1755,7 +1633,7 @@
     # 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.
@@ -1767,19 +1645,21 @@
       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'`; do
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
       # Make sure the directory exists.
       test -f "$dirpart/$file" && continue
       fdir=`AS_DIRNAME(["$file"])`
@@ -1797,7 +1677,7 @@
 # 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],
@@ -1805,23 +1685,32 @@
      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
 ])
 
-# Do all the work for Automake.                             -*- Autoconf -*-
-
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# 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 8
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
+# 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.
+#
+# 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])
 # -----------------------------------------------
@@ -1834,7 +1723,7 @@
 # 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.65])dnl
+[AC_PREREQ([2.62])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
@@ -1863,42 +1752,33 @@
 # Define the identity of the package.
 dnl Distinguish between old-style and new-style calls.
 m4_ifval([$2],
-[AC_DIAGNOSE([obsolete],
-             [$0: two- and three-arguments forms are deprecated.])
-m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+[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], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
-  [ok:ok],,
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
   [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([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 (and possibly the TAP driver).  The
-# system "awk" is bad on some platforms.
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
@@ -1907,82 +1787,34 @@
 			     [_AM_PROG_TAR([v7])])])
 _AM_IF_OPTION([no-dependencies],,
 [AC_PROVIDE_IFELSE([AC_PROG_CC],
-		  [_AM_DEPENDENCIES([CC])],
-		  [m4_define([AC_PROG_CC],
-			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
+		  [_AM_DEPENDENCIES(CC)],
+		  [define([AC_PROG_CC],
+			  defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_CXX],
-		  [_AM_DEPENDENCIES([CXX])],
-		  [m4_define([AC_PROG_CXX],
-			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
+		  [_AM_DEPENDENCIES(CXX)],
+		  [define([AC_PROG_CXX],
+			  defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
 AC_PROVIDE_IFELSE([AC_PROG_OBJC],
-		  [_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_DEPENDENCIES(OBJC)],
+		  [define([AC_PROG_OBJC],
+			  defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
 ])
-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.
+_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_CONFIG_COMMANDS_PRE(dnl
 [m4_provide_if([_AM_COMPILER_EXEEXT],
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
-
-# 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@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 The trailing newline in this macro's definition is deliberate, for
-dnl backward compatibility and to allow trailing 'dnl'-style comments
-dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
 ])
 
-dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+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.
@@ -2004,18 +1836,21 @@
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2008, 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_INSTALL_SH
 # ------------------
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-if test x"${install_sh+set}" != xset; then
+if test x"${install_sh}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -2023,14 +1858,16 @@
     install_sh="\${SHELL} $am_aux_dir/install-sh"
   esac
 fi
-AC_SUBST([install_sh])])
+AC_SUBST(install_sh)])
 
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2005  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],
@@ -2046,12 +1883,14 @@
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  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.
@@ -2069,7 +1908,7 @@
 _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
@@ -2096,12 +1935,15 @@
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# 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],
@@ -2109,10 +1951,11 @@
 $1=${$1-"${am_missing_run}$2"}
 AC_SUBST($1)])
 
+
 # AM_MISSING_HAS_RUN
 # ------------------
-# 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.
+# 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.
 AC_DEFUN([AM_MISSING_HAS_RUN],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 AC_REQUIRE_AUX_FILE([missing])dnl
@@ -2125,51 +1968,54 @@
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --is-lightweight"; then
-  am_missing_run="$MISSING "
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
 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
 ])
 
-#  -*- Autoconf -*-
-# Obsolete and "removed" macros, that must however still report explicit
-# error messages when used, to smooth transition.
-#
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# 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.
 
-AC_DEFUN([AM_CONFIG_HEADER],
-[AC_DIAGNOSE([obsolete],
-['$0': this macro is obsolete.
-You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl
-AC_CONFIG_HEADERS($@)])
+# serial 1
 
-AC_DEFUN([AM_PROG_CC_STDC],
-[AC_PROG_CC
-am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc
-AC_DIAGNOSE([obsolete],
-['$0': this macro is obsolete.
-You should simply use the 'AC][_PROG_CC' macro instead.
-Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
-but upon 'ac_cv_prog_cc_stdc'.])])
-
-AC_DEFUN([AM_C_PROTOTYPES],
-         [AC_FATAL([automatic de-ANSI-fication support has been removed])])
-AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
+# 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 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],
@@ -2179,7 +2025,7 @@
 # --------------------
 # 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)
 # ------------------------
@@ -2193,82 +2039,24 @@
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2014 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) 2001-2014 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_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-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
+# 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_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='
@@ -2279,40 +2067,32 @@
 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 (
-   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
+   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
-     if test "$[2]" = conftest.file || test $am_try -eq 2; then
-       break
-     fi
-     # Just in case.
-     sleep 1
-     am_has_slept=yes
-   done
+      # 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
+
    test "$[2]" = conftest.file
    )
 then
@@ -2322,118 +2102,46 @@
    AC_MSG_ERROR([newly created file is older than distributed files!
 Check your system clock])
 fi
-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
-])
+AC_MSG_RESULT(yes)])
 
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 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.
 
-# 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-2014 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_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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2008, 2010 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.
@@ -2447,16 +2155,18 @@
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2005, 2012 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
@@ -2466,114 +2176,76 @@
 # 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}'])
-
-# 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'
-
 m4_if([$1], [v7],
-  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+     [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.
+_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
 
-  [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],
+  # 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
 
-  [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
-
-    # 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
+  # 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])
+    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/compile b/compile
deleted file mode 100755
index a85b723..0000000
--- a/compile
+++ /dev/null
@@ -1,347 +0,0 @@
-#! /bin/sh
-# Wrapper for compilers which do not understand '-c -o'.
-
-scriptversion=2012-10-14.11; # UTC
-
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
-# Written by Tom Tromey <tromey@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@gnu.org> or send patches to
-# <automake-patches@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@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
old mode 100755
new mode 100644
index eab94e2..f32079a
--- a/config.guess
+++ b/config.guess
@@ -1,12 +1,14 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2014 Free Software Foundation, Inc.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
-timestamp='2014-11-04'
+timestamp='2008-01-23'
 
 # 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
+# the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -15,23 +17,27 @@
 # 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/>.
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
 #
 # 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 Exception is an additional permission under section 7
-# of the GNU General Public License, version 3 ("GPLv3").
-#
-# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
-#
-# 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 to <config-patches@gnu.org>.
+# the same distribution terms that you use for the rest of that program.
 
 
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# 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.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
 me=`echo "$0" | sed -e 's,.*/,,'`
 
 usage="\
@@ -50,7 +56,8 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2014 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 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."
@@ -132,43 +139,12 @@
 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' | sed 's, ,,g'`
-	;;
-esac
-
-case "${UNAME_MACHINE}" in
-  i?86)
-     test -z "$VENDOR" && VENDOR=pc
-     ;;
-  *)
-     test -z "$VENDOR" && VENDOR=unknown
-     ;;
-esac
-test -f /etc/SuSE-release -o -f /.buildenv && VENDOR=suse
-
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:NetBSD:*:*)
 	# NetBSD (nbsd) targets should (where applicable) match one or
-	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
 	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
 	# switched to ELF, *-*-netbsd* would select the old
 	# object file format.  This provides both forward
@@ -194,7 +170,7 @@
 	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
 		eval $set_cc_for_build
 		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
-			| grep -q __ELF__
+			| grep __ELF__ >/dev/null
 		then
 		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
 		    # Return netbsd for either.  FIX?
@@ -204,7 +180,7 @@
 		fi
 		;;
 	    *)
-		os=netbsd
+	        os=netbsd
 		;;
 	esac
 	# The OS release
@@ -225,25 +201,21 @@
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
 	echo "${machine}-${os}${release}"
 	exit ;;
-    *:Bitrig:*:*)
-	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
-	echo ${UNAME_MACHINE_ARCH}-${VENDOR}-bitrig${UNAME_RELEASE}
-	exit ;;
     *:OpenBSD:*:*)
 	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-	echo ${UNAME_MACHINE_ARCH}-${VENDOR}-openbsd${UNAME_RELEASE}
+	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
 	exit ;;
     *:ekkoBSD:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-ekkobsd${UNAME_RELEASE}
+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
 	exit ;;
     *:SolidBSD:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-solidbsd${UNAME_RELEASE}
+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
 	exit ;;
     macppc:MirBSD:*:*)
-	echo powerpc-${VENDOR}-mirbsd${UNAME_RELEASE}
+	echo powerpc-unknown-mirbsd${UNAME_RELEASE}
 	exit ;;
     *:MirBSD:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-mirbsd${UNAME_RELEASE}
+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
 	exit ;;
     alpha:OSF1:*:*)
 	case $UNAME_RELEASE in
@@ -251,7 +223,7 @@
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
 		;;
 	*5.*)
-		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
 		;;
 	esac
 	# According to Compaq, /usr/sbin/psrinfo has been available on
@@ -297,10 +269,7 @@
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
 	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
-	exitcode=$?
-	trap '' 0
-	exit $exitcode ;;
+	exit ;;
     Alpha\ *:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# Should we change UNAME_MACHINE based on the output of uname instead
@@ -311,13 +280,13 @@
 	echo alpha-dec-winnt3.5
 	exit ;;
     Amiga*:UNIX_System_V:4.0:*)
-	echo m68k-${VENDOR}-sysv4
+	echo m68k-unknown-sysv4
 	exit ;;
     *:[Aa]miga[Oo][Ss]:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-amigaos
+	echo ${UNAME_MACHINE}-unknown-amigaos
 	exit ;;
     *:[Mm]orph[Oo][Ss]:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-morphos
+	echo ${UNAME_MACHINE}-unknown-morphos
 	exit ;;
     *:OS/390:*:*)
 	echo i370-ibm-openedition
@@ -326,13 +295,13 @@
 	echo s390-ibm-zvmoe
 	exit ;;
     *:OS400:*:*)
-	echo powerpc-ibm-os400
+        echo powerpc-ibm-os400
 	exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit ;;
-    arm*:riscos:*:*|arm*:RISCOS:*:*)
-	echo arm-${VENDOR}-riscos
+    arm:riscos:*:*|arm:RISCOS:*:*)
+	echo arm-unknown-riscos
 	exit ;;
     SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
 	echo hppa1.1-hitachi-hiuxmpp
@@ -355,33 +324,14 @@
 	case `/usr/bin/uname -p` in
 	    sparc) echo sparc-icl-nx7; exit ;;
 	esac ;;
-    s390x:SunOS:*:*)
-	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
     sun4H:SunOS:5.*:*)
 	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
-    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
-	echo i386-pc-auroraux${UNAME_RELEASE}
-	exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-	eval $set_cc_for_build
-	SUN_ARCH="i386"
-	# If there is a compiler, see if it is configured for 64-bit objects.
-	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
-	# This test works for both compilers.
-	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
-	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-		grep IS_64BIT_ARCH >/dev/null
-	    then
-		SUN_ARCH="x86_64"
-	    fi
-	fi
-	echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     sun4*:SunOS:6*:*)
 	# According to config.sub, this is the proper way to canonicalize
@@ -425,23 +375,23 @@
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-	echo m68k-atari-mint${UNAME_RELEASE}
+        echo m68k-atari-mint${UNAME_RELEASE}
 	exit ;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
 	echo m68k-atari-mint${UNAME_RELEASE}
-	exit ;;
+        exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-	echo m68k-atari-mint${UNAME_RELEASE}
+        echo m68k-atari-mint${UNAME_RELEASE}
 	exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-	echo m68k-milan-mint${UNAME_RELEASE}
-	exit ;;
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-	echo m68k-hades-mint${UNAME_RELEASE}
-	exit ;;
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-	echo m68k-${VENDOR}-mint${UNAME_RELEASE}
-	exit ;;
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
     m68k:machten:*:*)
 	echo m68k-apple-machten${UNAME_RELEASE}
 	exit ;;
@@ -511,8 +461,8 @@
 	echo m88k-motorola-sysv3
 	exit ;;
     AViiON:dgux:*:*)
-	# DG/UX returns AViiON for all architectures
-	UNAME_PROCESSOR=`/usr/bin/uname -p`
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
 	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
 	then
 	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@@ -525,7 +475,7 @@
 	else
 	    echo i586-dg-dgux${UNAME_RELEASE}
 	fi
-	exit ;;
+ 	exit ;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
 	echo m88k-dolphin-sysv3
 	exit ;;
@@ -582,16 +532,15 @@
 		echo rs6000-ibm-aix3.2
 	fi
 	exit ;;
-    *:AIX:*:[4567])
+    *:AIX:*:[456])
 	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
 	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
 		IBM_ARCH=rs6000
 	else
 		IBM_ARCH=powerpc
 	fi
-	if [ -x /usr/bin/lslpp ] ; then
-		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
-			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
 	else
 		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
 	fi
@@ -626,52 +575,52 @@
 	    9000/[678][0-9][0-9])
 		if [ -x /usr/bin/getconf ]; then
 		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-		    case "${sc_cpu_version}" in
-		      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-		      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-		      532)                      # CPU_PA_RISC2_0
-			case "${sc_kernel_bits}" in
-			  32) HP_ARCH="hppa2.0n" ;;
-			  64) HP_ARCH="hppa2.0w" ;;
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
 			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-			esac ;;
-		    esac
+                        esac ;;
+                    esac
 		fi
 		if [ "${HP_ARCH}" = "" ]; then
 		    eval $set_cc_for_build
-		    sed 's/^		//' << EOF >$dummy.c
+		    sed 's/^              //' << EOF >$dummy.c
 
-		#define _HPUX_SOURCE
-		#include <stdlib.h>
-		#include <unistd.h>
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
 
-		int main ()
-		{
-		#if defined(_SC_KERNEL_BITS)
-		    long bits = sysconf(_SC_KERNEL_BITS);
-		#endif
-		    long cpu  = sysconf (_SC_CPU_VERSION);
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
 
-		    switch (cpu)
-			{
-			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-			case CPU_PA_RISC2_0:
-		#if defined(_SC_KERNEL_BITS)
-			    switch (bits)
-				{
-				case 64: puts ("hppa2.0w"); break;
-				case 32: puts ("hppa2.0n"); break;
-				default: puts ("hppa2.0"); break;
-				} break;
-		#else  /* !defined(_SC_KERNEL_BITS) */
-			    puts ("hppa2.0"); break;
-		#endif
-			default: puts ("hppa1.0"); break;
-			}
-		    exit (0);
-		}
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
 EOF
 		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
 		    test -z "$HP_ARCH" && HP_ARCH=hppa
@@ -691,7 +640,7 @@
 	    # => hppa64-hp-hpux11.23
 
 	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
-		grep -q __LP64__
+		grep __LP64__ >/dev/null
 	    then
 		HP_ARCH="hppa2.0w"
 	    else
@@ -752,9 +701,9 @@
 	exit ;;
     i*86:OSF1:*:*)
 	if [ -x /usr/sbin/sysversion ] ; then
-	    echo ${UNAME_MACHINE}-${VENDOR}-osf1mk
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
 	else
-	    echo ${UNAME_MACHINE}-${VENDOR}-osf1
+	    echo ${UNAME_MACHINE}-unknown-osf1
 	fi
 	exit ;;
     parisc*:Lites*:*:*)
@@ -762,22 +711,22 @@
 	exit ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
 	echo c1-convex-bsd
-	exit ;;
+        exit ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
 	else echo c2-convex-bsd
 	fi
-	exit ;;
+        exit ;;
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
 	echo c34-convex-bsd
-	exit ;;
+        exit ;;
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
 	echo c38-convex-bsd
-	exit ;;
+        exit ;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
 	echo c4-convex-bsd
-	exit ;;
+        exit ;;
     CRAY*Y-MP:*:*:*)
 	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit ;;
@@ -801,70 +750,62 @@
 	exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-	exit ;;
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
     5000:UNIX_System_V:4.*:*)
-	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
 	exit ;;
     sparc*:BSD/OS:*:*)
-	echo sparc-${VENDOR}-bsdi${UNAME_RELEASE}
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
 	exit ;;
     *:BSD/OS:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-bsdi${UNAME_RELEASE}
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit ;;
     *:FreeBSD:*:*)
-	UNAME_PROCESSOR=`/usr/bin/uname -p`
-	case ${UNAME_PROCESSOR} in
+	case ${UNAME_MACHINE} in
+	    pc98)
+		echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	    amd64)
-		echo x86_64-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	    *)
-		echo ${UNAME_PROCESSOR}-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+		echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
 	esac
 	exit ;;
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
 	exit ;;
-    *:MINGW64*:*)
-	echo ${UNAME_MACHINE}-pc-mingw64
-	exit ;;
     *:MINGW*:*)
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
-    *:MSYS*:*)
-	echo ${UNAME_MACHINE}-pc-msys
-	exit ;;
     i*:windows32*:*)
-	# uname -m includes "-pc" on this system.
-	echo ${UNAME_MACHINE}-mingw32
+    	# uname -m includes "-pc" on this system.
+    	echo ${UNAME_MACHINE}-mingw32
 	exit ;;
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
-    *:Interix*:*)
-	case ${UNAME_MACHINE} in
+    *:Interix*:[3456]*)
+    	case ${UNAME_MACHINE} in
 	    x86)
 		echo i586-pc-interix${UNAME_RELEASE}
 		exit ;;
-	    authenticamd | genuineintel | EM64T)
-		echo x86_64-${VENDOR}-interix${UNAME_RELEASE}
+	    EM64T | authenticamd)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
 		exit ;;
 	    IA64)
-		echo ia64-${VENDOR}-interix${UNAME_RELEASE}
+		echo ia64-unknown-interix${UNAME_RELEASE}
 		exit ;;
 	esac ;;
     [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
 	echo i${UNAME_MACHINE}-pc-mks
 	exit ;;
-    8664:Windows_NT:*)
-	echo x86_64-pc-mks
-	exit ;;
     i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
@@ -875,31 +816,110 @@
 	echo ${UNAME_MACHINE}-pc-uwin
 	exit ;;
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-	echo x86_64-${VENDOR}-cygwin
+	echo x86_64-unknown-cygwin
 	exit ;;
     p*:CYGWIN*:*)
-	echo powerpcle-${VENDOR}-cygwin
+	echo powerpcle-unknown-cygwin
 	exit ;;
     prep*:SunOS:5.*:*)
-	echo powerpcle-${VENDOR}-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     *:GNU:*:*)
 	# the GNU system
-	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-${VENDOR}-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 	exit ;;
     *:GNU/*:*:*)
 	# other systems with GNU libc and userland
-	echo ${UNAME_MACHINE}-${VENDOR}-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
 	exit ;;
     i*86:Minix:*:*)
 	echo ${UNAME_MACHINE}-pc-minix
 	exit ;;
-    aarch64:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
+    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
+	else
+	    echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+	fi
 	exit ;;
-    aarch64_be:Linux:*:*)
-	UNAME_MACHINE=aarch64_be
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
+    avr32*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    cris:Linux:*:*)
+	echo cris-axis-linux-gnu
+	exit ;;
+    crisv32:Linux:*:*)
+	echo crisv32-axis-linux-gnu
+	exit ;;
+    frv:Linux:*:*)
+    	echo frv-unknown-linux-gnu
+	exit ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit ;;
+    mips:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef mips
+	#undef mipsel
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mipsel
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=mips
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	;;
+    mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef mips64
+	#undef mips64el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mips64el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=mips64
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^CPU/{
+		s: ::g
+		p
+	    }'`"
+	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+	;;
+    or32:Linux:*:*)
+	echo or32-unknown-linux-gnu
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-gnu
+	exit ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
 	exit ;;
     alpha:Linux:*:*)
 	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -910,132 +930,106 @@
 	  EV6)   UNAME_MACHINE=alphaev6 ;;
 	  EV67)  UNAME_MACHINE=alphaev67 ;;
 	  EV68*) UNAME_MACHINE=alphaev68 ;;
-	esac
-	objdump --private-headers /bin/sh | grep -q ld.so.1
-	if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    arc:Linux:*:* | arceb:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-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}-${VENDOR}-linux-${LIBC}
-	else
-	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
-		| grep -q __ARM_PCS_VFP
-	    then
-		echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}eabi
-	    else
-		echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}eabihf
-	    fi
-	fi
-	exit ;;
-    avr32*:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    cris:Linux:*:*)
-	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
-	exit ;;
-    crisv32:Linux:*:*)
-	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
-	exit ;;
-    frv:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    hexagon:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    i*86:Linux:*:*)
-	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
-	exit ;;
-    ia64:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    m32r*:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    m68*:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    mips:Linux:*:* | mips64:Linux:*:*)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#undef CPU
-	#undef ${UNAME_MACHINE}
-	#undef ${UNAME_MACHINE}el
-	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-	CPU=${UNAME_MACHINE}el
-	#else
-	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-	CPU=${UNAME_MACHINE}
-	#else
-	CPU=
-	#endif
-	#endif
-EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
-	test x"${CPU}" != x && { echo "${CPU}-${VENDOR}-linux-${LIBC}"; exit; }
-	;;
-    openrisc*:Linux:*:*)
-	echo or1k-${VENDOR}-linux-${LIBC}
-	exit ;;
-    or32:Linux:*:* | or1k*:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    padre:Linux:*:*)
-	echo sparc-${VENDOR}-linux-${LIBC}
-	exit ;;
-    parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-${VENDOR}-linux-${LIBC}
+        esac
+	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${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-${VENDOR}-linux-${LIBC} ;;
-	  PA8*) echo hppa2.0-${VENDOR}-linux-${LIBC} ;;
-	  *)    echo hppa-${VENDOR}-linux-${LIBC} ;;
+	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
+	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
+	  *)    echo hppa-unknown-linux-gnu ;;
 	esac
 	exit ;;
-    ppc64:Linux:*:*)
-	echo powerpc64-${VENDOR}-linux-${LIBC}
-	exit ;;
-    ppc:Linux:*:*)
-	echo powerpc-${VENDOR}-linux-${LIBC}
-	exit ;;
-    ppc64le:Linux:*:*)
-	echo powerpc64le-${VENDOR}-linux-${LIBC}
-	exit ;;
-    ppcle:Linux:*:*)
-	echo powerpcle-${VENDOR}-linux-${LIBC}
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
 	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
-	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+	echo ${UNAME_MACHINE}-ibm-linux
 	exit ;;
     sh64*:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     sh*:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
-	exit ;;
-    tile*:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     vax:Linux:*:*)
-	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+	echo ${UNAME_MACHINE}-dec-linux-gnu
 	exit ;;
     x86_64:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
+	echo x86_64-unknown-linux-gnu
 	exit ;;
     xtensa*:Linux:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
+    i*86:Linux:*:*)
+	# The BFD linker knows what the default object file format is, so
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	# Set LC_ALL=C to ensure ld outputs messages in English.
+	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+			 | sed -ne '/supported targets:/!d
+				    s/[ 	][ 	]*/ /g
+				    s/.*supported targets: *//
+				    s/ .*//
+				    p'`
+        case "$ld_supported_targets" in
+	  elf32-i386)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	  a.out-i386-linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit ;;
+	  coff-i386)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit ;;
+	  "")
+		# Either a pre-BFD a.out linker (linux-gnuoldld) or
+		# one that does not give us useful --help.
+		echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+		exit ;;
+	esac
+	# Determine whether the default compiler is a.out or elf
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <features.h>
+	#ifdef __ELF__
+	# ifdef __GLIBC__
+	#  if __GLIBC__ >= 2
+	LIBC=gnu
+	#  else
+	LIBC=gnulibc1
+	#  endif
+	# else
+	LIBC=gnulibc1
+	# endif
+	#else
+	#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+	LIBC=gnu
+	#else
+	LIBC=gnuaout
+	#endif
+	#endif
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+	    /^LIBC/{
+		s: ::g
+		p
+	    }'`"
+	test x"${LIBC}" != x && {
+		echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+		exit
+	}
+	test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+	;;
     i*86:DYNIX/ptx:4*:*)
 	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
 	# earlier versions are messed up and put the nodename in both
@@ -1043,11 +1037,11 @@
 	echo i386-sequent-sysv4
 	exit ;;
     i*86:UNIX_SV:4.2MP:2.*)
-	# Unixware is an offshoot of SVR4, but it has its own version
-	# number series starting with 2...
-	# I am not positive that other SVR4 systems won't match this,
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
 	# I just have to hope.  -- rms.
-	# Use sysv4.2uw... so that sysv4* matches it.
+        # Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit ;;
     i*86:OS/2:*:*)
@@ -1056,16 +1050,16 @@
 	echo ${UNAME_MACHINE}-pc-os2-emx
 	exit ;;
     i*86:XTS-300:*:STOP)
-	echo ${UNAME_MACHINE}-${VENDOR}-stop
+	echo ${UNAME_MACHINE}-unknown-stop
 	exit ;;
     i*86:atheos:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-atheos
+	echo ${UNAME_MACHINE}-unknown-atheos
 	exit ;;
     i*86:syllable:*:*)
 	echo ${UNAME_MACHINE}-pc-syllable
 	exit ;;
-    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
-	echo i386-${VENODR}-lynxos${UNAME_RELEASE}
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
 	exit ;;
     i*86:*DOS:*:*)
 	echo ${UNAME_MACHINE}-pc-msdosdjgpp
@@ -1079,13 +1073,13 @@
 	fi
 	exit ;;
     i*86:*:5:[678]*)
-	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
 	case `/bin/uname -X | grep "^Machine"` in
 	    *486*)	     UNAME_MACHINE=i486 ;;
 	    *Pentium)	     UNAME_MACHINE=i586 ;;
 	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
 	esac
-	echo ${UNAME_MACHINE}-${VENDOR}-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
 	exit ;;
     i*86:*:3.2:*)
 	if test -f /usr/options/cb.name; then
@@ -1107,13 +1101,10 @@
 	exit ;;
     pc:*:*:*)
 	# Left here for compatibility:
-	# uname -m prints for DJGPP always 'pc', but it prints nothing about
-	# the processor, so we play safe by assuming i586.
-	# Note: whatever this is, it MUST be the same as what config.sub
-	# prints for the "djgpp" host, or else GDB configury will decide that
-	# this is a cross-build.
-	echo i586-pc-msdosdjgpp
-	exit ;;
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+	echo i386-pc-msdosdjgpp
+        exit ;;
     Intel:Mach:3*:*)
 	echo i386-pc-mach3
 	exit ;;
@@ -1124,7 +1115,7 @@
 	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
 	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
 	else # Add other i860-SVR4 vendors below as they are discovered.
-	  echo i860-${VENODR}-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
 	fi
 	exit ;;
     mini*:CTIX:SYS*5:*)
@@ -1148,32 +1139,22 @@
 	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
 	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-	  && { echo i486-ncr-sysv4; exit; } ;;
-    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
-	OS_REL='.3'
-	test -r /etc/.relid \
-	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-	    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
-	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
-	    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-	echo m68k-${VENDOR}-lynxos${UNAME_RELEASE}
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
 	exit ;;
     mc68030:UNIX_System_V:4.*:*)
 	echo m68k-atari-sysv4
 	exit ;;
     TSUNAMI:LynxOS:2.*:*)
-	echo sparc-${VENDOR}-lynxos${UNAME_RELEASE}
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
 	exit ;;
     rs6000:LynxOS:2.*:*)
-	echo rs6000-${VENDOR}-lynxos${UNAME_RELEASE}
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
 	exit ;;
-    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
-	echo powerpc-${VENDOR}-lynxos${UNAME_RELEASE}
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
 	exit ;;
     SM[BE]S:UNIX_SV:*:*)
 	echo mips-dde-sysv${UNAME_RELEASE}
@@ -1192,10 +1173,10 @@
 		echo ns32k-sni-sysv
 	fi
 	exit ;;
-    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-			# says <Richard.M.Bartel@ccMail.Census.GOV>
-	echo i586-unisys-sysv4
-	exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
     *:UNIX_System_V:4*:FTX*)
 	# From Gerald Hewes <hewes@openmarket.com>.
 	# How about differentiating between stratus architectures? -djm
@@ -1221,11 +1202,11 @@
 	exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 	if [ -d /usr/nec ]; then
-		echo mips-nec-sysv${UNAME_RELEASE}
+	        echo mips-nec-sysv${UNAME_RELEASE}
 	else
-		echo mips-${VENDOR}-sysv${UNAME_RELEASE}
+	        echo mips-unknown-sysv${UNAME_RELEASE}
 	fi
-	exit ;;
+        exit ;;
     BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
 	echo powerpc-be-beos
 	exit ;;
@@ -1235,12 +1216,6 @@
     BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
 	echo i586-pc-beos
 	exit ;;
-    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
-	echo i586-pc-haiku
-	exit ;;
-    x86_64:Haiku:*:*)
-	echo x86_64-${VENDOR}-haiku
-	exit ;;
     SX-4:SUPER-UX:*:*)
 	echo sx4-nec-superux${UNAME_RELEASE}
 	exit ;;
@@ -1267,31 +1242,9 @@
 	exit ;;
     *:Darwin:*:*)
 	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-	eval $set_cc_for_build
-	if test "$UNAME_PROCESSOR" = unknown ; then
-	    UNAME_PROCESSOR=powerpc
-	fi
-	if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
-	    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
-	elif test "$UNAME_PROCESSOR" = i386 ; then
-	    # Avoid executing cc on OS X 10.9, as it ships with a stub
-	    # that puts up a graphical alert prompting to install
-	    # developer tools.  Any system running Mac OS X 10.7 or
-	    # later (Darwin 11 and later) is required to have a 64-bit
-	    # processor. This is not true of the ARM version of Darwin
-	    # that Apple uses in portable devices.
-	    UNAME_PROCESSOR=x86_64
-	fi
+	case $UNAME_PROCESSOR in
+	    unknown) UNAME_PROCESSOR=powerpc ;;
+	esac
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
@@ -1305,10 +1258,7 @@
     *:QNX:*:4*)
 	echo i386-pc-qnx
 	exit ;;
-    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:*:*)
@@ -1332,13 +1282,13 @@
 	else
 	    UNAME_MACHINE="$cputype"
 	fi
-	echo ${UNAME_MACHINE}-${VENDOR}-plan9
+	echo ${UNAME_MACHINE}-unknown-plan9
 	exit ;;
     *:TOPS-10:*:*)
-	echo pdp10-${VENDOR}-tops10
+	echo pdp10-unknown-tops10
 	exit ;;
     *:TENEX:*:*)
-	echo pdp10-${VENDOR}-tenex
+	echo pdp10-unknown-tenex
 	exit ;;
     KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
 	echo pdp10-dec-tops20
@@ -1347,19 +1297,19 @@
 	echo pdp10-xkl-tops20
 	exit ;;
     *:TOPS-20:*:*)
-	echo pdp10-${VENDOR}-tops20
+	echo pdp10-unknown-tops20
 	exit ;;
     *:ITS:*:*)
-	echo pdp10-${VENDOR}-its
+	echo pdp10-unknown-its
 	exit ;;
     SEI:*:*:SEIUX)
-	echo mips-sei-seiux${UNAME_RELEASE}
+        echo mips-sei-seiux${UNAME_RELEASE}
 	exit ;;
     *:DragonFly:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit ;;
     *:*VMS:*:*)
-	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
 	case "${UNAME_MACHINE}" in
 	    A*) echo alpha-dec-vms ; exit ;;
 	    I*) echo ia64-dec-vms ; exit ;;
@@ -1374,14 +1324,159 @@
     i*86:rdos:*:*)
 	echo ${UNAME_MACHINE}-pc-rdos
 	exit ;;
-    i*86:AROS:*:*)
-	echo ${UNAME_MACHINE}-pc-aros
-	exit ;;
-    x86_64:VMkernel:*:*)
-	echo ${UNAME_MACHINE}-${VENDOR}-esx
-	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_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+	{ echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit ;;
+    c34*)
+	echo c34-convex-bsd
+	exit ;;
+    c38*)
+	echo c38-convex-bsd
+	exit ;;
+    c4*)
+	echo c4-convex-bsd
+	exit ;;
+    esac
+fi
+
 cat >&2 <<EOF
 $0: unable to guess system type
 
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..43e54c3
--- /dev/null
+++ b/config.h
@@ -0,0 +1,211 @@
+/* config.h.  Generated from config.h.in by configure.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have the `basename' function. */
+#define HAVE_BASENAME 1
+
+/* Define to 1 if you have the <byteswap.h> header file. */
+#define HAVE_BYTESWAP_H 1
+
+/* Define to 1 if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define if you have the iconv() function and it works. */
+#define HAVE_ICONV 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <langinfo.h> header file. */
+#define HAVE_LANGINFO_H 1
+
+/* Define to 1 if you have the `gcrypt' library (-lgcrypt). */
+#define HAVE_LIBGCRYPT 1
+
+/* Define to 1 if you have the <libgen.h> header file. */
+#define HAVE_LIBGEN_H 1
+
+/* Have libusb 0.x */
+/* #undef HAVE_LIBUSB0 */
+
+/* Have libusb 1.0 */
+#define HAVE_LIBUSB1 /**/
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+   to 0 otherwise. */
+#define HAVE_MALLOC 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mkstemp' function. */
+#define HAVE_MKSTEMP 1
+
+/* Have libopenusb 1.0 */
+/* #undef HAVE_OPENUSB */
+
+/* Define to 1 if you have the `select' function. */
+#define HAVE_SELECT 1
+
+/* Define to 1 if `stat' has the bug that it succeeds when given the
+   zero-length file name argument. */
+/* #undef HAVE_STAT_EMPTY_STRING_BUG */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strndup' function. */
+#define HAVE_STRNDUP 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* Define to 1 if `st_blksize' is a member of `struct stat'. */
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+
+/* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use
+   `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */
+#define HAVE_ST_BLKSIZE 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#define HAVE_SYS_UIO_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `usleep' function. */
+#define HAVE_USLEEP 1
+
+/* Define as const if the declaration of iconv() needs const. */
+#define ICONV_CONST 
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+   slash. */
+#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE "libmtp"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "libmtp-discuss@lists.sourceforge.net"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libmtp"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libmtp 1.1.5"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libmtp"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.1.5"
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Enable MTPZ functionality */
+/* #undef USE_MTPZ */
+
+/* Version number of package */
+#define VERSION "1.1.5"
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* #  undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to rpl_malloc if the replacement function should be used. */
+/* #undef malloc */
+
+/* Define to `long int' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
diff --git a/config.h.in b/config.h.in
index 26eee8a..1e89197 100644
--- a/config.h.in
+++ b/config.h.in
@@ -54,6 +54,10 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+   to 0 otherwise. */
+#undef HAVE_MALLOC
+
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
@@ -187,11 +191,6 @@
 # endif
 #endif
 
-/* Enable large inode numbers on Mac OS X 10.5.  */
-#ifndef _DARWIN_USE_64_BIT_INODE
-# define _DARWIN_USE_64_BIT_INODE 1
-#endif
-
 /* Number of bits in a file offset, on hosts where this is settable. */
 #undef _FILE_OFFSET_BITS
 
@@ -201,6 +200,9 @@
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
+/* Define to rpl_malloc if the replacement function should be used. */
+#undef malloc
+
 /* Define to `long int' if <sys/types.h> does not define. */
 #undef off_t
 
diff --git a/config.sub b/config.sub
old mode 100755
new mode 100644
index 7ffe373..6759825
--- a/config.sub
+++ b/config.sub
@@ -1,40 +1,44 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2014 Free Software Foundation, Inc.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
 
-timestamp='2014-12-03'
+timestamp='2008-01-16'
 
-# 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
+# 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
 # (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/>.
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
 #
 # 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 Exception is an additional permission under section 7
-# of the GNU General Public License, version 3 ("GPLv3").
+# the same distribution terms that you use for the rest of that program.
 
 
-# Please send patches to <config-patches@gnu.org>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
 #
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
 # If it is invalid, we print an error message on stderr and exit with code 1.
 # Otherwise, we print the canonical config type on stdout and succeed.
 
-# You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
-
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
 # that are meaningful with *any* GNU software.
@@ -68,7 +72,8 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2014 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 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."
@@ -115,18 +120,12 @@
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
-  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-  knetbsd*-gnu* | netbsd*-gnu* | \
-  kopensolaris*-gnu* | \
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
-  android-linux)
-    os=-linux-android
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
-    ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
@@ -149,13 +148,10 @@
 	-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)
 		os=
 		basic_machine=$1
 		;;
-	-bluegene*)
-		os=-cnk
-		;;
 	-sim | -cisco | -oki | -wec | -winbond)
 		os=
 		basic_machine=$1
@@ -170,10 +166,10 @@
 		os=-chorusos
 		basic_machine=$1
 		;;
-	-chorusrdb)
-		os=-chorusrdb
+ 	-chorusrdb)
+ 		os=-chorusrdb
 		basic_machine=$1
-		;;
+ 		;;
 	-hiux*)
 		os=-hiuxwe2
 		;;
@@ -218,12 +214,6 @@
 	-isc*)
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
-	-lynx*178)
-		os=-lynxos178
-		;;
-	-lynx*5)
-		os=-lynxos5
-		;;
 	-lynx*)
 		os=-lynxos
 		;;
@@ -248,90 +238,59 @@
 	# Some are omitted here because they have special meanings below.
 	1750a | 580 \
 	| a29k \
-	| aarch64 | aarch64_be \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
-	| arc | arceb \
-	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
-	| avr | avr32 \
-	| be32 | be64 \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
 	| bfin \
-	| c4x | c8051 | clipper \
+	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
-	| epiphany \
 	| fido | fr30 | frv \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
-	| hexagon \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
-	| k1om \
-	| le32 | le64 \
-	| lm32 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
+	| maxq | mb | microblaze | mcore | mep \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
-	| mips64octeon | mips64octeonel \
-	| mips64orion | mips64orionel \
-	| mips64r5900 | mips64r5900el \
 	| mips64vr | mips64vrel \
+	| mips64orion | mips64orionel \
 	| mips64vr4100 | mips64vr4100el \
 	| mips64vr4300 | mips64vr4300el \
 	| mips64vr5000 | mips64vr5000el \
 	| mips64vr5900 | mips64vr5900el \
 	| mipsisa32 | mipsisa32el \
 	| mipsisa32r2 | mipsisa32r2el \
-	| mipsisa32r6 | mipsisa32r6el \
 	| mipsisa64 | mipsisa64el \
 	| mipsisa64r2 | mipsisa64r2el \
-	| mipsisa64r6 | mipsisa64r6el \
 	| mipsisa64sb1 | mipsisa64sb1el \
 	| mipsisa64sr71k | mipsisa64sr71kel \
-	| mipsr5900 | mipsr5900el \
 	| mipstx39 | mipstx39el \
 	| mn10200 | mn10300 \
-	| moxie \
 	| mt \
 	| msp430 \
-	| nds32 | nds32le | nds32be \
-	| nios | nios2 | nios2eb | nios2el \
+	| nios | nios2 \
 	| ns16k | ns32k \
-	| open8 | or1k | or1knd | or32 \
+	| or32 \
 	| pdp10 | pdp11 | pj | pjl \
-	| powerpc | powerpc64 | powerpc64le | powerpcle \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
 	| pyramid \
-	| riscv32 | riscv64 \
-	| rl78 | rx \
 	| score \
-	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-	| spu \
-	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
-	| ubicom32 \
-	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
-	| visium \
+	| spu | strongarm \
+	| tahoe | thumb | tic4x | tic80 | tron \
+	| v850 | v850e \
 	| we32k \
-	| x86 | xc16x | xstormy16 | xtensa \
-	| z8k | z80)
+	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| z8k)
 		basic_machine=$basic_machine-unknown
 		;;
-	c54x)
-		basic_machine=tic54x-unknown
-		;;
-	c55x)
-		basic_machine=tic55x-unknown
-		;;
-	c6x)
-		basic_machine=tic6x-unknown
-		;;
-	leon|leon[3-9])
-		basic_machine=sparc-$basic_machine
-		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -341,21 +300,6 @@
 		basic_machine=mt-unknown
 		;;
 
-	strongarm | thumb | xscale)
-		basic_machine=arm-unknown
-		;;
-	xgate)
-		basic_machine=$basic_machine-unknown
-		os=-none
-		;;
-	xscaleeb)
-		basic_machine=armeb-unknown
-		;;
-
-	xscaleel)
-		basic_machine=armel-unknown
-		;;
-
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
@@ -370,83 +314,64 @@
 	# Recognize the basic CPU types with company name.
 	580-* \
 	| a29k-* \
-	| aarch64-* | aarch64_be-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* | avr32-* \
-	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
-	| c[123]* | c30-* | [cjt]90-* | c4x-* \
-	| c8051-* | clipper-* | craynv-* | cydra-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
-	| hexagon-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
-	| k1om-* \
-	| le32-* | le64-* \
-	| lm32-* \
 	| m32c-* | m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
-	| microblaze-* | microblazeel-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
-	| mips64octeon-* | mips64octeonel-* \
-	| mips64orion-* | mips64orionel-* \
-	| mips64r5900-* | mips64r5900el-* \
 	| mips64vr-* | mips64vrel-* \
+	| mips64orion-* | mips64orionel-* \
 	| mips64vr4100-* | mips64vr4100el-* \
 	| mips64vr4300-* | mips64vr4300el-* \
 	| mips64vr5000-* | mips64vr5000el-* \
 	| mips64vr5900-* | mips64vr5900el-* \
 	| mipsisa32-* | mipsisa32el-* \
 	| mipsisa32r2-* | mipsisa32r2el-* \
-	| mipsisa32r6-* | mipsisa32r6el-* \
 	| mipsisa64-* | mipsisa64el-* \
 	| mipsisa64r2-* | mipsisa64r2el-* \
-	| mipsisa64r6-* | mipsisa64r6el-* \
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
-	| mipsr5900-* | mipsr5900el-* \
 	| mipstx39-* | mipstx39el-* \
 	| mmix-* \
 	| mt-* \
 	| msp430-* \
-	| nds32-* | nds32le-* | nds32be-* \
-	| nios-* | nios2-* | nios2eb-* | nios2el-* \
+	| nios-* | nios2-* \
 	| none-* | np1-* | ns16k-* | ns32k-* \
-	| open8-* \
-	| or1k*-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
 	| pyramid-* \
-	| rl78-* | romp-* | rs6000-* | rx-* \
-	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+	| romp-* | rs6000-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
-	| tahoe-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+	| tahoe-* | thumb-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
-	| tile*-* \
 	| tron-* \
-	| ubicom32-* \
-	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
-	| vax-* \
-	| visium-* \
+	| v850-* | v850e-* | vax-* \
 	| we32k-* \
-	| x86-* | x86_64-* | xc16x-* | xps100-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
 	| xstormy16-* | xtensa*-* \
 	| ymp-* \
-	| z8k-* | z80-*)
+	| z8k-*)
 		;;
 	# Recognize the basic CPU types without company name, with glob match.
 	xtensa*)
@@ -468,7 +393,7 @@
 		basic_machine=a29k-amd
 		os=-udi
 		;;
-	abacus)
+    	abacus)
 		basic_machine=abacus-unknown
 		;;
 	adobe68k)
@@ -514,10 +439,6 @@
 		basic_machine=m68k-apollo
 		os=-bsd
 		;;
-	aros)
-		basic_machine=i386-pc
-		os=-aros
-		;;
 	aux)
 		basic_machine=m68k-apple
 		os=-aux
@@ -534,27 +455,10 @@
 		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
 		os=-linux
 		;;
-	bluegene*)
-		basic_machine=powerpc-ibm
-		os=-cnk
-		;;
-	c54x-*)
-		basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	c55x-*)
-		basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	c6x-*)
-		basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
 	c90)
 		basic_machine=c90-cray
 		os=-unicos
 		;;
-	cegcc)
-		basic_machine=arm-unknown
-		os=-cegcc
-		;;
 	convex-c1)
 		basic_machine=c1-convex
 		os=-bsd
@@ -583,7 +487,7 @@
 		basic_machine=craynv-cray
 		os=-unicosmp
 		;;
-	cr16 | cr16-*)
+	cr16)
 		basic_machine=cr16-unknown
 		os=-elf
 		;;
@@ -622,10 +526,6 @@
 		basic_machine=m88k-motorola
 		os=-sysv3
 		;;
-	dicos)
-		basic_machine=i686-pc
-		os=-dicos
-		;;
 	djgpp)
 		basic_machine=i586-pc
 		os=-msdosdjgpp
@@ -741,6 +641,7 @@
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
 		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i*86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
@@ -779,9 +680,6 @@
 		basic_machine=m68k-isi
 		os=-sysv
 		;;
-	leon-*|leon[3-9]-*)
-		basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
-		;;
 	m68knommu)
 		basic_machine=m68k-unknown
 		os=-linux
@@ -801,15 +699,8 @@
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
-	microblaze*)
-		basic_machine=microblaze-xilinx
-		;;
-	mingw64)
-		basic_machine=x86_64-pc
-		os=-mingw64
-		;;
 	mingw32)
-		basic_machine=i686-pc
+		basic_machine=i386-pc
 		os=-mingw32
 		;;
 	mingw32ce)
@@ -837,10 +728,6 @@
 		basic_machine=powerpc-unknown
 		os=-morphos
 		;;
-	moxiebox)
-		basic_machine=moxie-unknown
-		os=-moxiebox
-		;;
 	msdos)
 		basic_machine=i386-pc
 		os=-msdos
@@ -848,18 +735,10 @@
 	ms1-*)
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
-	msys)
-		basic_machine=i686-pc
-		os=-msys
-		;;
 	mvs)
 		basic_machine=i370-ibm
 		os=-mvs
 		;;
-	nacl)
-		basic_machine=le32-unknown
-		os=-nacl
-		;;
 	ncr3000)
 		basic_machine=i486-ncr
 		os=-sysv4
@@ -924,12 +803,6 @@
 	np1)
 		basic_machine=np1-gould
 		;;
-	neo-tandem)
-		basic_machine=neo-tandem
-		;;
-	nse-tandem)
-		basic_machine=nse-tandem
-		;;
 	nsr-tandem)
 		basic_machine=nsr-tandem
 		;;
@@ -1012,10 +885,9 @@
 		;;
 	power)	basic_machine=power-ibm
 		;;
-	ppc | ppcbe)	basic_machine=powerpc-unknown
+	ppc)	basic_machine=powerpc-unknown
 		;;
-	ppc-* | ppcbe-*)
-		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	ppcle | powerpclittle | ppc-le | powerpc-little)
 		basic_machine=powerpcle-unknown
@@ -1040,11 +912,7 @@
 		basic_machine=i586-unknown
 		os=-pw32
 		;;
-	rdos | rdos64)
-		basic_machine=x86_64-pc
-		os=-rdos
-		;;
-	rdos32)
+	rdos)
 		basic_machine=i386-pc
 		os=-rdos
 		;;
@@ -1113,9 +981,6 @@
 		basic_machine=i860-stratus
 		os=-sysv4
 		;;
-	strongarm-* | thumb-*)
-		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
 	sun2)
 		basic_machine=m68000-sun
 		;;
@@ -1172,8 +1037,20 @@
 		basic_machine=t90-cray
 		os=-unicos
 		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tic55x | c55x*)
+		basic_machine=tic55x-unknown
+		os=-coff
+		;;
+	tic6x | c6x*)
+		basic_machine=tic6x-unknown
+		os=-coff
+		;;
 	tile*)
-		basic_machine=$basic_machine-unknown
+		basic_machine=tile-unknown
 		os=-linux-gnu
 		;;
 	tx39)
@@ -1243,9 +1120,6 @@
 	xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
-	xscale-* | xscalee[bl]-*)
-		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
-		;;
 	ymp)
 		basic_machine=ymp-cray
 		os=-unicos
@@ -1254,10 +1128,6 @@
 		basic_machine=z8k-unknown
 		os=-sim
 		;;
-	z80-*-coff)
-		basic_machine=z80-unknown
-		os=-sim
-		;;
 	none)
 		basic_machine=none-none
 		os=-none
@@ -1296,7 +1166,7 @@
 	we32k)
 		basic_machine=we32k-att
 		;;
-	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+	sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
 		basic_machine=sh-unknown
 		;;
 	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
@@ -1343,12 +1213,9 @@
 if [ x"$os" != x"" ]
 then
 case $os in
-	# First match some system type aliases
-	# that might get confused with valid system types.
+        # First match some system type aliases
+        # that might get confused with valid system types.
 	# -solaris* is a basic system type, with this one exception.
-	-auroraux)
-		os=-auroraux
-		;;
 	-solaris1 | -solaris1.*)
 		os=`echo $os | sed -e 's|solaris1|sunos4|'`
 		;;
@@ -1369,31 +1236,29 @@
 	# Each alternative MUST END IN A *, to match a version number.
 	# -sysv* is not here because it comes later, after sysvr4.
 	-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* | -plan9* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
 	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-	      | -aos* | -aros* \
+	      | -aos* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
 	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-	      | -bitrig* | -openbsd* | -solidbsd* \
+	      | -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* | -mingw64* | -linux-gnu* | -linux-android* \
-	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
-	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
+	      | -chorusos* | -chorusrdb* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -uxpv* | -beos* | -mpeix* | -udk* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1432,7 +1297,7 @@
 	-opened*)
 		os=-openedition
 		;;
-	-os400*)
+        -os400*)
 		os=-os400
 		;;
 	-wince*)
@@ -1481,7 +1346,7 @@
 	-sinix*)
 		os=-sysv4
 		;;
-	-tpf*)
+        -tpf*)
 		os=-tpf
 		;;
 	-triton*)
@@ -1517,14 +1382,12 @@
 	-aros*)
 		os=-aros
 		;;
+	-kaos*)
+		os=-kaos
+		;;
 	-zvmoe)
 		os=-zvmoe
 		;;
-	-dicos*)
-		os=-dicos
-		;;
-	-nacl*)
-		;;
 	-none)
 		;;
 	*)
@@ -1547,10 +1410,10 @@
 # system, and we'll never get to this point.
 
 case $basic_machine in
-	score-*)
+        score-*)
 		os=-elf
 		;;
-	spu-*)
+        spu-*)
 		os=-elf
 		;;
 	*-acorn)
@@ -1562,23 +1425,8 @@
 	arm*-semi)
 		os=-aout
 		;;
-	c4x-* | tic4x-*)
-		os=-coff
-		;;
-	c8051-*)
-		os=-elf
-		;;
-	hexagon-*)
-		os=-elf
-		;;
-	tic54x-*)
-		os=-coff
-		;;
-	tic55x-*)
-		os=-coff
-		;;
-	tic6x-*)
-		os=-coff
+        c4x-* | tic4x-*)
+        	os=-coff
 		;;
 	# This must come before the *-dec entry.
 	pdp10-*)
@@ -1598,11 +1446,14 @@
 		;;
 	m68000-sun)
 		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
 		;;
 	m68*-cisco)
 		os=-aout
 		;;
-	mep-*)
+        mep-*)
 		os=-elf
 		;;
 	mips*-cisco)
@@ -1629,7 +1480,7 @@
 	*-ibm)
 		os=-aix
 		;;
-	*-knuth)
+    	*-knuth)
 		os=-mmixware
 		;;
 	*-wec)
@@ -1734,7 +1585,7 @@
 			-sunos*)
 				vendor=sun
 				;;
-			-cnk*|-aix*)
+			-aix*)
 				vendor=ibm
 				;;
 			-beos*)
diff --git a/configure b/configure
index f555122..afd225b 100755
--- a/configure
+++ b/configure
@@ -1,11 +1,13 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libmtp 1.1.12.
+# Generated by GNU Autoconf 2.68 for libmtp 1.1.5.
 #
 # Report bugs to <libmtp-discuss@lists.sourceforge.net>.
 #
 #
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+# Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -134,31 +136,6 @@
 # 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
@@ -192,8 +169,7 @@
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1
-test -x / || exit 1"
+test x\$exitcode = x0 || 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'\" &&
@@ -246,25 +222,21 @@
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  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
+  # 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+"$@"}
 fi
 
     if test x$as_have_required = xno; then :
@@ -367,14 +339,6 @@
 
 
 } # 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
@@ -496,10 +460,6 @@
   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).
@@ -534,16 +494,16 @@
     # ... 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 -pR'.
+    # In both cases, we have to default to `cp -p'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
+      as_ln_s='cp -p'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -pR'
+    as_ln_s='cp -p'
   fi
 else
-  as_ln_s='cp -pR'
+  as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -555,8 +515,28 @@
   as_mkdir_p=false
 fi
 
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
+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
 
 # 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'"
@@ -590,8 +570,8 @@
 # Identity of this package.
 PACKAGE_NAME='libmtp'
 PACKAGE_TARNAME='libmtp'
-PACKAGE_VERSION='1.1.12'
-PACKAGE_STRING='libmtp 1.1.12'
+PACKAGE_VERSION='1.1.5'
+PACKAGE_STRING='libmtp 1.1.5'
 PACKAGE_BUGREPORT='libmtp-discuss@lists.sourceforge.net'
 PACKAGE_URL=''
 
@@ -716,10 +696,6 @@
 LDFLAGS
 CFLAGS
 CC
-AM_BACKSLASH
-AM_DEFAULT_VERBOSITY
-AM_DEFAULT_V
-AM_V
 am__untar
 am__tar
 AMTAR
@@ -784,7 +760,6 @@
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
-enable_silent_rules
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1272,6 +1247,8 @@
 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
@@ -1357,7 +1334,7 @@
   # 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 libmtp 1.1.12 to adapt to many kinds of systems.
+\`configure' configures libmtp 1.1.5 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1427,7 +1404,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libmtp 1.1.12:";;
+     short | recursive ) echo "Configuration of libmtp 1.1.5:";;
    esac
   cat <<\_ACEOF
 
@@ -1435,19 +1412,15 @@
   --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]
-  --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
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
   --enable-shared[=PKGS]  build shared libraries [default=yes]
   --enable-static[=PKGS]  build static libraries [default=yes]
   --enable-fast-install[=PKGS]
                           optimize for fast installation [default=yes]
   --disable-libtool-lock  avoid locking (might break parallel builds)
   --disable-rpath         do not hardcode runtime library paths
-  --enable-doxygen        Build API documentation using Doxygen [default=auto]
+  --enable-doxygen        Build API documentation using Doxygen [default=no]
   --disable-mtpz          Disable functionality to connect to MTPZ devices
                           (e.g. Zune)
   --disable-largefile     omit support for large files
@@ -1460,11 +1433,11 @@
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-sysroot=DIR Search for dependent libraries within DIR
                         (or the compiler's sysroot if not specified).
-  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
   --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
   --without-libiconv-prefix     don't search for libiconv in includedir and libdir
   --with-udev=DIR         directory where udev is installed
-                          [default=/usr/lib/udev]
+                          [default=/lib/udev]
   --with-udev-rules=NAME  file name for udev rules [default=69-libmtp.rules]
   --with-udev-group=GROUP file group for device nodes [default: none
                           specified]
@@ -1554,10 +1527,10 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libmtp configure 1.1.12
-generated by GNU Autoconf 2.69
+libmtp configure 1.1.5
+generated by GNU Autoconf 2.68
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1633,7 +1606,7 @@
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 test -x conftest$ac_exeext
+	 $as_test_x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -2034,8 +2007,8 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libmtp $as_me 1.1.12, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+It was created by libmtp $as_me 1.1.5, which was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
 
@@ -2383,7 +2356,7 @@
 
 
 
-am__api_version='1.15'
+am__api_version='1.11'
 
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@@ -2451,7 +2424,7 @@
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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.
@@ -2509,6 +2482,9 @@
 
 { $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='
@@ -2519,40 +2495,32 @@
 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 (
-   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
+   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
-     if test "$2" = conftest.file || test $am_try -eq 2; then
-       break
-     fi
-     # Just in case.
-     sleep 1
-     am_has_slept=yes
-   done
+      # 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
+
    test "$2" = conftest.file
    )
 then
@@ -2564,16 +2532,6 @@
 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.
@@ -2584,8 +2542,8 @@
 ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
 program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 
-# Expand $ac_aux_dir to an absolute path.
-am_aux_dir=`cd "$ac_aux_dir" && pwd`
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
 
 if test x"${MISSING+set}" != xset; then
   case $am_aux_dir in
@@ -2596,15 +2554,15 @@
   esac
 fi
 # Use eval to expand $SHELL
-if eval "$MISSING --is-lightweight"; then
-  am_missing_run="$MISSING "
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
 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+set}" != xset; then
+if test x"${install_sh}" != xset; then
   case $am_aux_dir in
   *\ * | *\	*)
     install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@@ -2613,10 +2571,10 @@
   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.
@@ -2635,7 +2593,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -2675,7 +2633,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_STRIP="strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2726,7 +2684,7 @@
   test -z "$as_dir" && as_dir=.
     for ac_prog in mkdir gmkdir; do
 	 for ac_exec_ext in '' $ac_executable_extensions; do
-	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
+	   { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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) '* | \
@@ -2755,6 +2713,12 @@
 { $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.
@@ -2773,7 +2737,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -2837,45 +2801,6 @@
 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."
@@ -2898,7 +2823,7 @@
 
 # Define the identity of the package.
  PACKAGE='libmtp'
- VERSION='1.1.12'
+ VERSION='1.1.5'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2926,22 +2851,12 @@
 
 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 (and possibly the TAP driver).  The
-# system "awk" is bad on some platforms.
+# 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 -'
 
 
@@ -2949,49 +2864,6 @@
 
 
 
-# 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@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"
 
 
@@ -3018,7 +2890,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -3058,7 +2930,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3111,7 +2983,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -3152,7 +3024,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -3210,7 +3082,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -3254,7 +3126,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3700,7 +3572,8 @@
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-struct stat;
+#include <sys/types.h>
+#include <sys/stat.h>
 /* 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);
@@ -3784,65 +3657,6 @@
 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
-
 DEPDIR="${am__leading_dot}deps"
 
 ac_config_commands="$ac_config_commands depfiles"
@@ -3862,7 +3676,7 @@
 _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
@@ -3918,8 +3732,8 @@
   # 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
@@ -3954,16 +3768,16 @@
     : > 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 10 /bin/sh.
-      echo '/* dummy */' > sub/conftst$i.h
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch 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
@@ -3972,8 +3786,8 @@
       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
@@ -3981,7 +3795,7 @@
       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}
@@ -4139,7 +3953,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_AS="${ac_tool_prefix}as"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4179,7 +3993,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_AS="as"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4231,7 +4045,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -4271,7 +4085,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_DLLTOOL="dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4323,7 +4137,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -4363,7 +4177,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_OBJDUMP="objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4537,7 +4351,7 @@
     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"
-      as_fn_executable_p "$ac_path_SED" || continue
+      { test -f "$ac_path_SED" && $as_test_x "$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
@@ -4613,7 +4427,7 @@
     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"
-      as_fn_executable_p "$ac_path_GREP" || continue
+      { test -f "$ac_path_GREP" && $as_test_x "$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
@@ -4679,7 +4493,7 @@
     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"
-      as_fn_executable_p "$ac_path_EGREP" || continue
+      { test -f "$ac_path_EGREP" && $as_test_x "$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
@@ -4746,7 +4560,7 @@
     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"
-      as_fn_executable_p "$ac_path_FGREP" || continue
+      { test -f "$ac_path_FGREP" && $as_test_x "$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
@@ -5002,7 +4816,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -5046,7 +4860,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_DUMPBIN="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5459,7 +5273,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -5499,7 +5313,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_OBJDUMP="objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5802,7 +5616,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -5842,7 +5656,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_DLLTOOL="dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5943,7 +5757,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -5987,7 +5801,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6112,7 +5926,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -6152,7 +5966,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_STRIP="strip"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6211,7 +6025,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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
@@ -6251,7 +6065,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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
@@ -6743,7 +6557,7 @@
   rm -rf conftest*
   ;;
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
@@ -6761,10 +6575,7 @@
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_i386"
 	    ;;
-	  powerpc64le-*linux*)
-	    LD="${LD-ld} -m elf32lppclinux"
-	    ;;
-	  powerpc64-*linux*)
+	  ppc64-*linux*|powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -6783,10 +6594,7 @@
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*linux*)
-	    LD="${LD-ld} -m elf64lppc"
-	    ;;
-	  powerpc-*linux*)
+	  ppc*-*linux*|powerpc*-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -6906,7 +6714,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -6946,7 +6754,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_MANIFEST_TOOL="mt"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7026,7 +6834,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -7066,7 +6874,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_DSYMUTIL="dsymutil"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7118,7 +6926,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -7158,7 +6966,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_NMEDIT="nmedit"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7210,7 +7018,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -7250,7 +7058,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_LIPO="lipo"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7302,7 +7110,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -7342,7 +7150,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_OTOOL="otool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -7394,7 +7202,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -7434,7 +7242,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  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_OTOOL64="otool64"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -10934,10 +10742,14 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # Add ABI-specific directories to the system library path.
+  sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
@@ -11936,7 +11748,6 @@
   prefix="$acl_save_prefix"
 
 
-
 # Check whether --with-gnu-ld was given.
 if test "${with_gnu_ld+set}" = set; then :
   withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
@@ -11947,21 +11758,21 @@
 # Prepare PATH_SEPARATOR.
 # The user is always right.
 if test "${PATH_SEPARATOR+set}" != set; then
-  # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
-  # contains only /bin. Note that ksh looks also at the FPATH variable,
-  # so we have to set that as well for the test.
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
-    && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
-           || PATH_SEPARATOR=';'
-       }
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
 fi
-
 ac_prog=ld
 if test "$GCC" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
-$as_echo_n "checking for ld used by $CC... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
   case $host in
   *-*-mingw*)
     # gcc leaves a trailing carriage return which upsets mingw
@@ -11971,11 +11782,11 @@
   esac
   case $ac_prog in
     # Accept absolute paths.
-    [\\/]* | ?:[\\/]*)
+    [\\/]* | [A-Za-z]:[\\/]*)
       re_direlt='/[^/][^/]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
-      while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
       done
       test -z "$LD" && LD="$ac_prog"
@@ -12000,26 +11811,23 @@
   $as_echo_n "(cached) " >&6
 else
   if test -z "$LD"; then
-  acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
   for ac_dir in $PATH; do
-    IFS="$acl_save_ifs"
     test -z "$ac_dir" && ac_dir=.
     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
       acl_cv_path_LD="$ac_dir/$ac_prog"
       # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
+      # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
+      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
       *GNU* | *'with BFD'*)
-        test "$with_gnu_ld" != no && break
-        ;;
+        test "$with_gnu_ld" != no && break ;;
       *)
-        test "$with_gnu_ld" != yes && break
-        ;;
+        test "$with_gnu_ld" != yes && break ;;
       esac
     fi
   done
-  IFS="$acl_save_ifs"
+  IFS="$ac_save_ifs"
 else
   acl_cv_path_LD="$LD" # Let the user override the test with a path.
 fi
@@ -12039,14 +11847,12 @@
 if ${acl_cv_prog_gnu_ld+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
-  acl_cv_prog_gnu_ld=yes
-  ;;
+  acl_cv_prog_gnu_ld=yes ;;
 *)
-  acl_cv_prog_gnu_ld=no
-  ;;
+  acl_cv_prog_gnu_ld=no ;;
 esac
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
@@ -12229,7 +12035,7 @@
       done
       if test -z "$already_handled"; then
         names_already_handled="$names_already_handled $name"
-                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
         eval value=\"\$HAVE_LIB$uppername\"
         if test -n "$value"; then
           if test "$value" = yes; then
@@ -12872,7 +12678,7 @@
 
 
 # Optionally set install location of udev
-UDEV=/usr/lib/udev
+UDEV=/lib/udev
 
 # Check whether --with-udev was given.
 if test "${with_udev+set}" = set; then :
@@ -12925,7 +12731,7 @@
   ac_enable_doxygen=auto
 fi
 
-if test "x$ac_enable_doxygen" != "xno"; then
+if test "x$ac_enable_doxygen" == "xyes"; then
     # Extract the first word of "doxygen", so it can be a program name with args.
 set dummy doxygen; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -12942,7 +12748,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_HAVE_DOXYGEN="true"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -12967,10 +12773,8 @@
     if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$ac_enable_doxygen" = "xyes"; then
         as_fn_error $? "*** API documentation explicitly requested but Doxygen not found" "$LINENO" 5
     fi
-    if test "x$HAVE_DOXYGEN" = "xtrue"; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: API documentation will be generated using Doxygen" >&5
+    { $as_echo "$as_me:${as_lineno-$LINENO}: API documentation will be generated using Doxygen" >&5
 $as_echo "$as_me: API documentation will be generated using Doxygen" >&6;}
-    fi
 else
     HAVE_DOXYGEN=false
     { $as_echo "$as_me:${as_lineno-$LINENO}: API documentation will not be generated" >&5
@@ -13082,7 +12886,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ms_lib_exe="yes"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -13121,7 +12925,6 @@
 
 
 
-
 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
 	if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
@@ -13142,7 +12945,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -13185,7 +12988,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$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
@@ -13250,7 +13053,6 @@
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags "libusb-1.0 >= 1.0.0" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
 fi
@@ -13267,7 +13069,6 @@
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs "libusb-1.0 >= 1.0.0" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
 fi
@@ -13287,9 +13088,9 @@
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb-1.0 >= 1.0.0" 2>&1`
+	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libusb-1.0 >= 1.0.0" 2>&1`
         else
-	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb-1.0 >= 1.0.0" 2>&1`
+	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors "libusb-1.0 >= 1.0.0" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$LIBUSB_PKG_ERRORS" >&5
@@ -13356,7 +13157,6 @@
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags "libusb >= 0.1.8" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
 fi
@@ -13373,7 +13173,6 @@
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs "libusb >= 0.1.8" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
 fi
@@ -13393,9 +13192,9 @@
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb >= 0.1.8" 2>&1`
+	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libusb >= 0.1.8" 2>&1`
         else
-	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb >= 0.1.8" 2>&1`
+	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors "libusb >= 0.1.8" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$LIBUSB_PKG_ERRORS" >&5
@@ -13592,7 +13391,6 @@
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags "libusb >= 0.1.8" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
 fi
@@ -13609,7 +13407,6 @@
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; then
   pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs "libusb >= 0.1.8" 2>/dev/null`
-		      test "x$?" != "x0" && pkg_failed=yes
 else
   pkg_failed=yes
 fi
@@ -13629,9 +13426,9 @@
         _pkg_short_errors_supported=no
 fi
         if test $_pkg_short_errors_supported = yes; then
-	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb >= 0.1.8" 2>&1`
+	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libusb >= 0.1.8" 2>&1`
         else
-	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb >= 0.1.8" 2>&1`
+	        LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors "libusb >= 0.1.8" 2>&1`
         fi
 	# Put the nasty error message in config.log where it belongs
 	echo "$LIBUSB_PKG_ERRORS" >&5
@@ -14069,11 +13866,11 @@
 int
 main ()
 {
-
+/* FIXME: Include the comments suggested by Paul. */
 #ifndef __cplusplus
-  /* Ultrix mips cc rejects this sort of thing.  */
+  /* Ultrix mips cc rejects this.  */
   typedef int charset[2];
-  const charset cs = { 0, 0 };
+  const charset cs;
   /* SunOS 4.1.1 cc rejects this.  */
   char const *const *pcpcc;
   char **ppc;
@@ -14090,9 +13887,8 @@
   ++pcpcc;
   ppc = (char**) pcpcc;
   pcpcc = (char const *const *) ppc;
-  { /* SCO 3.2v4 cc rejects this sort of thing.  */
-    char tx;
-    char *t = &tx;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
     char const *s = 0 ? (char *) 0 : (char const *) 0;
 
     *t++ = 0;
@@ -14108,10 +13904,10 @@
     iptr p = 0;
     ++p;
   }
-  { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying
+  { /* AIX XL C 1.02.0.0 rejects this saying
        "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
-    struct s { int j; const int *ap[3]; } bx;
-    struct s *b = &bx; b->j = 5;
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
   }
   { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
     const int foo = 10;
@@ -14209,6 +14005,73 @@
 
 
 # Checks for library functions.
+for ac_header in stdlib.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_stdlib_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STDLIB_H 1
+_ACEOF
+
+fi
+
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5
+$as_echo_n "checking for GNU libc compatible malloc... " >&6; }
+if ${ac_cv_func_malloc_0_nonnull+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then :
+  ac_cv_func_malloc_0_nonnull=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+char *malloc ();
+#endif
+
+int
+main ()
+{
+return ! malloc (0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_func_malloc_0_nonnull=yes
+else
+  ac_cv_func_malloc_0_nonnull=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5
+$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; }
+if test $ac_cv_func_malloc_0_nonnull = yes; then :
+
+$as_echo "#define HAVE_MALLOC 1" >>confdefs.h
+
+else
+  $as_echo "#define HAVE_MALLOC 0" >>confdefs.h
+
+   case " $LIBOBJS " in
+  *" malloc.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS malloc.$ac_objext"
+ ;;
+esac
+
+
+$as_echo "#define malloc rpl_malloc" >>confdefs.h
+
+fi
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5
 $as_echo_n "checking for working memcmp... " >&6; }
 if ${ac_cv_func_memcmp_working+:} false; then :
@@ -14590,8 +14453,6 @@
 esac
 rm -rf conftest*
   fi
-
-
 fi
 
 # Stick in "-Werror" if you want to be more aggressive.
@@ -15672,6 +15533,7 @@
 
 ac_libobjs=
 ac_ltlibobjs=
+U=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
   ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
@@ -15686,14 +15548,6 @@
 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='#'
@@ -16045,16 +15899,16 @@
     # ... 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 -pR'.
+    # In both cases, we have to default to `cp -p'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
+      as_ln_s='cp -p'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -pR'
+    as_ln_s='cp -p'
   fi
 else
-  as_ln_s='cp -pR'
+  as_ln_s='cp -p'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -16114,16 +15968,28 @@
   as_mkdir_p=false
 fi
 
-
-# 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
+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
 
 # 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'"
@@ -16144,8 +16010,8 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libmtp $as_me 1.1.12, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
+This file was extended by libmtp $as_me 1.1.5, which was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -16210,11 +16076,11 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libmtp config.status 1.1.12
-configured by $0, generated by GNU Autoconf 2.69,
+libmtp config.status 1.1.5
+configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -16305,7 +16171,7 @@
 _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'
@@ -17227,7 +17093,7 @@
 
   case $ac_file$ac_mode in
     "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
-  # Older Autoconf quotes --file arguments for eval, but not when files
+  # Autoconf 2.62 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
@@ -17240,7 +17106,7 @@
     # 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.
@@ -17274,19 +17140,21 @@
       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'`; do
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/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 600105b..6fc47a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 # Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.52)
-AC_INIT([libmtp], [1.1.12], [libmtp-discuss@lists.sourceforge.net])
+AC_INIT([libmtp], [1.1.5], [libmtp-discuss@lists.sourceforge.net])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign])
 AC_CONFIG_SRCDIR([src/libmtp.c])
@@ -15,10 +15,10 @@
 AM_ICONV
 
 # Optionally set install location of udev
-UDEV=/usr/lib/udev
+UDEV=/lib/udev
 AC_ARG_WITH(udev,
     AC_HELP_STRING([--with-udev=DIR],
-    [directory where udev is installed [default=/usr/lib/udev]]),
+    [directory where udev is installed [default=/lib/udev]]),
     [UDEV="${withval}"], [])
 AC_SUBST(UDEV)
 
@@ -54,16 +54,14 @@
 
 # Optionally enable and check for doxygen
 AC_ARG_ENABLE([doxygen],
-    AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=auto]]),
+    AS_HELP_STRING([--enable-doxygen], [Build API documentation using Doxygen [default=no]]),
     [ac_enable_doxygen=$enableval], [ac_enable_doxygen=auto])
-if test "x$ac_enable_doxygen" != "xno"; then
+if test "x$ac_enable_doxygen" == "xyes"; then
     AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, true, false)
     if test "x$HAVE_DOXYGEN" = "xfalse" -a "x$ac_enable_doxygen" = "xyes"; then
         AC_MSG_ERROR([*** API documentation explicitly requested but Doxygen not found])
     fi
-    if test "x$HAVE_DOXYGEN" = "xtrue"; then
-        AC_MSG_NOTICE([API documentation will be generated using Doxygen])
-    fi
+    AC_MSG_NOTICE([API documentation will be generated using Doxygen])
 else
     HAVE_DOXYGEN=false
     AC_MSG_NOTICE([API documentation will not be generated])
@@ -188,6 +186,7 @@
 AC_STRUCT_ST_BLKSIZE
 
 # Checks for library functions.
+AC_FUNC_MALLOC
 AC_FUNC_MEMCMP
 AC_FUNC_STAT
 AC_CHECK_FUNCS(basename memset select strdup strerror strndup strrchr strtoul usleep mkstemp)
diff --git a/depcomp b/depcomp
index fc98710..bd0ac08 100755
--- a/depcomp
+++ b/depcomp
@@ -1,9 +1,10 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2013-05-30.07; # UTC
+scriptversion=2011-12-04.11; # UTC
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
+# 2011 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
@@ -27,9 +28,9 @@
 
 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]
@@ -39,8 +40,8 @@
 
 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.
@@ -56,66 +57,6 @@
     ;;
 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
@@ -128,9 +69,6 @@
 
 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
@@ -142,32 +80,26 @@
 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
-fi
-
-if test "$depmode" = xlc; then
-  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
-  gccflag=-qmakedep=gcc,-MF
-  depmode=gcc
+   # 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
 
 case "$depmode" in
@@ -190,7 +122,8 @@
   done
   "$@"
   stat=$?
-  if test $stat -ne 0; then
+  if test $stat -eq 0; then :
+  else
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -198,17 +131,13 @@
   ;;
 
 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).  Also, it might not be
-##   supported by the other compilers which use the 'gcc' depmode.
+##   -MM, not -M (despite what the docs say).
 ## - Using -M directly means running the compiler twice (even worse
 ##   than renaming).
   if test -z "$gccflag"; then
@@ -216,31 +145,33 @@
   fi
   "$@" -Wp,"$gccflag$tmpdepfile"
   stat=$?
-  if test $stat -ne 0; then
+  if test $stat -eq 0; then :
+  else
     rm -f "$tmpdepfile"
     exit $stat
   fi
   rm -f "$depfile"
   echo "$object : \\" > "$depfile"
-  # The second -e expression handles DOS-style file names with drive
-  # letters.
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## 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.
-## Some versions of gcc put a space before the ':'.  On the theory
+  tr ' ' '
+' < "$tmpdepfile" |
+## 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.
-  tr ' ' "$nl" < "$tmpdepfile" \
-    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
-    | sed -e 's/$/ :/' >> "$depfile"
+    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
+      | sed -e 's/$/ :/' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
 
@@ -258,7 +189,8 @@
     "$@" -MDupdate "$tmpdepfile"
   fi
   stat=$?
-  if test $stat -ne 0; then
+  if test $stat -eq 0; then :
+  else
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -266,41 +198,43 @@
 
   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 ' ' "$nl" < "$tmpdepfile" \
-      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
-      | tr "$nl" ' ' >> "$depfile"
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> "$depfile"
     echo >> "$depfile"
+
     # The second pass generates a dummy entry for each header file.
-    tr ' ' "$nl" < "$tmpdepfile" \
-      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
-      >> "$depfile"
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> "$depfile"
   else
-    make_dummy_depfile
+    # 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"
   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.
-  set_dir_from "$object"
-  set_base_from "$object"
+  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
     tmpdepfile1=$dir$base.u
     tmpdepfile2=$base.u
@@ -313,7 +247,9 @@
     "$@" -M
   fi
   stat=$?
-  if test $stat -ne 0; then
+
+  if test $stat -eq 0; then :
+  else
     rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
     exit $stat
   fi
@@ -322,100 +258,44 @@
   do
     test -f "$tmpdepfile" && break
   done
-  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
+  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"
   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"
   ;;
 
-## 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
+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
   #    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
-
-  if test $stat -ne 0; then
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -427,8 +307,8 @@
   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"
   ;;
 
@@ -439,8 +319,9 @@
   # '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.
-  set_dir_from  "$object"
-  set_base_from "$object"
+  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
     tmpdepfile1=$dir$base.d
     tmpdepfile2=$dir.libs/$base.d
@@ -451,7 +332,8 @@
     "$@" +Maked
   fi
   stat=$?
-  if test $stat -ne 0; then
+  if test $stat -eq 0; then :
+  else
      rm -f "$tmpdepfile1" "$tmpdepfile2"
      exit $stat
   fi
@@ -461,61 +343,77 @@
     test -f "$tmpdepfile" && break
   done
   if test -f "$tmpdepfile"; then
-    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
-    # Add 'dependent.h:' lines.
+    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+    # Add `dependent.h:' lines.
     sed -ne '2,${
-               s/^ *//
-               s/ \\*$//
-               s/$/:/
-               p
-             }' "$tmpdepfile" >> "$depfile"
+	       s/^ *//
+	       s/ \\*$//
+	       s/$/:/
+	       p
+	     }' "$tmpdepfile" >> "$depfile"
   else
-    make_dummy_depfile
+    echo "#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.
-  set_dir_from  "$object"
-  set_base_from "$object"
+   # 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
-    # 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
+   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 -ne 0; then
-    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
-    exit $stat
-  fi
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      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
-  ;;
+   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"
+   ;;
 
 msvc7)
   if test "$libtool" = yes; then
@@ -526,7 +424,8 @@
   "$@" $showIncludes > "$tmpdepfile"
   stat=$?
   grep -v '^Note: including file: ' "$tmpdepfile"
-  if test $stat -ne 0; then
+  if test "$stat" = 0; then :
+  else
     rm -f "$tmpdepfile"
     exit $stat
   fi
@@ -544,15 +443,14 @@
   p
 }' | $cygpath_u | sort -u | sed -n '
 s/ /\\ /g
-s/\(.*\)/'"$tab"'\1 \\/p
+s/\(.*\)/	\1 \\/p
 s/.\(.*\) \\/\1:/
 H
 $ {
-  s/.*/'"$tab"'/
+  s/.*/	/
   G
   p
 }' >> "$depfile"
-  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
   rm -f "$tmpdepfile"
   ;;
 
@@ -580,7 +478,7 @@
     shift
   fi
 
-  # Remove '-o $object'.
+  # Remove `-o $object'.
   IFS=" "
   for arg
   do
@@ -600,18 +498,18 @@
   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|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
   rm -f "$depfile"
   cat < "$tmpdepfile" > "$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"
+  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"
   rm -f "$tmpdepfile"
   ;;
 
@@ -664,12 +562,11 @@
   # 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"
-  # 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"
+  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"
   rm -f "$tmpdepfile" "$tmpdepfile".bak
   ;;
 
@@ -686,7 +583,7 @@
     shift
   fi
 
-  # Remove '-o $object'.
+  # Remove `-o $object'.
   IFS=" "
   for arg
   do
@@ -705,10 +602,10 @@
     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"
@@ -740,23 +637,23 @@
       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::'"$tab"'\1 \\:p' >> "$depfile"
-  echo "$tab" >> "$depfile"
+  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
+  echo "	" >> "$depfile"
   sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
   rm -f "$tmpdepfile"
   ;;
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 962b190..569107c 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
-
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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.
@@ -14,61 +15,6 @@
 
 @SET_MAKE@
 VPATH = @srcdir@
-am__is_gnu_make = { \
-  if test -z '$(MAKELEVEL)'; then \
-    false; \
-  elif test -n '$(MAKE_HOST)'; then \
-    true; \
-  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
-    true; \
-  else \
-    false; \
-  fi; \
-}
-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@
@@ -88,6 +34,8 @@
 build_triplet = @build@
 host_triplet = @host@
 subdir = doc
+DIST_COMMON = $(srcdir)/Doxyfile.in $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/byteorder.m4 \
 	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/libtool.m4 \
@@ -96,36 +44,15 @@
 	$(top_srcdir)/m4/stdint.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Doxyfile
 CONFIG_CLEAN_VPATH_FILES =
-AM_V_P = $(am__v_P_@AM_V@)
-am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
-am__v_P_0 = false
-am__v_P_1 = :
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo "  GEN     " $@;
-am__v_GEN_1 = 
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_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)
-am__DIST_COMMON = $(srcdir)/Doxyfile.in $(srcdir)/Makefile.in
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AS = @AS@
 AUTOCONF = @AUTOCONF@
@@ -272,6 +199,7 @@
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign doc/Makefile
+.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -297,11 +225,11 @@
 
 clean-libtool:
 	-rm -rf .libs _libs
-tags TAGS:
+tags: TAGS
+TAGS:
 
-ctags CTAGS:
-
-cscope cscopelist:
+ctags: CTAGS
+CTAGS:
 
 
 distdir: $(DISTFILES)
@@ -370,8 +298,8 @@
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
 @HAVE_DOXYGEN_FALSE@uninstall-local:
-@HAVE_DOXYGEN_FALSE@clean-local:
 @HAVE_DOXYGEN_FALSE@install-data-local:
+@HAVE_DOXYGEN_FALSE@clean-local:
 clean: clean-am
 
 clean-am: clean-generic clean-libtool clean-local mostlyclean-am
@@ -441,19 +369,17 @@
 .MAKE: install-am install-strip
 
 .PHONY: all all-am all-local check check-am clean clean-generic \
-	clean-libtool clean-local 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-data-local 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 \
+	clean-libtool clean-local distclean distclean-generic \
+	distclean-libtool distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am \
+	install-data-local 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 uninstall-local
-
-.PRECIOUS: Makefile
+	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
+	uninstall-local
 
 
 @HAVE_DOXYGEN_TRUE@all-local:
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 85e1a8b..d1b2fcd 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
-
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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,61 +16,6 @@
 @SET_MAKE@
 
 VPATH = @srcdir@
-am__is_gnu_make = { \
-  if test -z '$(MAKELEVEL)'; then \
-    false; \
-  elif test -n '$(MAKE_HOST)'; then \
-    true; \
-  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
-    true; \
-  else \
-    false; \
-  fi; \
-}
-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@
@@ -96,6 +42,7 @@
 	mtp-emptyfolders$(EXEEXT) \
 	mtp-thumb$(EXEEXT) mtp-reset$(EXEEXT) mtp-filetree$(EXEEXT)
 subdir = examples
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/byteorder.m4 \
 	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/libtool.m4 \
@@ -104,7 +51,6 @@
 	$(top_srcdir)/m4/stdint.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
@@ -115,10 +61,6 @@
 mtp_albumart_OBJECTS = $(am_mtp_albumart_OBJECTS)
 mtp_albumart_LDADD = $(LDADD)
 mtp_albumart_DEPENDENCIES = ../src/libmtp.la
-AM_V_lt = $(am__v_lt_@AM_V@)
-am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
-am__v_lt_0 = --silent
-am__v_lt_1 = 
 am_mtp_albums_OBJECTS = albums.$(OBJEXT) util.$(OBJEXT)
 mtp_albums_OBJECTS = $(am_mtp_albums_OBJECTS)
 mtp_albums_LDADD = $(LDADD)
@@ -169,40 +111,19 @@
 mtp_trexist_OBJECTS = $(am_mtp_trexist_OBJECTS)
 mtp_trexist_LDADD = $(LDADD)
 mtp_trexist_DEPENDENCIES = ../src/libmtp.la
-AM_V_P = $(am__v_P_@AM_V@)
-am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
-am__v_P_0 = false
-am__v_P_1 = :
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo "  GEN     " $@;
-am__v_GEN_1 = 
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
-am__v_at_0 = @
-am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
-	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
-	$(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_@AM_V@)
-am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
-am__v_CC_0 = @echo "  CC      " $@;
-am__v_CC_1 = 
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_@AM_V@)
-am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
-am__v_CCLD_0 = @echo "  CCLD    " $@;
-am__v_CCLD_1 = 
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
 SOURCES = $(mtp_albumart_SOURCES) $(mtp_albums_SOURCES) \
 	$(mtp_connect_SOURCES) $(mtp_detect_SOURCES) \
 	$(mtp_emptyfolders_SOURCES) $(mtp_files_SOURCES) \
@@ -217,35 +138,11 @@
 	$(mtp_format_SOURCES) \
 	$(mtp_reset_SOURCES) $(mtp_thumb_SOURCES) \
 	$(mtp_tracks_SOURCES) $(mtp_trexist_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__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AS = @AS@
 AUTOCONF = @AUTOCONF@
@@ -409,6 +306,7 @@
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign examples/Makefile
+.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -428,19 +326,14 @@
 $(am__aclocal_m4_deps):
 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 } \
@@ -461,8 +354,7 @@
 	@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
@@ -475,58 +367,45 @@
 	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
 	echo " rm -f" $$list; \
 	rm -f $$list
-
 mtp-albumart$(EXEEXT): $(mtp_albumart_OBJECTS) $(mtp_albumart_DEPENDENCIES) $(EXTRA_mtp_albumart_DEPENDENCIES) 
 	@rm -f mtp-albumart$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_albumart_OBJECTS) $(mtp_albumart_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_albumart_OBJECTS) $(mtp_albumart_LDADD) $(LIBS)
 mtp-albums$(EXEEXT): $(mtp_albums_OBJECTS) $(mtp_albums_DEPENDENCIES) $(EXTRA_mtp_albums_DEPENDENCIES) 
 	@rm -f mtp-albums$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_albums_OBJECTS) $(mtp_albums_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_albums_OBJECTS) $(mtp_albums_LDADD) $(LIBS)
 mtp-connect$(EXEEXT): $(mtp_connect_OBJECTS) $(mtp_connect_DEPENDENCIES) $(EXTRA_mtp_connect_DEPENDENCIES) 
 	@rm -f mtp-connect$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_connect_OBJECTS) $(mtp_connect_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_connect_OBJECTS) $(mtp_connect_LDADD) $(LIBS)
 mtp-detect$(EXEEXT): $(mtp_detect_OBJECTS) $(mtp_detect_DEPENDENCIES) $(EXTRA_mtp_detect_DEPENDENCIES) 
 	@rm -f mtp-detect$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_detect_OBJECTS) $(mtp_detect_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_detect_OBJECTS) $(mtp_detect_LDADD) $(LIBS)
 mtp-emptyfolders$(EXEEXT): $(mtp_emptyfolders_OBJECTS) $(mtp_emptyfolders_DEPENDENCIES) $(EXTRA_mtp_emptyfolders_DEPENDENCIES) 
 	@rm -f mtp-emptyfolders$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_emptyfolders_OBJECTS) $(mtp_emptyfolders_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_emptyfolders_OBJECTS) $(mtp_emptyfolders_LDADD) $(LIBS)
 mtp-files$(EXEEXT): $(mtp_files_OBJECTS) $(mtp_files_DEPENDENCIES) $(EXTRA_mtp_files_DEPENDENCIES) 
 	@rm -f mtp-files$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_files_OBJECTS) $(mtp_files_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_files_OBJECTS) $(mtp_files_LDADD) $(LIBS)
 mtp-filetree$(EXEEXT): $(mtp_filetree_OBJECTS) $(mtp_filetree_DEPENDENCIES) $(EXTRA_mtp_filetree_DEPENDENCIES) 
 	@rm -f mtp-filetree$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_filetree_OBJECTS) $(mtp_filetree_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_filetree_OBJECTS) $(mtp_filetree_LDADD) $(LIBS)
 mtp-folders$(EXEEXT): $(mtp_folders_OBJECTS) $(mtp_folders_DEPENDENCIES) $(EXTRA_mtp_folders_DEPENDENCIES) 
 	@rm -f mtp-folders$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_folders_OBJECTS) $(mtp_folders_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_folders_OBJECTS) $(mtp_folders_LDADD) $(LIBS)
 mtp-format$(EXEEXT): $(mtp_format_OBJECTS) $(mtp_format_DEPENDENCIES) $(EXTRA_mtp_format_DEPENDENCIES) 
 	@rm -f mtp-format$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_format_OBJECTS) $(mtp_format_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_format_OBJECTS) $(mtp_format_LDADD) $(LIBS)
 mtp-reset$(EXEEXT): $(mtp_reset_OBJECTS) $(mtp_reset_DEPENDENCIES) $(EXTRA_mtp_reset_DEPENDENCIES) 
 	@rm -f mtp-reset$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_reset_OBJECTS) $(mtp_reset_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_reset_OBJECTS) $(mtp_reset_LDADD) $(LIBS)
 mtp-thumb$(EXEEXT): $(mtp_thumb_OBJECTS) $(mtp_thumb_DEPENDENCIES) $(EXTRA_mtp_thumb_DEPENDENCIES) 
 	@rm -f mtp-thumb$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_thumb_OBJECTS) $(mtp_thumb_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_thumb_OBJECTS) $(mtp_thumb_LDADD) $(LIBS)
 mtp-tracks$(EXEEXT): $(mtp_tracks_OBJECTS) $(mtp_tracks_DEPENDENCIES) $(EXTRA_mtp_tracks_DEPENDENCIES) 
 	@rm -f mtp-tracks$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_tracks_OBJECTS) $(mtp_tracks_LDADD) $(LIBS)
-
+	$(LINK) $(mtp_tracks_OBJECTS) $(mtp_tracks_LDADD) $(LIBS)
 mtp-trexist$(EXEEXT): $(mtp_trexist_OBJECTS) $(mtp_trexist_DEPENDENCIES) $(EXTRA_mtp_trexist_DEPENDENCIES) 
 	@rm -f mtp-trexist$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(mtp_trexist_OBJECTS) $(mtp_trexist_LDADD) $(LIBS)
+	$(LINK) $(mtp_trexist_OBJECTS) $(mtp_trexist_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -556,25 +435,25 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@
 
 .c.o:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
 
 .c.obj:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
 
 .c.lo:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -582,15 +461,26 @@
 clean-libtool:
 	-rm -rf .libs _libs
 
-ID: $(am__tagged_files)
-	$(am__define_uniq_tagged_files); mkid -fID $$unique
-tags: tags-am
-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-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	set x; \
 	here=`pwd`; \
-	$(am__define_uniq_tagged_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; }; }'`; \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -602,11 +492,15 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: ctags-am
-
-CTAGS: ctags
-ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
-	$(am__define_uniq_tagged_files); \
+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; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -615,21 +509,6 @@
 	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
@@ -774,22 +653,19 @@
 
 .MAKE: install-am install-exec-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
-	clean-binPROGRAMS clean-generic 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-exec-hook 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-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
-	uninstall-binPROGRAMS
-
-.PRECIOUS: Makefile
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic 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-exec-hook \
+	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-compile mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am uninstall-binPROGRAMS
 
 
 install-exec-hook:
diff --git a/examples/albumart.c b/examples/albumart.c
index 350ba45..c98b305 100644
--- a/examples/albumart.c
+++ b/examples/albumart.c
@@ -55,7 +55,6 @@
   struct stat statbuff;
   uint32_t storageid = 0;
   uint32_t parentid = 0;
-  int ret;
 
   fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
 
@@ -125,8 +124,7 @@
     return 1;
   }
   else {
-    ret = read(fd, imagedata, filesize);
-    if (ret == -1) perror("read");
+    read(fd, imagedata, filesize);
     close(fd);
   }
 
@@ -148,8 +146,7 @@
   album->tracks = ids;
   album->parent_id = parentid;
   album->storage_id = storageid;
-
-  ret = LIBMTP_Create_New_Album(device,album);
+  int ret = LIBMTP_Create_New_Album(device,album);
   if (ret == 0) {
     ret = LIBMTP_Send_Representative_Sample(device,album->album_id, albumart);
     if (ret != 0) {
diff --git a/examples/albums.c b/examples/albums.c
index 23c8d59..4905467 100644
--- a/examples/albums.c
+++ b/examples/albums.c
@@ -34,44 +34,8 @@
   printf("    Tracks: %d\n\n",album->no_tracks);
 }
 
-static void
-dump_albums(LIBMTP_mtpdevice_t *device, uint32_t storageid, int leaf)
-{
-  LIBMTP_file_t *files;
-
-  /* Get file listing. */
-  files = LIBMTP_Get_Files_And_Folders(device,
-				       storageid,
-				       leaf);
-  if (files == NULL) {
-    LIBMTP_Dump_Errorstack(device);
-    LIBMTP_Clear_Errorstack(device);
-  } else {
-    LIBMTP_file_t *file, *tmp;
-    file = files;
-    while (file != NULL) {
-      /* Please don't print these */
-      if (file->filetype == LIBMTP_FILETYPE_FOLDER) {
-	dump_albums(device, storageid, file->item_id);
-      } else if (file->filetype == LIBMTP_FILETYPE_ALBUM) {
-	LIBMTP_album_t *album;
-
-	album = LIBMTP_Get_Album(device, file->item_id);
-	dump_albuminfo(album);
-	LIBMTP_destroy_album_t(album);
-      }
-      tmp = file;
-      file = file->next;
-      LIBMTP_destroy_file_t(tmp);
-    }
-  }
-}
-
 int main (int argc, char *argv[]) {
-  LIBMTP_raw_device_t *rawdevices;
-  int numrawdevices;
-  LIBMTP_error_number_t err;
-  int i;
+  LIBMTP_mtpdevice_t *device_list, *device;
 
   int opt;
   extern int optind;
@@ -92,8 +56,7 @@
 
   fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
 
-  err = LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
-  switch(err)
+  switch(LIBMTP_Get_Connected_Devices(&device_list))
   {
   case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
     fprintf(stdout, "mtp-albums: No Devices have been found\n");
@@ -116,20 +79,13 @@
   case LIBMTP_ERROR_NONE:
     fprintf(stdout, "mtp-albums: Successfully connected\n");
     fflush(stdout);
-    break;
   }
 
   /* iterate through connected MTP devices */
-  for (i = 0; i < numrawdevices; i++) {
-    LIBMTP_mtpdevice_t *device;
-    LIBMTP_devicestorage_t *storage;
+  for(device = device_list; device != NULL; device = device->next)
+  {
     char *friendlyname;
-
-    device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
-    if (device == NULL) {
-      fprintf(stderr, "Unable to open raw device %d\n", i);
-      continue;
-    }
+    LIBMTP_album_t *album_list, *album, *tmp;
 
     /* Echo the friendly name so we know which device we are working with */
     friendlyname = LIBMTP_Get_Friendlyname(device);
@@ -140,18 +96,18 @@
       free(friendlyname);
     }
 
-    LIBMTP_Dump_Errorstack(device);
-    LIBMTP_Clear_Errorstack(device);
-
-    /* Loop over storages */
-    for (storage = device->storage; storage != 0; storage = storage->next) {
-      dump_albums(device, storage->id, 0);
+    album_list = LIBMTP_Get_Album_List(device);
+    album = album_list;
+    while(album != NULL)
+    {
+      dump_albuminfo(album);
+      tmp = album;
+      album = album->next;
+      LIBMTP_destroy_album_t(tmp);
     }
-    LIBMTP_Release_Device(device);
   }
 
-  free(rawdevices);
-
+  LIBMTP_Release_Device_List(device_list);
   printf("OK.\n");
   return 0;
 }
diff --git a/examples/detect.c b/examples/detect.c
index 220f92e..92e43b8 100644
--- a/examples/detect.c
+++ b/examples/detect.c
@@ -2,7 +2,7 @@
  * \file detect.c
  * Example program to detect a device and list capabilities.
  *
- * Copyright (C) 2005-2015 Linus Walleij <triad@df.lth.se>
+ * Copyright (C) 2005-2008 Linus Walleij <triad@df.lth.se>
  * Copyright (C) 2007 Ted Bullock <tbullock@canada.com>
  *
  * This library is free software; you can redistribute it and/or
@@ -130,7 +130,7 @@
   fprintf(stdout, "Attempting to connect device(s)\n");
   for (i = 0; i < numrawdevices; i++) {
     LIBMTP_mtpdevice_t *device;
-    LIBMTP_devicestorage_t *storage;
+    LIBMTP_file_t *files;
     char *friendlyname;
     char *syncpartner;
     char *sectime;
@@ -141,7 +141,7 @@
     uint8_t currbattlevel;
     int ret;
 
-    device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
+    device = LIBMTP_Open_Raw_Device(&rawdevices[i]);
     if (device == NULL) {
       fprintf(stderr, "Unable to open raw device %d\n", i);
       continue;
@@ -203,43 +203,34 @@
     }
 
     // Device certificate XML fragment
-    if (rawdevices[i].device_entry.vendor_id == 0x041e) {
-      /*
-       * This code is currently disabled except for vendors we
-       * know does support it: all devices say that
-       * they support getting a device certificate but a lot of
-       * them obviously doesn't, instead they crash when you try
-       * to obtain it.
-       */
-      ret = LIBMTP_Get_Device_Certificate(device, &devcert);
-      if (ret == 0 && devcert != NULL) {
-	fprintf(stdout, "\nDevice Certificate:\n%s\n", devcert);
-	free(devcert);
-      } else {
-	fprintf(stdout, "Unable to acquire device certificate, perhaps this device "
-		"does not support this\n");
-	LIBMTP_Dump_Errorstack(device);
-	LIBMTP_Clear_Errorstack(device);
-      }
+#if 0
+    /*
+     * This code is currently disabled: all devices say that
+     * they support getting a device certificate but a lot of
+     * them obviously doesn't, instead they crash when you try
+     * to obtain it.
+     */
+    ret = LIBMTP_Get_Device_Certificate(device, &devcert);
+    if (ret == 0 && devcert != NULL) {
+      fprintf(stdout, "\nDevice Certificate:\n%s\n", devcert);
+      free(devcert);
+    } else {
+      fprintf(stdout, "Unable to acquire device certificate, perhaps this device "
+	      "does not support this\n");
+      LIBMTP_Dump_Errorstack(device);
+      LIBMTP_Clear_Errorstack(device);
     }
+#endif
 
-    /* Try to get Media player device info XML file... */
-    /* Loop over storages */
-    for (storage = device->storage; storage != 0; storage = storage->next) {
-      LIBMTP_file_t *files;
-
-      /* Get file listing for the root directory, no other dirs */
-      files = LIBMTP_Get_Files_And_Folders(device,
-					   storage->id,
-					   0);
-
-      if (files != NULL) {
-	LIBMTP_file_t *file, *tmp;
-	file = files;
-	while (file != NULL) {
-	  if (!strcmp(file->filename, "WMPInfo.xml") ||
-	      !strcmp(file->filename, "WMPinfo.xml") ||
-	      !strcmp(file->filename, "default-capabilities.xml")) {
+    // Try to get Media player device info XML file...
+    files = LIBMTP_Get_Filelisting_With_Callback(device, NULL, NULL);
+    if (files != NULL) {
+      LIBMTP_file_t *file, *tmp;
+      file = files;
+      while (file != NULL) {
+	if (!strcmp(file->filename, "WMPInfo.xml") ||
+	    !strcmp(file->filename, "WMPinfo.xml") ||
+	    !strcmp(file->filename, "default-capabilities.xml")) {
 	    if (file->item_id != 0) {
 	      /* Dump this file */
 	      FILE *xmltmp = tmpfile();
@@ -283,11 +274,10 @@
 		fclose(xmltmp);
 	      }
 	    }
-	  }
-	  tmp = file;
-	  file = file->next;
-	  LIBMTP_destroy_file_t(tmp);
 	}
+	tmp = file;
+	file = file->next;
+	LIBMTP_destroy_file_t(tmp);
       }
     }
     LIBMTP_Release_Device(device);
diff --git a/examples/files.c b/examples/files.c
index 8c3e586..11b0c04 100644
--- a/examples/files.c
+++ b/examples/files.c
@@ -46,48 +46,16 @@
   printf("   Filetype: %s\n", LIBMTP_Get_Filetype_Description(file->filetype));
 }
 
-static void
-dump_files(LIBMTP_mtpdevice_t *device, uint32_t storageid, int leaf)
+int main (int argc, char **argv)
 {
+  LIBMTP_mtpdevice_t *device_list, *device;
   LIBMTP_file_t *files;
 
-  /* Get file listing. */
-  files = LIBMTP_Get_Files_And_Folders(device,
-				       storageid,
-				       leaf);
-  if (files == NULL) {
-    LIBMTP_Dump_Errorstack(device);
-    LIBMTP_Clear_Errorstack(device);
-  } else {
-    LIBMTP_file_t *file, *tmp;
-    file = files;
-    while (file != NULL) {
-      /* Please don't print these */
-      if (file->filetype == LIBMTP_FILETYPE_FOLDER) {
-	dump_files(device, storageid, file->item_id);
-      } else {
-	dump_fileinfo(file);
-      }
-      tmp = file;
-      file = file->next;
-      LIBMTP_destroy_file_t(tmp);
-    }
-  }
-}
-
-int main(int argc, char **argv)
-{
-  LIBMTP_raw_device_t *rawdevices;
-  int numrawdevices;
-  LIBMTP_error_number_t err;
-  int i;
-
   fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
 
   LIBMTP_Init();
 
-  err = LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
-  switch(err)
+  switch(LIBMTP_Get_Connected_Devices(&device_list))
   {
   case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
     fprintf(stdout, "mtp-files: No Devices have been found\n");
@@ -104,27 +72,19 @@
   default:
     fprintf(stderr, "mtp-files: Unknown error, please report "
                     "this to the libmtp developers\n");
-    return 1;
+  return 1;
 
   /* Successfully connected at least one device, so continue */
   case LIBMTP_ERROR_NONE:
     fprintf(stdout, "mtp-files: Successfully connected\n");
     fflush(stdout);
-    break;
   }
 
   /* iterate through connected MTP devices */
-  for (i = 0; i < numrawdevices; i++) {
-    LIBMTP_mtpdevice_t *device;
-    LIBMTP_devicestorage_t *storage;
+  for(device = device_list; device != NULL; device = device->next)
+  {
     char *friendlyname;
 
-    device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
-    if (device == NULL) {
-      fprintf(stderr, "Unable to open raw device %d\n", i);
-      continue;
-    }
-
     /* Echo the friendly name so we know which device we are working with */
     friendlyname = LIBMTP_Get_Friendlyname(device);
     if (friendlyname == NULL) {
@@ -134,18 +94,25 @@
       free(friendlyname);
     }
 
-    LIBMTP_Dump_Errorstack(device);
-    LIBMTP_Clear_Errorstack(device);
-
-    /* Loop over storages */
-    for (storage = device->storage; storage != 0; storage = storage->next) {
-      dump_files(device, storage->id, 0);
-    }
-    LIBMTP_Release_Device(device);
+	  /* Get track listing. */
+	  files = LIBMTP_Get_Filelisting_With_Callback(device, NULL, NULL);
+	  if (files == NULL) {
+	    printf("No files.\n");
+	    LIBMTP_Dump_Errorstack(device);
+	    LIBMTP_Clear_Errorstack(device);
+	  } else {
+	    LIBMTP_file_t *file, *tmp;
+	    file = files;
+	    while (file != NULL) {
+	      dump_fileinfo(file);
+	      tmp = file;
+	      file = file->next;
+	      LIBMTP_destroy_file_t(tmp);
+      }
+	  }
   }
 
-  free(rawdevices);
-
+  LIBMTP_Release_Device_List(device_list);
   printf("OK.\n");
   exit (0);
 }
diff --git a/examples/filetree.c b/examples/filetree.c
index 234d093..6d6ed81 100644
--- a/examples/filetree.c
+++ b/examples/filetree.c
@@ -49,10 +49,8 @@
   }
 
   /* Iterate over the filelisting */
-  file = files;
-  while (file != NULL) {
+  for (file = files; file != NULL; file = file->next) {
     int i;
-    LIBMTP_file_t *oldfile;
 
     /* Indent */
     for (i = 0; i < depth; i++) {
@@ -62,10 +60,6 @@
     if (file->filetype == LIBMTP_FILETYPE_FOLDER) {
       recursive_file_tree(device, storage, file->item_id, depth+2);
     }
-
-    oldfile = file;
-    file = file->next;
-    LIBMTP_destroy_file_t(oldfile);
   }
 }
 
diff --git a/examples/folders.c b/examples/folders.c
index 34ea9ce..f139343 100644
--- a/examples/folders.c
+++ b/examples/folders.c
@@ -41,14 +41,13 @@
 
 int main (int argc, char **argv)
 {
-  LIBMTP_raw_device_t *rawdevices;
-  int numrawdevices;
-  int i;
+  LIBMTP_mtpdevice_t *device_list, *device;
 
   LIBMTP_Init();
   printf("Attempting to connect device(s)\n");
 
-  switch (LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices)) {
+  switch(LIBMTP_Get_Connected_Devices(&device_list))
+  {
   case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
     printf("mtp-folders: no devices found\n");
     return 0;
@@ -64,7 +63,7 @@
   default:
     fprintf(stderr, "mtp-folders: Unknown error, please report "
                     "this to the libmtp developers\n");
-    return 1;
+  return 1;
 
   /* Successfully connected at least one device, so continue */
   case LIBMTP_ERROR_NONE:
@@ -72,18 +71,12 @@
   }
 
   /* iterate through connected MTP devices */
-  for (i = 0; i < numrawdevices; i++) {
-    LIBMTP_mtpdevice_t *device;
+  for(device = device_list; device != NULL; device = device->next)
+  {
     LIBMTP_devicestorage_t *storage;
     char *friendlyname;
     int ret;
 
-    device = LIBMTP_Open_Raw_Device(&rawdevices[i]);
-    if (device == NULL) {
-      fprintf(stderr, "Unable to open raw device %d\n", i);
-      continue;
-    }
-
     /* Echo the friendly name so we know which device we are working with */
     friendlyname = LIBMTP_Get_Friendlyname(device);
     if (friendlyname == NULL) {
@@ -121,10 +114,9 @@
       }
       LIBMTP_destroy_folder_t(folders);
     }
-    LIBMTP_Release_Device(device);
   }
 
-  free(rawdevices);
+  LIBMTP_Release_Device_List(device_list);
   printf("OK.\n");
 
   return 0;
diff --git a/examples/sendtr.c b/examples/sendtr.c
index a608d15..8c4b1b5 100644
--- a/examples/sendtr.c
+++ b/examples/sendtr.c
@@ -186,7 +186,6 @@
 {
   char *filename, *parent;
   char artist[80], albumartist[80], title[80], genre[80], album[80], composer[80];
-  char *to_path_copy = NULL;
   char num[80];
   uint64_t filesize;
   uint32_t parent_id = 0;
@@ -197,37 +196,30 @@
 
   printf("Sending track %s to %s\n", from_path, to_path);
 
-  to_path_copy = strdup(to_path);
-  parent = dirname(to_path_copy);
+  trackmeta = LIBMTP_new_track_t();
+  albuminfo = LIBMTP_new_album_t();
+
+  parent = dirname(strdup(to_path));
+  filename = basename(strdup(to_path));
   parent_id = parse_path (parent,files,folders);
   if (parent_id == -1) {
-    free (to_path_copy);
     printf("Parent folder could not be found, skipping\n");
     return 1;
   }
-  strcpy (to_path_copy,to_path);
-  filename = basename(to_path_copy);
 
   if (stat(from_path, &sb) == -1) {
     fprintf(stderr, "%s: ", from_path);
     perror("stat");
-    free (to_path_copy);
     return 1;
   }
 
-  if (!S_ISREG(sb.st_mode)) {
-    free (to_path_copy);
+  if (!S_ISREG(sb.st_mode))
     return 0;
-  }
 
   filesize = sb.st_size;
-
-  trackmeta = LIBMTP_new_track_t();
   trackmeta->filetype = find_filetype (from_path);
   if (!LIBMTP_FILETYPE_IS_TRACK(trackmeta->filetype)) {
     printf("Not a valid track codec: \"%s\"\n", LIBMTP_Get_Filetype_Description(trackmeta->filetype));
-    LIBMTP_destroy_track_t(trackmeta);
-    free (to_path_copy);
     return 1;
   }
 
@@ -291,9 +283,6 @@
     printf("Title:     %s\n", ptitle);
     trackmeta->title = strdup(ptitle);
   }
-
-  albuminfo = LIBMTP_new_album_t();
-
   if (palbum) {
     printf("Album:     %s\n", palbum);
     trackmeta->album = strdup(palbum);
@@ -382,13 +371,12 @@
 
   LIBMTP_destroy_album_t(albuminfo);
   LIBMTP_destroy_track_t(trackmeta);
-  free (to_path_copy);
 
   return ret;
 }
 
 int sendtrack_command (int argc, char **argv) {
-  int opt, ret;
+  int opt;
   extern int optind;
   extern char *optarg;
   char *partist = NULL;
@@ -406,31 +394,24 @@
   while ( (opt = getopt(argc, argv, "qD:t:a:A:w:l:c:g:n:d:y:s:")) != -1 ) {
     switch (opt) {
     case 't':
-      free (ptitle);
       ptitle = strdup(optarg);
       break;
     case 'a':
-      free (partist);
       partist = strdup(optarg);
       break;
     case 'A':
-      free (palbumartist);
       palbumartist = strdup(optarg);
       break;
     case 'w':
-      free (pcomposer);
       pcomposer = strdup(optarg);
       break;
     case 'l':
-      free (palbum);
       palbum = strdup(optarg);
       break;
     case 'c':
-      free (pcodec);
       pcodec = strdup(optarg); // FIXME: DSM check for MP3, WAV or WMA
       break;
     case 'g':
-      free (pgenre);
       pgenre = strdup(optarg);
       break;
     case 'n':
@@ -458,18 +439,11 @@
   if ( argc != 2 ) {
     printf("You need to pass a filename and destination.\n");
     sendtrack_usage();
-    ret = 0;
-  } else {
-    checklang();
-    printf("%s,%s,%s,%s,%s,%s,%s,%s,%d%d,%d,%u,%d\n",argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer,tracknum, length, year, storageid, quiet);
-    ret = sendtrack_function(argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer, tracknum, length, year, storageid, quiet);
+    return 0;
   }
-  free (ptitle);
-  free (partist);
-  free (palbumartist);
-  free (pcomposer);
-  free (palbum);
-  free (pcodec);
-  free (pgenre);
-  return ret;
+
+  checklang();
+
+  printf("%s,%s,%s,%s,%s,%s,%s,%s,%d%d,%d,%u,%d\n",argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer,tracknum, length, year, storageid, quiet);
+  return sendtrack_function(argv[0],argv[1],partist,palbumartist,ptitle,pgenre,palbum,pcomposer, tracknum, length, year, storageid, quiet);
 }
diff --git a/examples/thumb.c b/examples/thumb.c
index 3dc360e..2718a0c 100644
--- a/examples/thumb.c
+++ b/examples/thumb.c
@@ -47,7 +47,7 @@
   int fd;
   uint32_t id = 0;
   uint64_t filesize;
-  char *imagedata = NULL;
+  uint8_t *imagedata = NULL;
   char *path = NULL;
   char *rest;
   struct stat statbuff;
@@ -81,8 +81,8 @@
     perror("stat");
     exit(1);
   }
-  filesize = statbuff.st_size;
-  imagedata = malloc(filesize);
+  filesize = (uint64_t) statbuff.st_size;
+  imagedata = malloc(filesize * sizeof(uint16_t));
 
 #ifdef __WIN32__
   if ( (fd = open(path, O_RDONLY|O_BINARY) == -1) ) {
@@ -91,9 +91,9 @@
 #endif
     printf("Couldn't open image file %s (%s)\n",path,strerror(errno));
     return 1;
-  } else {
-    ret = read(fd, imagedata, filesize);
-    if (ret == -1) perror("read thumb data");
+  }
+  else {
+    read(fd, imagedata, filesize);
     close(fd);
   }
 
@@ -105,9 +105,16 @@
   }
   
   LIBMTP_filesampledata_t *thumb = LIBMTP_new_filesampledata_t();
-  thumb->data = imagedata;
+
+  int i;
+  thumb->data = malloc(sizeof(uint16_t) * filesize);
+  for (i = 0; i < filesize; i++) {
+    thumb->data[i] = imagedata[i];
+  }
+
   thumb->size = filesize;
   thumb->filetype = LIBMTP_FILETYPE_JPEG;
+  
   ret = LIBMTP_Send_Representative_Sample(device,id,thumb);
   if (ret != 0) {
     printf("Couldn't send thumbnail\n");
@@ -115,6 +122,7 @@
     LIBMTP_Clear_Errorstack(device);
   }
 
+  free(imagedata);
   LIBMTP_destroy_filesampledata_t(thumb);
 
   LIBMTP_Release_Device(device);
diff --git a/examples/tracks.c b/examples/tracks.c
index e22506e..04aa2e1 100644
--- a/examples/tracks.c
+++ b/examples/tracks.c
@@ -79,52 +79,15 @@
   }
 }
 
-static void
-dump_tracks(LIBMTP_mtpdevice_t *device, uint32_t storageid, int leaf)
-{
-  LIBMTP_file_t *files;
-
-  /* Get track listing. */
-  files = LIBMTP_Get_Files_And_Folders(device,
-				       storageid,
-				       leaf);
-  if (files == NULL) {
-    LIBMTP_Dump_Errorstack(device);
-    LIBMTP_Clear_Errorstack(device);
-  } else {
-    LIBMTP_file_t *file, *tmp;
-
-    file = files;
-    while (file != NULL) {
-      /* Please don't print these */
-      if (file->filetype == LIBMTP_FILETYPE_FOLDER) {
-	dump_tracks(device, storageid, file->item_id);
-      } else if (LIBMTP_FILETYPE_IS_TRACK(file->filetype)) {
-	LIBMTP_track_t *track;
-
-	track = LIBMTP_Get_Trackmetadata(device, file->item_id);
-	dump_trackinfo(track);
-	LIBMTP_destroy_track_t(track);
-      }
-      tmp = file;
-      file = file->next;
-      LIBMTP_destroy_file_t(tmp);
-    }
-  }
-}
-
 int main (int argc, char **argv)
 {
-  LIBMTP_raw_device_t *rawdevices;
-  int numrawdevices;
-  LIBMTP_error_number_t err;
-  int i;
+  LIBMTP_mtpdevice_t *device_list, *device;
+  LIBMTP_track_t *tracks;
 
   LIBMTP_Init();
   fprintf(stdout, "Attempting to connect device(s)\n");
 
-  err = LIBMTP_Detect_Raw_Devices(&rawdevices, &numrawdevices);
-  switch(err)
+  switch(LIBMTP_Get_Connected_Devices(&device_list))
   {
   case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
     fprintf(stdout, "mtp-tracks: No Devices have been found\n");
@@ -147,21 +110,12 @@
   case LIBMTP_ERROR_NONE:
     fprintf(stdout, "mtp-tracks: Successfully connected\n");
     fflush(stdout);
-    break;
   }
 
-  /* Iterate through connected MTP devices */
-  for (i = 0; i < numrawdevices; i++) {
-    LIBMTP_mtpdevice_t *device;
-    LIBMTP_devicestorage_t *storage;
+  /* iterate through connected MTP devices */
+  for(device = device_list; device != NULL; device = device->next) {
     char *friendlyname;
 
-    device = LIBMTP_Open_Raw_Device_Uncached(&rawdevices[i]);
-    if (device == NULL) {
-      fprintf(stderr, "Unable to open raw device %d\n", i);
-      continue;
-    }
-
     /* Echo the friendly name so we know which device we are working with */
     friendlyname = LIBMTP_Get_Friendlyname(device);
     if (friendlyname == NULL) {
@@ -170,18 +124,23 @@
       printf("Friendly name: %s\n", friendlyname);
       free(friendlyname);
     }
-
-    LIBMTP_Dump_Errorstack(device);
-    LIBMTP_Clear_Errorstack(device);
-
-    /* Loop over storages */
-    for (storage = device->storage; storage != 0; storage = storage->next) {
-      dump_tracks(device, storage->id, 0);
+    // Get track listing.
+    tracks = LIBMTP_Get_Tracklisting_With_Callback(device, NULL, NULL);
+    if (tracks == NULL) {
+      printf("No tracks.\n");
+    } else {
+      LIBMTP_track_t *track, *tmp;
+      track = tracks;
+      while (track != NULL) {
+	dump_trackinfo(track);
+	tmp = track;
+	track = track->next;
+	LIBMTP_destroy_track_t(tmp);
+      }
     }
-
-    LIBMTP_Release_Device(device);
   }
 
+  LIBMTP_Release_Device_List(device_list);
   printf("OK.\n");
   exit (0);
 }
diff --git a/install-sh b/install-sh
index 0b0fdcb..a9244eb 100755
--- a/install-sh
+++ b/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2013-12-25.23; # UTC
+scriptversion=2011-01-19.21; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -35,21 +35,25 @@
 # 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
 # from scratch.
 
-tab='	'
 nl='
 '
-IFS=" $tab$nl"
+IFS=" ""	$nl"
 
-# Set DOITPROG to "echo" to test this script.
+# set DOITPROG to echo to test this script
 
+# Don't use :- since 4.3BSD and earlier shells don't like it.
 doit=${DOITPROG-}
-doit_exec=${doit:-exec}
+if test -z "$doit"; then
+  doit_exec=exec
+else
+  doit_exec=$doit
+fi
 
 # Put in absolute file names if you don't have them in your path;
 # or use environment vars.
@@ -64,6 +68,17 @@
 rmprog=${RMPROG-rm}
 stripprog=${STRIPPROG-strip}
 
+posix_glob='?'
+initialize_posix_glob='
+  test "$posix_glob" != "?" || {
+    if (set -f) 2>/dev/null; then
+      posix_glob=
+    else
+      posix_glob=:
+    fi
+  }
+'
+
 posix_mkdir=
 
 # Desired mode of installed file.
@@ -82,7 +97,7 @@
 dst_arg=
 
 copy_on_change=false
-is_target_a_directory=possibly
+no_target_directory=
 
 usage="\
 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@@ -122,57 +137,46 @@
     -d) dir_arg=true;;
 
     -g) chgrpcmd="$chgrpprog $2"
-        shift;;
+	shift;;
 
     --help) echo "$usage"; exit $?;;
 
     -m) mode=$2
-        case $mode in
-          *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
-            echo "$0: invalid mode: $mode" >&2
-            exit 1;;
-        esac
-        shift;;
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
 
     -o) chowncmd="$chownprog $2"
-        shift;;
+	shift;;
 
     -s) stripcmd=$stripprog;;
 
-    -t)
-        is_target_a_directory=always
-        dst_arg=$2
-        # Protect names problematic for 'test' and other utilities.
-        case $dst_arg in
-          -* | [=\(\)!]) dst_arg=./$dst_arg;;
-        esac
-        shift;;
+    -t) dst_arg=$2
+	# Protect names problematic for `test' and other utilities.
+	case $dst_arg in
+	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
+	esac
+	shift;;
 
-    -T) is_target_a_directory=never;;
+    -T) no_target_directory=true;;
 
     --version) echo "$0 $scriptversion"; exit $?;;
 
-    --) shift
-        break;;
+    --)	shift
+	break;;
 
-    -*) echo "$0: invalid option: $1" >&2
-        exit 1;;
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
 
     *)  break;;
   esac
   shift
 done
 
-# We allow the use of options -d and -T together, by making -d
-# take the precedence; this is for compatibility with GNU install.
-
-if test -n "$dir_arg"; then
-  if test -n "$dst_arg"; then
-    echo "$0: target directory not allowed when installing a directory." >&2
-    exit 1
-  fi
-fi
-
 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
   # When -d is used, all remaining arguments are directories to create.
   # When -t is used, the destination is already specified.
@@ -186,7 +190,7 @@
     fi
     shift # arg
     dst_arg=$arg
-    # Protect names problematic for 'test' and other utilities.
+    # Protect names problematic for `test' and other utilities.
     case $dst_arg in
       -* | [=\(\)!]) dst_arg=./$dst_arg;;
     esac
@@ -198,21 +202,12 @@
     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
-  if test $# -gt 1 || test "$is_target_a_directory" = always; then
-    if test ! -d "$dst_arg"; then
-      echo "$0: $dst_arg: Is not a directory." >&2
-      exit 1
-    fi
-  fi
-fi
-
-if test -z "$dir_arg"; then
   do_exit='(exit $ret); exit $ret'
   trap "ret=129; $do_exit" 1
   trap "ret=130; $do_exit" 2
@@ -228,16 +223,16 @@
 
     *[0-7])
       if test -z "$stripcmd"; then
-        u_plus_rw=
+	u_plus_rw=
       else
-        u_plus_rw='% 200'
+	u_plus_rw='% 200'
       fi
       cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
     *)
       if test -z "$stripcmd"; then
-        u_plus_rw=
+	u_plus_rw=
       else
-        u_plus_rw=,u+rw
+	u_plus_rw=,u+rw
       fi
       cp_umask=$mode$u_plus_rw;;
   esac
@@ -245,7 +240,7 @@
 
 for src
 do
-  # Protect names problematic for 'test' and other utilities.
+  # Protect names problematic for `test' and other utilities.
   case $src in
     -* | [=\(\)!]) src=./$src;;
   esac
@@ -274,15 +269,41 @@
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
     if test -d "$dst"; then
-      if test "$is_target_a_directory" = never; then
-        echo "$0: $dst_arg: Is a directory" >&2
-        exit 1
+      if test -n "$no_target_directory"; then
+	echo "$0: $dst_arg: Is a directory" >&2
+	exit 1
       fi
       dstdir=$dst
       dst=$dstdir/`basename "$src"`
       dstdir_status=0
     else
-      dstdir=`dirname "$dst"`
+      # Prefer dirname, but fall back on a substitute if dirname fails.
+      dstdir=`
+	(dirname "$dst") 2>/dev/null ||
+	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	     X"$dst" : 'X\(//\)[^/]' \| \
+	     X"$dst" : 'X\(//\)$' \| \
+	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+	echo X"$dst" |
+	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)[^/].*/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\/\)$/{
+		   s//\1/
+		   q
+		 }
+		 /^X\(\/\).*/{
+		   s//\1/
+		   q
+		 }
+		 s/.*/./; q'
+      `
+
       test -d "$dstdir"
       dstdir_status=$?
     fi
@@ -293,74 +314,74 @@
   if test $dstdir_status != 0; then
     case $posix_mkdir in
       '')
-        # Create intermediate dirs using mode 755 as modified by the umask.
-        # This is like FreeBSD 'install' as of 1997-10-28.
-        umask=`umask`
-        case $stripcmd.$umask in
-          # Optimize common cases.
-          *[2367][2367]) mkdir_umask=$umask;;
-          .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+	# Create intermediate dirs using mode 755 as modified by the umask.
+	# This is like FreeBSD 'install' as of 1997-10-28.
+	umask=`umask`
+	case $stripcmd.$umask in
+	  # Optimize common cases.
+	  *[2367][2367]) mkdir_umask=$umask;;
+	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
 
-          *[0-7])
-            mkdir_umask=`expr $umask + 22 \
-              - $umask % 100 % 40 + $umask % 20 \
-              - $umask % 10 % 4 + $umask % 2
-            `;;
-          *) mkdir_umask=$umask,go-w;;
-        esac
+	  *[0-7])
+	    mkdir_umask=`expr $umask + 22 \
+	      - $umask % 100 % 40 + $umask % 20 \
+	      - $umask % 10 % 4 + $umask % 2
+	    `;;
+	  *) mkdir_umask=$umask,go-w;;
+	esac
 
-        # With -d, create the new directory with the user-specified mode.
-        # Otherwise, rely on $mkdir_umask.
-        if test -n "$dir_arg"; then
-          mkdir_mode=-m$mode
-        else
-          mkdir_mode=
-        fi
+	# With -d, create the new directory with the user-specified mode.
+	# Otherwise, rely on $mkdir_umask.
+	if test -n "$dir_arg"; then
+	  mkdir_mode=-m$mode
+	else
+	  mkdir_mode=
+	fi
 
-        posix_mkdir=false
-        case $umask in
-          *[123567][0-7][0-7])
-            # POSIX mkdir -p sets u+wx bits regardless of umask, which
-            # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-            ;;
-          *)
-            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-            trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+	posix_mkdir=false
+	case $umask in
+	  *[123567][0-7][0-7])
+	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
+	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+	    ;;
+	  *)
+	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
 
-            if (umask $mkdir_umask &&
-                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-            then
-              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-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
-                     d????-?r-*) different_mode=700;;
-                     d????-?--*) different_mode=755;;
-                     *) false;;
-                   esac &&
-                   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-                     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-                   }
-                 }
-              then posix_mkdir=:
-              fi
-              rmdir "$tmpdir/d" "$tmpdir"
-            else
-              # Remove any dirs left behind by ancient mkdir implementations.
-              rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-            fi
-            trap '' 0;;
-        esac;;
+	    if (umask $mkdir_umask &&
+		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+	    then
+	      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.
+		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+		   case $ls_ld_tmpdir in
+		     d????-?r-*) different_mode=700;;
+		     d????-?--*) different_mode=755;;
+		     *) false;;
+		   esac &&
+		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+		   }
+		 }
+	      then posix_mkdir=:
+	      fi
+	      rmdir "$tmpdir/d" "$tmpdir"
+	    else
+	      # Remove any dirs left behind by ancient mkdir implementations.
+	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+	    fi
+	    trap '' 0;;
+	esac;;
     esac
 
     if
       $posix_mkdir && (
-        umask $mkdir_umask &&
-        $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+	umask $mkdir_umask &&
+	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
       )
     then :
     else
@@ -370,51 +391,53 @@
       # directory the slow way, step by step, checking for races as we go.
 
       case $dstdir in
-        /*) prefix='/';;
-        [-=\(\)!]*) prefix='./';;
-        *)  prefix='';;
+	/*) prefix='/';;
+	[-=\(\)!]*) prefix='./';;
+	*)  prefix='';;
       esac
 
+      eval "$initialize_posix_glob"
+
       oIFS=$IFS
       IFS=/
-      set -f
+      $posix_glob set -f
       set fnord $dstdir
       shift
-      set +f
+      $posix_glob set +f
       IFS=$oIFS
 
       prefixes=
 
       for d
       do
-        test X"$d" = X && continue
+	test X"$d" = X && continue
 
-        prefix=$prefix$d
-        if test -d "$prefix"; then
-          prefixes=
-        else
-          if $posix_mkdir; then
-            (umask=$mkdir_umask &&
-             $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
-            # Don't fail if two instances are running concurrently.
-            test -d "$prefix" || exit 1
-          else
-            case $prefix in
-              *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
-              *) qprefix=$prefix;;
-            esac
-            prefixes="$prefixes '$qprefix'"
-          fi
-        fi
-        prefix=$prefix/
+	prefix=$prefix$d
+	if test -d "$prefix"; then
+	  prefixes=
+	else
+	  if $posix_mkdir; then
+	    (umask=$mkdir_umask &&
+	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+	    # Don't fail if two instances are running concurrently.
+	    test -d "$prefix" || exit 1
+	  else
+	    case $prefix in
+	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+	      *) qprefix=$prefix;;
+	    esac
+	    prefixes="$prefixes '$qprefix'"
+	  fi
+	fi
+	prefix=$prefix/
       done
 
       if test -n "$prefixes"; then
-        # Don't fail if two instances are running concurrently.
-        (umask $mkdir_umask &&
-         eval "\$doit_exec \$mkdirprog $prefixes") ||
-          test -d "$dstdir" || exit 1
-        obsolete_mkdir_used=true
+	# Don't fail if two instances are running concurrently.
+	(umask $mkdir_umask &&
+	 eval "\$doit_exec \$mkdirprog $prefixes") ||
+	  test -d "$dstdir" || exit 1
+	obsolete_mkdir_used=true
       fi
     fi
   fi
@@ -449,12 +472,15 @@
 
     # If -C, don't bother to copy if it wouldn't change the file.
     if $copy_on_change &&
-       old=`LC_ALL=C ls -dlL "$dst"     2>/dev/null` &&
-       new=`LC_ALL=C ls -dlL "$dsttmp"  2>/dev/null` &&
-       set -f &&
+       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
+       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
+
+       eval "$initialize_posix_glob" &&
+       $posix_glob set -f &&
        set X $old && old=:$2:$4:$5:$6 &&
        set X $new && new=:$2:$4:$5:$6 &&
-       set +f &&
+       $posix_glob set +f &&
+
        test "$old" = "$new" &&
        $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
     then
@@ -467,24 +493,24 @@
       # to itself, or perhaps because mv is so ancient that it does not
       # support -f.
       {
-        # Now remove or move aside any old file at destination location.
-        # We try this two ways since rm can't unlink itself on some
-        # systems and the destination file might be busy for other
-        # reasons.  In this case, the final cleanup might fail but the new
-        # file should still install successfully.
-        {
-          test ! -f "$dst" ||
-          $doit $rmcmd -f "$dst" 2>/dev/null ||
-          { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-            { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
-          } ||
-          { echo "$0: cannot unlink or rename $dst" >&2
-            (exit 1); exit 1
-          }
-        } &&
+	# Now remove or move aside any old file at destination location.
+	# We try this two ways since rm can't unlink itself on some
+	# systems and the destination file might be busy for other
+	# reasons.  In this case, the final cleanup might fail but the new
+	# file should still install successfully.
+	{
+	  test ! -f "$dst" ||
+	  $doit $rmcmd -f "$dst" 2>/dev/null ||
+	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+	  } ||
+	  { echo "$0: cannot unlink or rename $dst" >&2
+	    (exit 1); exit 1
+	  }
+	} &&
 
-        # Now rename the file to the real destination.
-        $doit $mvcmd "$dsttmp" "$dst"
+	# Now rename the file to the real destination.
+	$doit $mvcmd "$dsttmp" "$dst"
       }
     fi || exit 1
 
diff --git a/libmtp.gyp b/libmtp.gyp
new file mode 100644
index 0000000..0c02790
--- /dev/null
+++ b/libmtp.gyp
@@ -0,0 +1,71 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'variables': {
+    'use_system_libmtp%': 0,
+  },
+  'conditions': [
+    ['use_system_libmtp==0', {
+      'targets': [
+        {
+          'target_name': 'libmtp',
+          'type': 'shared_library',
+          'product_name': 'mtp',
+          'dependencies': [
+            '../../third_party/libusb/libusb.gyp:libusb',
+          ],
+          'sources': [
+            'src/libmtp.c',
+            'src/libusb1-glue.c',
+            'src/ptp.c',
+            'src/unicode.c',
+            'src/util.c',
+          ],
+          'cflags!': ['-fvisibility=hidden'],
+          'include_dirs': [
+            '.',
+            'src',
+          ],
+          'direct_dependent_settings': {
+            'include_dirs': [
+              'src',
+            ],
+          },
+        },
+      ],
+    }, { # use_system_libmtp==1
+      'conditions': [
+        ['sysroot!=""', {
+          'variables': {
+            'pkg-config': '../../build/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)"',
+          },
+        }, {
+          'variables': {
+            'pkg-config': 'pkg-config'
+          },
+        }],
+      ],
+      'targets': [
+        {
+          'target_name': 'libmtp',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+                '<!@(<(pkg-config) --cflags libmtp)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other libmtp)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l libmtp)',
+            ],
+          },
+        }
+      ],
+    }],
+  ]
+}
diff --git a/libmtp.pc b/libmtp.pc
deleted file mode 100644
index 156a384..0000000
--- a/libmtp.pc
+++ /dev/null
@@ -1,15 +0,0 @@
-# libmtp pkg-config source file
-
-prefix=/usr
-exec_prefix=${prefix}
-libdir=/usr/lib64
-includedir=${prefix}/include
-
-Name: libmtp
-Description: libmtp is a library for accessing Media Transfer Protocol devices
-Version: 1.1.12
-Requires.private: libusb-1.0
-Conflicts:
-Libs: -L${libdir} -lmtp
-Libs.private: -lgcrypt 
-Cflags: -I${includedir} 
diff --git a/libmtp.pc.in b/libmtp.pc.in
index 93c7bbf..81f505c 100644
--- a/libmtp.pc.in
+++ b/libmtp.pc.in
@@ -8,7 +8,7 @@
 Name: libmtp
 Description: libmtp is a library for accessing Media Transfer Protocol devices
 Version: @VERSION@
-Requires.private: @LIBUSB_REQUIRES@
+Requires: @LIBUSB_REQUIRES@
 Conflicts:
 Libs: -L${libdir} -lmtp
 Libs.private: @LIBS@
diff --git a/libmtp.sh b/libmtp.sh
deleted file mode 100644
index b149413..0000000
--- a/libmtp.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-# Lifts a plugged in MTP device to user space and
-# optionally runs a client program.
-# Written by Linus Walleij 2006, based on the "usbcam"
-# script by Nalin Dahyabhai.
-DEVICEOWNER=root
-DEVICEPERMS=666
-
-# Special quirk for SuSE systems using "resmgr"
-# (see http://rechner.lst.de/~okir/resmgr/)
-if [ -f /sbin/resmgr ]
-then
-    /sbin/resmgr "${ACTION}" "${DEVICE}" desktop usb
-    exit 0
-fi
-
-# This is for most other distributions
-if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
-then
-    # New code, using lock files instead of copying /dev/console permissions
-    # This also works with non-gdm logins (e.g. on a virtual terminal)
-    # Idea and code from Nalin Dahyabhai <nalin@redhat.com>
-    if [ "x$DEVICEOWNER" = "xCONSOLE" ]
-    then
-	if [ -f /var/run/console/console.lock ]
-	then
-	    DEVICEOWNER=`cat /var/run/console/console.lock`
-	elif [ -f /var/run/console.lock ]
-	then
-	    DEVICEOWNER=`cat /var/run/console.lock`
-	elif [ -f /var/lock/console.lock ]
-	then
-	    DEVICEOWNER=`cat /var/lock/console.lock`
-	else
-	    DEVICEOWNER="nobody"
-	    DEVICEPERMS="666"
-	fi
-    fi
-    if [ -n "$DEVICEOWNER" ]
-    then
-        chmod 0000 "${DEVICE}"
-        chown "${DEVICEOWNER}" "${DEVICE}"
-        chmod "${DEVICEPERMS}" "${DEVICE}"
-    fi
-fi
diff --git a/ltmain.sh b/ltmain.sh
old mode 100644
new mode 100755
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 256661f..56666f0 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1312,7 +1312,7 @@
   rm -rf conftest*
   ;;
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
@@ -1326,10 +1326,7 @@
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_i386"
 	    ;;
-	  powerpc64le-*linux*)
-	    LD="${LD-ld} -m elf32lppclinux"
-	    ;;
-	  powerpc64-*linux*)
+	  ppc64-*linux*|powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -1348,10 +1345,7 @@
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*linux*)
-	    LD="${LD-ld} -m elf64lppc"
-	    ;;
-	  powerpc-*linux*)
+	  ppc*-*linux*|powerpc*-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -2675,10 +2669,14 @@
   # before this can be enabled.
   hardcode_into_libs=yes
 
+  # Add ABI-specific directories to the system library path.
+  sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
+
   # Append ld.so.conf contents to the search path
   if test -f /etc/ld.so.conf; then
     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+    sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+
   fi
 
   # We used to test for /lib/ld.so.1 and disable shared libraries on
diff --git a/missing b/missing
index f62bbae..86a8fc3 100755
--- a/missing
+++ b/missing
@@ -1,10 +1,11 @@
 #! /bin/sh
-# Common wrapper for a few potentially missing GNU programs.
+# Common stub for a few missing GNU programs while installing.
 
-scriptversion=2013-10-28.13; # UTC
+scriptversion=2012-01-06.13; # UTC
 
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
-# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+# 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@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
@@ -25,40 +26,68 @@
 # 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
+
+msg="missing on your system"
+
 case $1 in
-
-  --is-lightweight)
-    # Used by our autoconf macros to check whether the available missing
-    # script is modern enough.
-    exit 0
-    ;;
-
-  --run)
-    # Back-compat with the calling convention used by older automake.
-    shift
-    ;;
+--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
+  ;;
 
   -h|--h|--he|--hel|--help)
     echo "\
 $0 [OPTION]... PROGRAM [ARGUMENT]...
 
-Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
-to PROGRAM being missing or too old.
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
 
 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   autoconf  autoheader   autom4te  automake  makeinfo
-  bison     yacc      flex         lex       help2man
+  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]
 
-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@gnu.org>."
     exit $?
@@ -70,141 +99,228 @@
     ;;
 
   -*)
-    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
 
-# Run the given program, remember its exit status.
-"$@"; st=$?
+# normalize program name to check for.
+program=`echo "$1" | sed '
+  s/^gnu-//; t
+  s/^gnu//; t
+  s/^g//; t'`
 
-# 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
-
-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/>"
+# 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.
     ;;
-    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
+  *)
+    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
 
-# 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
+# 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
+    ;;
+
+  *)
+    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
+    ;;
+esac
+
+exit 0
 
 # Local variables:
 # eval: (add-hook 'write-file-hooks 'time-stamp)
diff --git a/patches/00_disable_playlist.patch b/patches/00_disable_playlist.patch
index 6e44fcf..6a0a573 100644
--- a/patches/00_disable_playlist.patch
+++ b/patches/00_disable_playlist.patch
@@ -1,7 +1,7 @@
-diff --git a/examples/Makefile.am b/examples/Makefile.am
-index 46ac70f..0bac1b3 100644
---- a/examples/Makefile.am
-+++ b/examples/Makefile.am
+Index: examples/Makefile.am
+===================================================================
+--- examples/Makefile.am	(revision 148515)
++++ examples/Makefile.am	(working copy)
 @@ -1,6 +1,6 @@
  bin_PROGRAMS=mtp-connect mtp-detect mtp-tracks mtp-files \
 -	mtp-folders mtp-trexist mtp-playlists mtp-getplaylist \
@@ -11,7 +11,7 @@
  	mtp-thumb mtp-reset mtp-filetree
  
  mtp_connect_SOURCES=connect.c connect.h delfile.c getfile.c newfolder.c \
-@@ -11,9 +11,6 @@ mtp_tracks_SOURCES=tracks.c util.c util.h common.h
+@@ -11,9 +11,6 @@
  mtp_files_SOURCES=files.c util.c util.h common.h
  mtp_folders_SOURCES=folders.c util.c util.h common.h
  mtp_trexist_SOURCES=trexist.c util.c util.h common.h
@@ -21,11 +21,11 @@
  mtp_format_SOURCES=format.c util.c util.h common.h
  mtp_albumart_SOURCES=albumart.c util.c util.h common.h
  mtp_albums_SOURCES=albums.c util.c util.h common.h
-diff --git a/examples/Makefile.in b/examples/Makefile.in
-index 8d6e224..85e1a8b 100644
---- a/examples/Makefile.in
-+++ b/examples/Makefile.in
-@@ -90,10 +90,10 @@ build_triplet = @build@
+Index: examples/Makefile.in
+===================================================================
+--- examples/Makefile.in	(revision 148515)
++++ examples/Makefile.in	(working copy)
+@@ -36,10 +36,10 @@
  host_triplet = @host@
  bin_PROGRAMS = mtp-connect$(EXEEXT) mtp-detect$(EXEEXT) \
  	mtp-tracks$(EXEEXT) mtp-files$(EXEEXT) mtp-folders$(EXEEXT) \
@@ -38,8 +38,8 @@
 +	mtp-emptyfolders$(EXEEXT) \
  	mtp-thumb$(EXEEXT) mtp-reset$(EXEEXT) mtp-filetree$(EXEEXT)
  subdir = examples
- ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-@@ -153,18 +153,6 @@ am_mtp_format_OBJECTS = format.$(OBJEXT) util.$(OBJEXT)
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+@@ -95,18 +95,6 @@
  mtp_format_OBJECTS = $(am_mtp_format_OBJECTS)
  mtp_format_LDADD = $(LDADD)
  mtp_format_DEPENDENCIES = ../src/libmtp.la
@@ -58,7 +58,7 @@
  am_mtp_reset_OBJECTS = reset.$(OBJEXT) util.$(OBJEXT)
  mtp_reset_OBJECTS = $(am_mtp_reset_OBJECTS)
  mtp_reset_LDADD = $(LDADD)
-@@ -219,16 +207,14 @@ SOURCES = $(mtp_albumart_SOURCES) $(mtp_albums_SOURCES) \
+@@ -140,16 +128,14 @@
  	$(mtp_connect_SOURCES) $(mtp_detect_SOURCES) \
  	$(mtp_emptyfolders_SOURCES) $(mtp_files_SOURCES) \
  	$(mtp_filetree_SOURCES) $(mtp_folders_SOURCES) \
@@ -76,8 +76,8 @@
 +	$(mtp_format_SOURCES) \
  	$(mtp_reset_SOURCES) $(mtp_thumb_SOURCES) \
  	$(mtp_tracks_SOURCES) $(mtp_trexist_SOURCES)
- am__can_run_installinfo = \
-@@ -397,9 +383,6 @@ mtp_tracks_SOURCES = tracks.c util.c util.h common.h
+ ETAGS = etags
+@@ -294,9 +280,6 @@
  mtp_files_SOURCES = files.c util.c util.h common.h
  mtp_folders_SOURCES = folders.c util.c util.h common.h
  mtp_trexist_SOURCES = trexist.c util.c util.h common.h
@@ -87,26 +87,23 @@
  mtp_format_SOURCES = format.c util.c util.h common.h
  mtp_albumart_SOURCES = albumart.c util.c util.h common.h
  mtp_albums_SOURCES = albums.c util.c util.h common.h
-@@ -529,18 +512,6 @@ mtp-format$(EXEEXT): $(mtp_format_OBJECTS) $(mtp_format_DEPENDENCIES) $(EXTRA_mt
+@@ -411,15 +394,6 @@
+ mtp-format$(EXEEXT): $(mtp_format_OBJECTS) $(mtp_format_DEPENDENCIES) $(EXTRA_mtp_format_DEPENDENCIES) 
  	@rm -f mtp-format$(EXEEXT)
- 	$(AM_V_CCLD)$(LINK) $(mtp_format_OBJECTS) $(mtp_format_LDADD) $(LIBS)
- 
+ 	$(LINK) $(mtp_format_OBJECTS) $(mtp_format_LDADD) $(LIBS)
 -mtp-getplaylist$(EXEEXT): $(mtp_getplaylist_OBJECTS) $(mtp_getplaylist_DEPENDENCIES) $(EXTRA_mtp_getplaylist_DEPENDENCIES) 
 -	@rm -f mtp-getplaylist$(EXEEXT)
--	$(AM_V_CCLD)$(LINK) $(mtp_getplaylist_OBJECTS) $(mtp_getplaylist_LDADD) $(LIBS)
--
+-	$(LINK) $(mtp_getplaylist_OBJECTS) $(mtp_getplaylist_LDADD) $(LIBS)
 -mtp-newplaylist$(EXEEXT): $(mtp_newplaylist_OBJECTS) $(mtp_newplaylist_DEPENDENCIES) $(EXTRA_mtp_newplaylist_DEPENDENCIES) 
 -	@rm -f mtp-newplaylist$(EXEEXT)
--	$(AM_V_CCLD)$(LINK) $(mtp_newplaylist_OBJECTS) $(mtp_newplaylist_LDADD) $(LIBS)
--
+-	$(LINK) $(mtp_newplaylist_OBJECTS) $(mtp_newplaylist_LDADD) $(LIBS)
 -mtp-playlists$(EXEEXT): $(mtp_playlists_OBJECTS) $(mtp_playlists_DEPENDENCIES) $(EXTRA_mtp_playlists_DEPENDENCIES) 
 -	@rm -f mtp-playlists$(EXEEXT)
--	$(AM_V_CCLD)$(LINK) $(mtp_playlists_OBJECTS) $(mtp_playlists_LDADD) $(LIBS)
--
+-	$(LINK) $(mtp_playlists_OBJECTS) $(mtp_playlists_LDADD) $(LIBS)
  mtp-reset$(EXEEXT): $(mtp_reset_OBJECTS) $(mtp_reset_DEPENDENCIES) $(EXTRA_mtp_reset_DEPENDENCIES) 
  	@rm -f mtp-reset$(EXEEXT)
- 	$(AM_V_CCLD)$(LINK) $(mtp_reset_OBJECTS) $(mtp_reset_LDADD) $(LIBS)
-@@ -574,11 +545,8 @@ distclean-compile:
+ 	$(LINK) $(mtp_reset_OBJECTS) $(mtp_reset_LDADD) $(LIBS)
+@@ -450,11 +424,8 @@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/folders.Po@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format.Po@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getfile.Po@am__quote@
@@ -118,10 +115,10 @@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reset.Po@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendfile.Po@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendtr.Po@am__quote@
-diff --git a/src/libmtp.c b/src/libmtp.c
-index 665f334..b38b7a2 100644
---- a/src/libmtp.c
-+++ b/src/libmtp.c
+Index: src/libmtp.c
+===================================================================
+--- src/libmtp.c	(revision 148515)
++++ src/libmtp.c	(working copy)
 @@ -40,7 +40,9 @@
  #include "ptp.h"
  #include "libusb-glue.h"
@@ -131,8 +128,8 @@
 +#endif
  #include "util.h"
  
- #include "mtpz.h"
-@@ -6965,6 +6967,7 @@ int LIBMTP_Set_Track_Name(LIBMTP_mtpdevice_t *device,
+ #include <stdlib.h>
+@@ -6764,6 +6766,7 @@
    return ret;
  }
  
@@ -140,7 +137,7 @@
  /**
   * This function renames a single playlist object file holder.
   * This simply means that the <code>PTP_OPC_ObjectFileName</code>
-@@ -7001,6 +7004,7 @@ int LIBMTP_Set_Playlist_Name(LIBMTP_mtpdevice_t *device,
+@@ -6800,6 +6803,7 @@
    playlist->name = strdup(newname);
    return ret;
  }
@@ -148,7 +145,7 @@
  
  /**
   * This function renames a single album.
-@@ -7418,6 +7422,7 @@ uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t *device, char *name,
+@@ -7217,6 +7221,7 @@
    return new_id;
  }
  
@@ -156,7 +153,7 @@
  /**
   * This creates a new playlist metadata structure and allocates memory
   * for it. Notice that if you add strings to this structure they
-@@ -7614,6 +7619,7 @@ LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *device, uint32_t cons
+@@ -7413,6 +7418,7 @@
  
    return pl;
  }
@@ -164,7 +161,7 @@
  
  /**
   * This function creates a new abstract list such as a playlist
-@@ -8170,6 +8176,7 @@ static int update_abstract_list(LIBMTP_mtpdevice_t *device,
+@@ -7967,6 +7973,7 @@
  }
  
  
@@ -172,7 +169,7 @@
  /**
   * This routine creates a new playlist based on the metadata
   * supplied. If the <code>tracks</code> field of the metadata
-@@ -8268,6 +8275,7 @@ int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *device,
+@@ -8065,6 +8072,7 @@
  			      metadata->tracks,
  			      metadata->no_tracks);
  }
@@ -180,10 +177,10 @@
  
  /**
   * This creates a new album metadata structure and allocates memory
-diff --git a/src/Makefile.am b/src/Makefile.am
-index d00e372..39f1c61 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
+Index: src/Makefile.am
+===================================================================
+--- src/Makefile.am	(revision 148515)
++++ src/Makefile.am	(working copy)
 @@ -1,9 +1,9 @@
  lib_LTLIBRARIES = libmtp.la
  
@@ -191,16 +188,16 @@
 -libmtp_la_SOURCES = libmtp.c unicode.c unicode.h util.c util.h playlist-spl.c \
 +libmtp_la_SOURCES = libmtp.c unicode.c unicode.h util.c util.h \
  	gphoto2-endian.h _stdint.h ptp.c ptp.h libusb-glue.h \
--	music-players.h device-flags.h playlist-spl.h mtpz.h \
-+	music-players.h device-flags.h mtpz.h \
- 	chdk_live_view.h chdk_ptp.h
+-	music-players.h device-flags.h playlist-spl.h mtpz.h
++	music-players.h device-flags.h mtpz.h
  
- if MTPZ_COMPILE
-diff --git a/src/libmtp.h.in b/src/libmtp.h.in
-index ac37b3e..4b742e1 100644
---- a/src/libmtp.h.in
-+++ b/src/libmtp.h.in
-@@ -1001,7 +1001,7 @@ uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t*, char *, uint32_t, uint32_t);
+ if LIBUSB1_COMPILE
+ libmtp_la_SOURCES += libusb1-glue.c
+Index: src/libmtp.h.in
+===================================================================
+--- src/libmtp.h.in	(revision 148515)
++++ src/libmtp.h.in	(working copy)
+@@ -966,7 +966,7 @@
  int LIBMTP_Set_Folder_Name(LIBMTP_mtpdevice_t *, LIBMTP_folder_t *, const char *);
  /** @} */
  
@@ -209,7 +206,7 @@
  /**
   * @}
   * @defgroup playlists The audio/video playlist management API.
-@@ -1014,6 +1014,7 @@ LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *, uint32_t const);
+@@ -979,6 +979,7 @@
  int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
  int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
  int LIBMTP_Set_Playlist_Name(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *, const char *);
@@ -217,11 +214,11 @@
  
  /**
   * @}
-diff --git a/src/Makefile.in b/src/Makefile.in
-index 5cdbab8..2c4cc96 100644
---- a/src/Makefile.in
-+++ b/src/Makefile.in
-@@ -140,8 +140,8 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
+Index: src/Makefile.in
+===================================================================
+--- src/Makefile.in	(revision 148515)
++++ src/Makefile.in	(working copy)
+@@ -85,16 +85,16 @@
  LTLIBRARIES = $(lib_LTLIBRARIES)
  am__DEPENDENCIES_1 =
  am__libmtp_la_SOURCES_DIST = libmtp.c unicode.c unicode.h util.c \
@@ -229,10 +226,10 @@
 -	libusb-glue.h music-players.h device-flags.h playlist-spl.h \
 +	util.h gphoto2-endian.h _stdint.h ptp.c ptp.h \
 +	libusb-glue.h music-players.h device-flags.h \
- 	mtpz.h chdk_live_view.h chdk_ptp.h mtpz.c libusb1-glue.c \
- 	libusb-glue.c libopenusb1-glue.c
+ 	mtpz.h mtpz.c libusb1-glue.c libusb-glue.c libopenusb1-glue.c
  @MTPZ_COMPILE_TRUE@am__objects_1 = libmtp_la-mtpz.lo
-@@ -150,7 +150,7 @@ am__libmtp_la_SOURCES_DIST = libmtp.c unicode.c unicode.h util.c \
+ @LIBUSB1_COMPILE_TRUE@am__objects_2 = libmtp_la-libusb1-glue.lo
+ @LIBUSB0_COMPILE_TRUE@am__objects_3 = libmtp_la-libusb-glue.lo
  @LIBOPENUSB_COMPILE_TRUE@am__objects_4 =  \
  @LIBOPENUSB_COMPILE_TRUE@	libmtp_la-libopenusb1-glue.lo
  am_libmtp_la_OBJECTS = libmtp_la-libmtp.lo libmtp_la-unicode.lo \
@@ -241,7 +238,7 @@
  	$(am__objects_1) $(am__objects_2) $(am__objects_3) \
  	$(am__objects_4)
  libmtp_la_OBJECTS = $(am_libmtp_la_OBJECTS)
-@@ -360,8 +360,8 @@ top_srcdir = @top_srcdir@
+@@ -252,8 +252,8 @@
  lib_LTLIBRARIES = libmtp.la
  libmtp_la_CFLAGS = @LIBUSB_CFLAGS@
  libmtp_la_SOURCES = libmtp.c unicode.c unicode.h util.c util.h \
@@ -249,10 +246,10 @@
 -	libusb-glue.h music-players.h device-flags.h playlist-spl.h \
 +	gphoto2-endian.h _stdint.h ptp.c ptp.h \
 +	libusb-glue.h music-players.h device-flags.h \
- 	mtpz.h chdk_live_view.h chdk_ptp.h $(am__append_1) \
- 	$(am__append_2) $(am__append_3) $(am__append_4)
+ 	mtpz.h $(am__append_1) $(am__append_2) $(am__append_3) \
+ 	$(am__append_4)
  include_HEADERS = libmtp.h
-@@ -486,7 +486,6 @@ distclean-compile:
+@@ -373,7 +373,6 @@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmtp_la-libusb-glue.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmtp_la-libusb1-glue.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmtp_la-mtpz.Plo@am__quote@
@@ -260,17 +257,17 @@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmtp_la-ptp.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmtp_la-unicode.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmtp_la-util.Plo@am__quote@
-@@ -533,13 +532,6 @@ libmtp_la-util.lo: util.c
+@@ -419,13 +418,6 @@
  @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-util.lo `test -f 'util.c' || echo '$(srcdir)/'`util.c
+ @am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-util.lo `test -f 'util.c' || echo '$(srcdir)/'`util.c
  
 -libmtp_la-playlist-spl.lo: playlist-spl.c
--@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-playlist-spl.lo -MD -MP -MF $(DEPDIR)/libmtp_la-playlist-spl.Tpo -c -o libmtp_la-playlist-spl.lo `test -f 'playlist-spl.c' || echo '$(srcdir)/'`playlist-spl.c
--@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-playlist-spl.Tpo $(DEPDIR)/libmtp_la-playlist-spl.Plo
--@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='playlist-spl.c' object='libmtp_la-playlist-spl.lo' libtool=yes @AMDEPBACKSLASH@
+-@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-playlist-spl.lo -MD -MP -MF $(DEPDIR)/libmtp_la-playlist-spl.Tpo -c -o libmtp_la-playlist-spl.lo `test -f 'playlist-spl.c' || echo '$(srcdir)/'`playlist-spl.c
+-@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-playlist-spl.Tpo $(DEPDIR)/libmtp_la-playlist-spl.Plo
+-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='playlist-spl.c' object='libmtp_la-playlist-spl.lo' libtool=yes @AMDEPBACKSLASH@
 -@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
--@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-playlist-spl.lo `test -f 'playlist-spl.c' || echo '$(srcdir)/'`playlist-spl.c
+-@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-playlist-spl.lo `test -f 'playlist-spl.c' || echo '$(srcdir)/'`playlist-spl.c
 -
  libmtp_la-ptp.lo: ptp.c
- @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-ptp.lo -MD -MP -MF $(DEPDIR)/libmtp_la-ptp.Tpo -c -o libmtp_la-ptp.lo `test -f 'ptp.c' || echo '$(srcdir)/'`ptp.c
- @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-ptp.Tpo $(DEPDIR)/libmtp_la-ptp.Plo
+ @am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-ptp.lo -MD -MP -MF $(DEPDIR)/libmtp_la-ptp.Tpo -c -o libmtp_la-ptp.lo `test -f 'ptp.c' || echo '$(srcdir)/'`ptp.c
+ @am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-ptp.Tpo $(DEPDIR)/libmtp_la-ptp.Plo
diff --git a/patches/01_build_fixes.patch b/patches/01_build_fixes.patch
index a93039c..3630a22 100644
--- a/patches/01_build_fixes.patch
+++ b/patches/01_build_fixes.patch
@@ -1,12 +1,39 @@
-diff --git a/src/ptp.h b/src/ptp.h
-index 62938b4..f25618c 100644
---- a/src/ptp.h
-+++ b/src/ptp.h
-@@ -3238,7 +3238,7 @@ uint16_t ptp_olympus_getcameraid (PTPParams*, unsigned char**, unsigned int *);
+Index: src/unicode.c
+===================================================================
+--- src/unicode.c	(revision 148519)
++++ src/unicode.c	(working copy)
+@@ -29,7 +29,8 @@
+  *
+  */
+ 
+-#include <config.h>
++#include "config.h"
++
+ #include <stdlib.h>
+ #include <string.h>
+ #ifdef HAVE_ICONV
+Index: src/playlist-spl.c
+===================================================================
+--- src/playlist-spl.c	(revision 148519)
++++ src/playlist-spl.c	(working copy)
+@@ -21,7 +21,7 @@
+  * Boston, MA 02111-1307, USA.
+  */
+ 
+-#include <config.h>
++#include "config.h"
+ 
+ #include <stdio.h>
+ #include <stdlib.h> // mkstmp()
+Index: src/ptp.h
+===================================================================
+--- src/ptp.h	(revision 148519)
++++ src/ptp.h	(working copy)
+@@ -2808,7 +2808,7 @@
  static inline int
  ptp_operation_issupported(PTPParams* params, uint16_t operation)
  {
--	unsigned int i=0;
+-	int i=0;
 +	uint32_t i=0;
  
  	for (;i<params->deviceinfo.OperationsSupported_len;i++) {
diff --git a/patches/02_check_ptp_operation_support.patch b/patches/02_check_ptp_operation_support.patch
new file mode 100644
index 0000000..2338fef
--- /dev/null
+++ b/patches/02_check_ptp_operation_support.patch
@@ -0,0 +1,98 @@
+Index: src/libmtp.c
+===================================================================
+--- src/libmtp.c	(revision 148597)
++++ src/libmtp.c	(working copy)
+@@ -1144,6 +1144,9 @@
+   int supported = 0;
+   uint16_t ptp_prop = map_libmtp_property_to_ptp_property(property);
+ 
++  if (!ptp_operation_issupported(device->params, PTP_OC_MTP_GetObjectPropsSupported))
++    return 0;
++
+   ret = ptp_mtp_getobjectpropssupported(device->params, map_libmtp_type_to_ptp_type(filetype), &propcnt, &props);
+   if (ret != PTP_RC_OK) {
+     add_ptp_error_to_errorstack(device, ret, "LIBMTP_Is_Property_Supported(): could not get properties supported.");
+@@ -1974,40 +1977,42 @@
+   }
+ 
+   /* Determine if the object size supported is 32 or 64 bit wide */
+-  for (i=0;i<current_params->deviceinfo.ImageFormats_len;i++) {
+-    PTPObjectPropDesc opd;
++  if (ptp_operation_issupported(current_params,PTP_OC_MTP_GetObjectPropsSupported)) {
++    for (i=0;i<current_params->deviceinfo.ImageFormats_len;i++) {
++      PTPObjectPropDesc opd;
+ 
+-    if (ptp_mtp_getobjectpropdesc(current_params,
+-				  PTP_OPC_ObjectSize,
+-				  current_params->deviceinfo.ImageFormats[i],
+-				  &opd) != PTP_RC_OK) {
+-      LIBMTP_ERROR("LIBMTP PANIC: "
+-	     "could not inspect object property descriptions!\n");
+-    } else {
+-      if (opd.DataType == PTP_DTC_UINT32) {
+-	if (bs == 0) {
+-	  bs = 32;
+-	} else if (bs != 32) {
+-	  LIBMTP_ERROR("LIBMTP PANIC: "
+-		 "different objects support different object sizes!\n");
+-	  bs = 0;
+-	  break;
+-	}
+-      } else if (opd.DataType == PTP_DTC_UINT64) {
+-	if (bs == 0) {
+-	  bs = 64;
+-	} else if (bs != 64) {
+-	  LIBMTP_ERROR("LIBMTP PANIC: "
+-		 "different objects support different object sizes!\n");
+-	  bs = 0;
+-	  break;
+-	}
++      if (ptp_mtp_getobjectpropdesc(current_params,
++                                    PTP_OPC_ObjectSize,
++                                    current_params->deviceinfo.ImageFormats[i],
++                                    &opd) != PTP_RC_OK) {
++        LIBMTP_ERROR("LIBMTP PANIC: "
++                     "could not inspect object property descriptions!\n");
+       } else {
+-	// Ignore if other size.
+-	LIBMTP_ERROR("LIBMTP PANIC: "
+-	       "awkward object size data type: %04x\n", opd.DataType);
+-	bs = 0;
+-	break;
++        if (opd.DataType == PTP_DTC_UINT32) {
++          if (bs == 0) {
++            bs = 32;
++          } else if (bs != 32) {
++            LIBMTP_ERROR("LIBMTP PANIC: "
++                         "different objects support different object sizes!\n");
++            bs = 0;
++            break;
++          }
++        } else if (opd.DataType == PTP_DTC_UINT64) {
++          if (bs == 0) {
++            bs = 64;
++          } else if (bs != 64) {
++            LIBMTP_ERROR("LIBMTP PANIC: "
++                         "different objects support different object sizes!\n");
++            bs = 0;
++            break;
++          }
++        } else {
++          // Ignore if other size.
++          LIBMTP_ERROR("LIBMTP PANIC: "
++                       "awkward object size data type: %04x\n", opd.DataType);
++          bs = 0;
++          break;
++        }
+       }
+     }
+   }
+@@ -4107,7 +4112,7 @@
+ 	break;
+       }
+     }
+-  } else {
++  } else if (ptp_operation_issupported(params,PTP_OC_MTP_GetObjectPropsSupported)) {
+     uint16_t *props = NULL;
+     uint32_t propcnt = 0;
+     int ret;
diff --git a/patches/03_enable_ptp_support.patch b/patches/03_enable_ptp_support.patch
index 925f1ab..849c80b 100644
--- a/patches/03_enable_ptp_support.patch
+++ b/patches/03_enable_ptp_support.patch
@@ -1,8 +1,8 @@
-diff --git a/src/libusb1-glue.c b/src/libusb1-glue.c
-index 45572f7..187c485 100644
---- a/src/libusb1-glue.c
-+++ b/src/libusb1-glue.c
-@@ -221,15 +221,15 @@ static void free_mtpdevice_list(mtpdevice_list_t *devlist)
+Index: src/libusb1-glue.c
+===================================================================
+--- src/libusb1-glue.c	(revision 148597)
++++ src/libusb1-glue.c	(working copy)
+@@ -197,15 +197,15 @@
  }
  
  /**
@@ -22,15 +22,15 @@
   */
  static int probe_device_descriptor(libusb_device *dev, FILE *dumpfile)
  {
-@@ -313,7 +313,6 @@ static int probe_device_descriptor(libusb_device *dev, FILE *dumpfile)
- 	   * TODO: Check for Still Image Capture class with PIMA 15740
- 	   * protocol, also known as PTP
+@@ -289,7 +289,6 @@
+ 	   * Check for Still Image Capture class with PIMA 15740 protocol,
+ 	   * also known as PTP
  	   */
 -#if 0
  	  if (intf->bInterfaceClass == LIBUSB_CLASS_PTP
  	      && intf->bInterfaceSubClass == 0x01
  	      && intf->bInterfaceProtocol == 0x01) {
-@@ -322,17 +321,9 @@ static int probe_device_descriptor(libusb_device *dev, FILE *dumpfile)
+@@ -297,17 +296,9 @@
  	      fprintf(dumpfile, "   Found PTP device, check vendor "
  		      "extension...\n");
  	    }
diff --git a/patches/04_parse_extension_descriptor_null_check.patch b/patches/04_parse_extension_descriptor_null_check.patch
new file mode 100644
index 0000000..eef6826
--- /dev/null
+++ b/patches/04_parse_extension_descriptor_null_check.patch
@@ -0,0 +1,15 @@
+Index: src/libmtp.c
+===================================================================
+--- src/libmtp.c	(revision 148643)
++++ src/libmtp.c	(working copy)
+@@ -1728,6 +1728,10 @@
+   int start = 0;
+   int end = 0;
+ 
++  /* NULL on Canon A70 */
++  if (!desc)
++    return;
++
+   /* descriptors are divided by semicolons */
+   while (end < strlen(desc)) {
+     /* Skip past initial whitespace */
diff --git a/patches/07_fix_strcpy_in_ptp_unpack_ptptime.patch b/patches/07_fix_strcpy_in_ptp_unpack_ptptime.patch
new file mode 100644
index 0000000..4e7f8e8
--- /dev/null
+++ b/patches/07_fix_strcpy_in_ptp_unpack_ptptime.patch
@@ -0,0 +1,27 @@
+Index: src/ptp-pack.c
+===================================================================
+--- src/ptp-pack.c	(revision 148712)
++++ src/ptp-pack.c	(working copy)
+@@ -533,7 +533,7 @@
+ ptp_unpack_PTPTIME (const char *str) {
+ 	char ptpdate[40];
+ 	char tmp[5];
+-	int  ptpdatelen;
++	size_t  ptpdatelen;
+ 	struct tm tm;
+ 
+ 	if (!str)
+@@ -543,11 +543,12 @@
+ 		/*ptp_debug (params ,"datelen is larger then size of buffer", ptpdatelen, (int)sizeof(ptpdate));*/
+ 		return 0;
+ 	}
+-	strcpy (ptpdate, str);
+ 	if (ptpdatelen<15) {
+ 		/*ptp_debug (params ,"datelen is less than 15 (%d)", ptpdatelen);*/
+ 		return 0;
+ 	}
++	strncpy (ptpdate, str, sizeof(ptpdate));
++	ptpdate[sizeof(ptpdate) - 1] = '\0';
+ 
+ 	memset(&tm,0,sizeof(tm));
+ 	strncpy (tmp, ptpdate, 4);
diff --git a/patches/08_add_licenses.patch b/patches/08_add_licenses.patch
index 94532d6..97fd856 100644
--- a/patches/08_add_licenses.patch
+++ b/patches/08_add_licenses.patch
@@ -1,7 +1,7 @@
-diff --git a/examples/evolution-sync.sh b/examples/evolution-sync.sh
-index 53ca0b9..0c54a32 100755
---- a/examples/evolution-sync.sh
-+++ b/examples/evolution-sync.sh
+Index: examples/evolution-sync.sh
+===================================================================
+--- examples/evolution-sync.sh	(revision 148712)
++++ examples/evolution-sync.sh	(working copy)
 @@ -1,4 +1,21 @@
  #!/bin/bash
 +#
@@ -24,19 +24,51 @@
  
  # Example evolution synchronization script by Nicolas Tetreault,
  # modified by Linus Walleij.
-diff --git a/ltmain.sh b/ltmain.sh
-index 63ae69d..96b101f 100644
---- a/ltmain.sh
-+++ b/ltmain.sh
+Index: src/ptp-pack.c
+===================================================================
+--- src/ptp-pack.c	(revision 149246)
++++ src/ptp-pack.c	(working copy)
+@@ -1,3 +1,27 @@
++/* ptp-pack.c
++ *
++ * Copyright (C) 2001-2004 Mariusz Woloszyn <emsi@ipartners.pl>
++ * Copyright (C) 2003-2012 Marcus Meissner <marcus@jet.franken.de>
++ * Copyright (C) 2006-2008 Linus Walleij <triad@df.lth.se>
++ * Copyright (C) 2007 Tero Saarni <tero.saarni@gmail.com>
++ * Copyright (C) 2009 Axel Waggershauser <awagger@web.de>
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2 of the License, or (at your option) any later version.
++ *
++ * This library 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the
++ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ * Boston, MA 02111-1307, USA.
++ */
++
+ /* currently this file is included into ptp.c */
+ 
+ #ifdef HAVE_ICONV
+Index: ltmain.sh
+===================================================================
+--- ltmain.sh	(revision 148712)
++++ ltmain.sh	(working copy)
 @@ -1,4 +1,3 @@
 -
  # libtool (GNU libtool) 2.4.2
  # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
  
-diff --git a/doc/examples.h b/doc/examples.h
-index 3e88ca4..d6dbbcd 100644
---- a/doc/examples.h
-+++ b/doc/examples.h
+Index: doc/examples.h
+===================================================================
+--- doc/examples.h	(revision 148712)
++++ doc/examples.h	(working copy)
 @@ -1,3 +1,23 @@
 +/**
 + *
@@ -61,10 +93,10 @@
  /*
   * List examples here...
   */
-diff --git a/doc/mainpage.h b/doc/mainpage.h
-index 19ef339..5e83263 100644
---- a/doc/mainpage.h
-+++ b/doc/mainpage.h
+Index: doc/mainpage.h
+===================================================================
+--- doc/mainpage.h	(revision 148712)
++++ doc/mainpage.h	(working copy)
 @@ -1,4 +1,24 @@
  /**
 + *
diff --git a/patches/09_do_not_build_udev_and_examples.patch b/patches/09_do_not_build_udev_and_examples.patch
index 74036d5..890c642 100644
--- a/patches/09_do_not_build_udev_and_examples.patch
+++ b/patches/09_do_not_build_udev_and_examples.patch
@@ -1,76 +1,62 @@
-diff --git a/Makefile.am b/Makefile.am
-index 7b7e06b..ba8f69a 100644
---- a/Makefile.am
-+++ b/Makefile.am
+Index: Makefile.am
+===================================================================
+--- Makefile.am	(revision 148712)
++++ Makefile.am	(working copy)
 @@ -1,4 +1,4 @@
 -SUBDIRS=src examples util doc
 +SUBDIRS=src util doc
  ACLOCAL_AMFLAGS=-I m4
  
  pkgconfigdir=$(libdir)/pkgconfig
-@@ -8,24 +8,24 @@ EXTRA_DIST=libmtp.pc libmtp.sh COPYING README.windows.txt
+@@ -8,17 +8,17 @@
  
  # This stuff only makes sense on Linux so only
  # build and ship it on Linux.
 -if USE_LINUX
 -udevrulesdir=@UDEV@/rules.d
--hwdbdir=@UDEV@/hwdb.d
 -udevrules_DATA=@UDEV_RULES@
--hwdb_DATA=69-libmtp.hwdb
 -noinst_DATA=libmtp.usermap libmtp.fdi
 -
 -libmtp.usermap: util/mtp-hotplug
 -	util/mtp-hotplug > libmtp.usermap
--
 -@UDEV_RULES@: util/mtp-hotplug
 -	util/mtp-hotplug -u -p"@UDEV@" @UDEV_GROUP@ @UDEV_MODE@ > @UDEV_RULES@
--
 -libmtp.fdi: util/mtp-hotplug
 -	util/mtp-hotplug -H > libmtp.fdi
 -
--$(hwdb_DATA): util/mtp-hotplug
--	util/mtp-hotplug -w > $(hwdb_DATA)
--
--CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi libmtp.hwdb
+-CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi
 -endif
 +#if USE_LINUX
 +#udevrulesdir=@UDEV@/rules.d
-+#hwdbdir=@UDEV@/hwdb.d
 +#udevrules_DATA=@UDEV_RULES@
-+#hwdb_DATA=69-libmtp.hwdb
 +#noinst_DATA=libmtp.usermap libmtp.fdi
 +#
 +#libmtp.usermap: util/mtp-hotplug
 +#	util/mtp-hotplug > libmtp.usermap
-+#
 +#@UDEV_RULES@: util/mtp-hotplug
 +#	util/mtp-hotplug -u -p"@UDEV@" @UDEV_GROUP@ @UDEV_MODE@ > @UDEV_RULES@
-+#
 +#libmtp.fdi: util/mtp-hotplug
 +#	util/mtp-hotplug -H > libmtp.fdi
 +#
-+#$(hwdb_DATA): util/mtp-hotplug
-+#	util/mtp-hotplug -w > $(hwdb_DATA)
-+#
-+#CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi libmtp.hwdb
++#CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi
 +#endif
-diff --git a/Makefile.in b/Makefile.in
-index c85503a..4575cba 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -159,9 +159,8 @@ am__uninstall_files_from_dir = { \
+Index: Makefile.in
+===================================================================
+--- Makefile.in	(revision 148712)
++++ Makefile.in	(working copy)
+@@ -91,9 +91,8 @@
      || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
           $(am__cd) "$$dir" && rm -f $$files; }; \
    }
--am__installdirs = "$(DESTDIR)$(hwdbdir)" "$(DESTDIR)$(pkgconfigdir)" \
+-am__installdirs = "$(DESTDIR)$(pkgconfigdir)" \
 -	"$(DESTDIR)$(udevrulesdir)"
--DATA = $(hwdb_DATA) $(noinst_DATA) $(pkgconfig_DATA) $(udevrules_DATA)
+-DATA = $(noinst_DATA) $(pkgconfig_DATA) $(udevrules_DATA)
 +am__installdirs = "$(DESTDIR)$(pkgconfigdir)"
 +DATA = $(pkgconfig_DATA)
  RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
    distclean-recursive maintainer-clean-recursive
- am__recursive_targets = \
-@@ -370,20 +369,11 @@ target_alias = @target_alias@
+ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+@@ -272,18 +271,11 @@
  top_build_prefix = @top_build_prefix@
  top_builddir = @top_builddir@
  top_srcdir = @top_srcdir@
@@ -84,25 +70,20 @@
 -# This stuff only makes sense on Linux so only
 -# build and ship it on Linux.
 -@USE_LINUX_TRUE@udevrulesdir = @UDEV@/rules.d
--@USE_LINUX_TRUE@hwdbdir = @UDEV@/hwdb.d
 -@USE_LINUX_TRUE@udevrules_DATA = @UDEV_RULES@
--@USE_LINUX_TRUE@hwdb_DATA = 69-libmtp.hwdb
 -@USE_LINUX_TRUE@noinst_DATA = libmtp.usermap libmtp.fdi
--@USE_LINUX_TRUE@CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi libmtp.hwdb
+-@USE_LINUX_TRUE@CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi
  all: config.h
  	$(MAKE) $(AM_MAKEFLAGS) all-recursive
  
-@@ -493,27 +483,6 @@ uninstall-pkgconfigDATA:
+@@ -370,25 +362,7 @@
  	@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
  	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
  	dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
 -install-udevrulesDATA: $(udevrules_DATA)
 -	@$(NORMAL_INSTALL)
+-	test -z "$(udevrulesdir)" || $(MKDIR_P) "$(DESTDIR)$(udevrulesdir)"
 -	@list='$(udevrules_DATA)'; test -n "$(udevrulesdir)" || list=; \
--	if test -n "$$list"; then \
--	  echo " $(MKDIR_P) '$(DESTDIR)$(udevrulesdir)'"; \
--	  $(MKDIR_P) "$(DESTDIR)$(udevrulesdir)" || exit 1; \
--	fi; \
 -	for p in $$list; do \
 -	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 -	  echo "$$d$$p"; \
@@ -111,25 +92,26 @@
 -	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(udevrulesdir)'"; \
 -	  $(INSTALL_DATA) $$files "$(DESTDIR)$(udevrulesdir)" || exit $$?; \
 -	done
--
+ 
 -uninstall-udevrulesDATA:
 -	@$(NORMAL_UNINSTALL)
 -	@list='$(udevrules_DATA)'; test -n "$(udevrulesdir)" || list=; \
 -	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 -	dir='$(DESTDIR)$(udevrulesdir)'; $(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.
-@@ -814,7 +783,7 @@ check: check-recursive
+ # into them and run `make' without going through this Makefile.
+ # To change the values of `make' variables: instead of editing Makefiles,
+@@ -719,7 +693,7 @@
  all-am: Makefile $(DATA) config.h
  installdirs: installdirs-recursive
  installdirs-am:
--	for dir in "$(DESTDIR)$(hwdbdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(udevrulesdir)"; do \
+-	for dir in "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(udevrulesdir)"; do \
 +	for dir in "$(DESTDIR)$(pkgconfigdir)"; do \
  	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
  	done
  install: install-recursive
-@@ -839,7 +808,6 @@ install-strip:
+@@ -744,7 +718,6 @@
  mostlyclean-generic:
  
  clean-generic:
@@ -137,73 +119,72 @@
  
  distclean-generic:
  	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-@@ -870,8 +838,7 @@ info: info-recursive
+@@ -775,7 +748,7 @@
  
  info-am:
  
--install-data-am: install-hwdbDATA install-pkgconfigDATA \
--	install-udevrulesDATA
+-install-data-am: install-pkgconfigDATA install-udevrulesDATA
 +install-data-am: install-pkgconfigDATA
  
  install-dvi: install-dvi-recursive
  
-@@ -917,8 +884,7 @@ ps: ps-recursive
+@@ -821,7 +794,7 @@
  
  ps-am:
  
--uninstall-am: uninstall-hwdbDATA uninstall-pkgconfigDATA \
--	uninstall-udevrulesDATA
+-uninstall-am: uninstall-pkgconfigDATA uninstall-udevrulesDATA
 +uninstall-am: uninstall-pkgconfigDATA
  
- .MAKE: $(am__recursive_targets) all install-am install-strip
- 
-@@ -931,30 +897,18 @@ uninstall-am: uninstall-hwdbDATA uninstall-pkgconfigDATA \
- 	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-hwdbDATA install-info \
-+	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 \
--	install-udevrulesDATA installcheck installcheck-am installdirs \
-+	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 \
--	uninstall-hwdbDATA uninstall-pkgconfigDATA \
+ .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
+ 	ctags-recursive install-am install-strip tags-recursive
+@@ -837,20 +810,29 @@
+ 	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 install-udevrulesDATA installcheck \
+-	installcheck-am installdirs installdirs-am maintainer-clean \
++	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 \
 -	uninstall-udevrulesDATA
-+	uninstall-pkgconfigDATA
- 
- .PRECIOUS: Makefile
++	uninstall uninstall-am uninstall-pkgconfigDATA
  
  
 -@USE_LINUX_TRUE@libmtp.usermap: util/mtp-hotplug
 -@USE_LINUX_TRUE@	util/mtp-hotplug > libmtp.usermap
--
 -@USE_LINUX_TRUE@@UDEV_RULES@: util/mtp-hotplug
 -@USE_LINUX_TRUE@	util/mtp-hotplug -u -p"@UDEV@" @UDEV_GROUP@ @UDEV_MODE@ > @UDEV_RULES@
--
 -@USE_LINUX_TRUE@libmtp.fdi: util/mtp-hotplug
 -@USE_LINUX_TRUE@	util/mtp-hotplug -H > libmtp.fdi
--
--@USE_LINUX_TRUE@$(hwdb_DATA): util/mtp-hotplug
--@USE_LINUX_TRUE@	util/mtp-hotplug -w > $(hwdb_DATA)
++# This stuff only makes sense on Linux so only
++# build and ship it on Linux.
++#if USE_LINUX
++#udevrulesdir=@UDEV@/rules.d
++#udevrules_DATA=@UDEV_RULES@
++#noinst_DATA=libmtp.usermap libmtp.fdi
++#
++#libmtp.usermap: util/mtp-hotplug
++#	util/mtp-hotplug > libmtp.usermap
++#@UDEV_RULES@: util/mtp-hotplug
++#	util/mtp-hotplug -u -p"@UDEV@" @UDEV_GROUP@ @UDEV_MODE@ > @UDEV_RULES@
++#libmtp.fdi: util/mtp-hotplug
++#	util/mtp-hotplug -H > libmtp.fdi
++#
++#CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi
++#endif
  
  # Tell versions [3.59,3.63) of GNU make to not export all variables.
  # Otherwise a system limit (for SysV at least) may be exceeded.
-diff --git a/util/Makefile.am b/util/Makefile.am
-index 11f3640..f39c888 100644
---- a/util/Makefile.am
-+++ b/util/Makefile.am
+Index: util/Makefile.am
+===================================================================
+--- util/Makefile.am	(revision 148712)
++++ util/Makefile.am	(working copy)
 @@ -1,11 +1,11 @@
 -if USE_LINUX
 -bin_PROGRAMS=mtp-hotplug
 -mtp_hotplug_SOURCES=mtp-hotplug.c
--
--mtp_probedir=@UDEV@
--mtp_probe_PROGRAMS=mtp-probe
--mtp_probe_SOURCES=mtp-probe.c
--endif
 +#if USE_LINUX
 +#bin_PROGRAMS=mtp-hotplug
 +#mtp_hotplug_SOURCES=mtp-hotplug.c
@@ -213,22 +194,42 @@
 +#mtp_probe_SOURCES=mtp-probe.c
 +#endif
  
+-mtp_probedir=@UDEV@
+-mtp_probe_PROGRAMS=mtp-probe
+-mtp_probe_SOURCES=mtp-probe.c
+-endif
+-
  AM_CPPFLAGS=-I$(top_builddir)/src
  LDADD=../src/libmtp.la
-diff --git a/util/Makefile.in b/util/Makefile.in
-index 5baca52..9b217ed 100644
---- a/util/Makefile.in
-+++ b/util/Makefile.in
-@@ -88,8 +88,6 @@ PRE_UNINSTALL = :
+Index: util/Makefile.in
+===================================================================
+--- util/Makefile.in	(revision 148712)
++++ util/Makefile.in	(working copy)
+@@ -15,6 +15,14 @@
+ 
+ @SET_MAKE@
+ 
++#if USE_LINUX
++#bin_PROGRAMS=mtp-hotplug
++#mtp_hotplug_SOURCES=mtp-hotplug.c
++#
++#mtp_probedir=@UDEV@
++#mtp_probe_PROGRAMS=mtp-probe
++#mtp_probe_SOURCES=mtp-probe.c
++#endif
+ VPATH = @srcdir@
+ pkgdatadir = $(datadir)/@PACKAGE@
+ pkgincludedir = $(includedir)/@PACKAGE@
+@@ -34,8 +42,6 @@
  POST_UNINSTALL = :
  build_triplet = @build@
  host_triplet = @host@
 -@USE_LINUX_TRUE@bin_PROGRAMS = mtp-hotplug$(EXEEXT)
 -@USE_LINUX_TRUE@mtp_probe_PROGRAMS = mtp-probe$(EXEEXT)
  subdir = util
+ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
- am__aclocal_m4_deps = $(top_srcdir)/m4/byteorder.m4 \
-@@ -104,83 +102,8 @@ mkinstalldirs = $(install_sh) -d
+@@ -50,36 +56,8 @@
  CONFIG_HEADER = $(top_builddir)/config.h
  CONFIG_CLEAN_FILES =
  CONFIG_CLEAN_VPATH_FILES =
@@ -239,82 +240,35 @@
 -mtp_hotplug_OBJECTS = $(am_mtp_hotplug_OBJECTS)
 -mtp_hotplug_LDADD = $(LDADD)
 -mtp_hotplug_DEPENDENCIES = ../src/libmtp.la
--AM_V_lt = $(am__v_lt_@AM_V@)
--am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
--am__v_lt_0 = --silent
--am__v_lt_1 = 
 -am__mtp_probe_SOURCES_DIST = mtp-probe.c
 -@USE_LINUX_TRUE@am_mtp_probe_OBJECTS = mtp-probe.$(OBJEXT)
 -mtp_probe_OBJECTS = $(am_mtp_probe_OBJECTS)
 -mtp_probe_LDADD = $(LDADD)
 -mtp_probe_DEPENDENCIES = ../src/libmtp.la
--AM_V_P = $(am__v_P_@AM_V@)
--am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
--am__v_P_0 = false
--am__v_P_1 = :
--AM_V_GEN = $(am__v_GEN_@AM_V@)
--am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
--am__v_GEN_0 = @echo "  GEN     " $@;
--am__v_GEN_1 = 
--AM_V_at = $(am__v_at_@AM_V@)
--am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
--am__v_at_0 = @
--am__v_at_1 = 
 -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 -depcomp = $(SHELL) $(top_srcdir)/depcomp
 -am__depfiles_maybe = depfiles
 -am__mv = mv -f
 -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 -	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
--LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
--	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
--	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
--	$(AM_CFLAGS) $(CFLAGS)
--AM_V_CC = $(am__v_CC_@AM_V@)
--am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
--am__v_CC_0 = @echo "  CC      " $@;
--am__v_CC_1 = 
+-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 -CCLD = $(CC)
--LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
--	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
--	$(AM_LDFLAGS) $(LDFLAGS) -o $@
--AM_V_CCLD = $(am__v_CCLD_@AM_V@)
--am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
--am__v_CCLD_0 = @echo "  CCLD    " $@;
--am__v_CCLD_1 = 
+-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+-	$(LDFLAGS) -o $@
 -SOURCES = $(mtp_hotplug_SOURCES) $(mtp_probe_SOURCES)
 -DIST_SOURCES = $(am__mtp_hotplug_SOURCES_DIST) \
 -	$(am__mtp_probe_SOURCES_DIST)
--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
 +SOURCES =
 +DIST_SOURCES =
- am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
  DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
  ACLOCAL = @ACLOCAL@
-@@ -314,15 +237,11 @@ target_alias = @target_alias@
+ AMTAR = @AMTAR@
+@@ -211,15 +189,11 @@
  top_build_prefix = @top_build_prefix@
  top_builddir = @top_builddir@
  top_srcdir = @top_srcdir@
@@ -330,25 +284,20 @@
  $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
  	@for dep in $?; do \
  	  case '$(am__configure_deps)' in \
-@@ -352,142 +271,6 @@ $(top_srcdir)/configure:  $(am__configure_deps)
+@@ -250,187 +224,19 @@
  $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
  	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
  $(am__aclocal_m4_deps):
 -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 } \
@@ -363,14 +312,13 @@
 -	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
 -	    } \
 -	; done
--
+ 
 -uninstall-binPROGRAMS:
 -	@$(NORMAL_UNINSTALL)
 -	@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
@@ -385,19 +333,14 @@
 -	rm -f $$list
 -install-mtp_probePROGRAMS: $(mtp_probe_PROGRAMS)
 -	@$(NORMAL_INSTALL)
+-	test -z "$(mtp_probedir)" || $(MKDIR_P) "$(DESTDIR)$(mtp_probedir)"
 -	@list='$(mtp_probe_PROGRAMS)'; test -n "$(mtp_probedir)" || list=; \
--	if test -n "$$list"; then \
--	  echo " $(MKDIR_P) '$(DESTDIR)$(mtp_probedir)'"; \
--	  $(MKDIR_P) "$(DESTDIR)$(mtp_probedir)" || 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 } \
@@ -418,8 +361,7 @@
 -	@list='$(mtp_probe_PROGRAMS)'; test -n "$(mtp_probedir)" || 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)$(mtp_probedir)' && rm -f" $$files ")"; \
 -	cd "$(DESTDIR)$(mtp_probedir)" && rm -f $$files
@@ -432,14 +374,12 @@
 -	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
 -	echo " rm -f" $$list; \
 -	rm -f $$list
--
 -mtp-hotplug$(EXEEXT): $(mtp_hotplug_OBJECTS) $(mtp_hotplug_DEPENDENCIES) $(EXTRA_mtp_hotplug_DEPENDENCIES) 
 -	@rm -f mtp-hotplug$(EXEEXT)
--	$(AM_V_CCLD)$(LINK) $(mtp_hotplug_OBJECTS) $(mtp_hotplug_LDADD) $(LIBS)
--
+-	$(LINK) $(mtp_hotplug_OBJECTS) $(mtp_hotplug_LDADD) $(LIBS)
 -mtp-probe$(EXEEXT): $(mtp_probe_OBJECTS) $(mtp_probe_DEPENDENCIES) $(EXTRA_mtp_probe_DEPENDENCIES) 
 -	@rm -f mtp-probe$(EXEEXT)
--	$(AM_V_CCLD)$(LINK) $(mtp_probe_OBJECTS) $(mtp_probe_LDADD) $(LIBS)
+-	$(LINK) $(mtp_probe_OBJECTS) $(mtp_probe_LDADD) $(LIBS)
 -
 -mostlyclean-compile:
 -	-rm -f *.$(OBJEXT)
@@ -451,39 +391,53 @@
 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtp-probe.Po@am__quote@
 -
 -.c.o:
--@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
--@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
--@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+-@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+-@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 -@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
--@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+-@am__fastdepCC_FALSE@	$(COMPILE) -c $<
 -
 -.c.obj:
--@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
--@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
--@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+-@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+-@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 -@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
--@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+-@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
 -
 -.c.lo:
--@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
--@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
--@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+-@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+-@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+-@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 -@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
--@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
- 
+-@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+-
  mostlyclean-libtool:
  	-rm -f *.lo
-@@ -497,37 +280,12 @@ clean-libtool:
  
- ID: $(am__tagged_files)
- 	$(am__define_uniq_tagged_files); mkid -fID $$unique
--tags: tags-am
--TAGS: tags
+ clean-libtool:
+ 	-rm -rf .libs _libs
 -
--tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+-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:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+-		$(TAGS_FILES) $(LISP)
 -	set x; \
 -	here=`pwd`; \
--	$(am__define_uniq_tagged_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; }; }'`; \
 -	shift; \
 -	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 -	  test -n "$$unique" || unique=$$empty_fix; \
@@ -495,31 +449,24 @@
 -	      $$unique; \
 -	  fi; \
 -	fi
--ctags: ctags-am
--
--CTAGS: ctags
--ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
--	$(am__define_uniq_tagged_files); \
+ 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; }; }'`; \
 -	test -z "$(CTAGS_ARGS)$$unique" \
 -	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 -	     $$unique
--
++CTAGS:
+ 
 -GTAGS:
 -	here=`$(am__cd) $(top_builddir) && pwd` \
 -	  && $(am__cd) $(top_srcdir) \
 -	  && gtags -i $(GTAGS_ARGS) "$$here"
-+tags: TAGS
-+TAGS:
-+
-+ctags: CTAGS
-+CTAGS:
-+
- cscopelist: cscopelist-am
- 
- cscopelist-am: $(am__tagged_files)
-@@ -544,9 +302,6 @@ cscopelist-am: $(am__tagged_files)
- 	  fi; \
- 	done >> $(top_builddir)/cscope.files
  
 -distclean-tags:
 -	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -527,7 +474,7 @@
  distdir: $(DISTFILES)
  	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
  	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-@@ -579,11 +334,8 @@ distdir: $(DISTFILES)
+@@ -463,11 +269,8 @@
  	done
  check-am: all-am
  check: check-am
@@ -540,7 +487,7 @@
  install: install-am
  install-exec: install-exec-am
  install-data: install-data-am
-@@ -616,14 +368,11 @@ maintainer-clean-generic:
+@@ -500,14 +303,11 @@
  	@echo "it deletes files that may require special tools to rebuild."
  clean: clean-am
  
@@ -557,7 +504,7 @@
  
  dvi: dvi-am
  
-@@ -637,13 +386,13 @@ info: info-am
+@@ -521,13 +321,13 @@
  
  info-am:
  
@@ -573,7 +520,7 @@
  
  install-html: install-html-am
  
-@@ -666,14 +415,12 @@ install-ps-am:
+@@ -550,14 +350,12 @@
  installcheck-am:
  
  maintainer-clean: maintainer-clean-am
@@ -589,7 +536,7 @@
  
  pdf: pdf-am
  
-@@ -683,25 +430,24 @@ ps: ps-am
+@@ -567,25 +365,20 @@
  
  ps-am:
  
@@ -598,27 +545,29 @@
  
  .MAKE: install-am install-strip
  
--.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
--	clean-binPROGRAMS clean-generic clean-libtool \
--	clean-mtp_probePROGRAMS cscopelist-am ctags ctags-am distclean \
-+.PHONY: all all-am check check-am clean \
-+	clean-generic clean-libtool \
-+	cscopelist-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 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-mtp_probePROGRAMS \
-+	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-compile mostlyclean-generic mostlyclean-libtool \
--	pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
--	uninstall-binPROGRAMS uninstall-mtp_probePROGRAMS
-+	pdf pdf-am ps ps-am uninstall uninstall-am
+-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+-	clean-generic clean-libtool clean-mtp_probePROGRAMS 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 \
++.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-mtp_probePROGRAMS 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 \
+-	uninstall-mtp_probePROGRAMS
++	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
  
- .PRECIOUS: Makefile
  
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/patches/10_remove_nexus_s_from_device_list.patch b/patches/10_remove_nexus_s_from_device_list.patch
index d716427..f75183e 100644
--- a/patches/10_remove_nexus_s_from_device_list.patch
+++ b/patches/10_remove_nexus_s_from_device_list.patch
@@ -1,17 +1,14 @@
-diff --git a/src/music-players.h b/src/music-players.h
-index fdd4654..c753e36 100644
---- a/src/music-players.h
-+++ b/src/music-players.h
-@@ -2257,12 +2257,6 @@
+Index: src/music-players.h
+===================================================================
+--- src/music-players.h	(revision 149707)
++++ src/music-players.h	(working copy)
+@@ -1553,9 +1553,6 @@
    // Reported by anonymous Sourceforge user
    { "Google Inc (for Asus)", 0x18d1, "TF101 Transformer", 0x4e0f,
        DEVICE_FLAGS_ANDROID_BUGS },
--  // 0x4e21 (Nexus S) is a USB Mass Storage device.
--  { "Google Inc (for Samsung)", 0x18d1, "Nexus S (MTP)", 0x4e25,
--      DEVICE_FLAGS_ANDROID_BUGS },
--  // 0x4e26 is also used by "Ramos W30HD Pro Quad Core"
--  { "Google Inc (for Samsung)", 0x18d1, "Nexus S (MTP+ADB)", 0x4e26,
+-  // Reported by Laurent Artaud <laurenta@users.sourceforge.net>
+-  { "Google Inc (for Samsung)", 0x18d1, "Nexus S", 0x4e21,
 -      DEVICE_FLAGS_ANDROID_BUGS },
    // Reported by Chris Smith <tcgsmythe@users.sourceforge.net>
-   { "Google Inc (for Asus)", 0x18d1, "Nexus 7 (MTP)", 0x4e41,
+   { "Google Inc (for Asus)", 0x18d1, "Nexus 7", 0x4e41,
        DEVICE_FLAGS_ANDROID_BUGS },
diff --git a/patches/11_add_gyp_file_and_generated_headers.patch b/patches/11_add_gyp_file_and_generated_headers.patch
new file mode 100644
index 0000000..473eb78
--- /dev/null
+++ b/patches/11_add_gyp_file_and_generated_headers.patch
@@ -0,0 +1,1489 @@
+Index: config.h
+===================================================================
+--- config.h	(revision 0)
++++ config.h	(revision 0)
+@@ -0,0 +1,211 @@
++/* config.h.  Generated from config.h.in by configure.  */
++/* config.h.in.  Generated from configure.ac by autoheader.  */
++
++/* Define if building universal (internal helper macro) */
++/* #undef AC_APPLE_UNIVERSAL_BUILD */
++
++/* Define to 1 if you have the <arpa/inet.h> header file. */
++#define HAVE_ARPA_INET_H 1
++
++/* Define to 1 if you have the `basename' function. */
++#define HAVE_BASENAME 1
++
++/* Define to 1 if you have the <byteswap.h> header file. */
++#define HAVE_BYTESWAP_H 1
++
++/* Define to 1 if you have the <ctype.h> header file. */
++#define HAVE_CTYPE_H 1
++
++/* Define to 1 if you have the <dlfcn.h> header file. */
++#define HAVE_DLFCN_H 1
++
++/* Define to 1 if you have the <errno.h> header file. */
++#define HAVE_ERRNO_H 1
++
++/* Define to 1 if you have the <fcntl.h> header file. */
++#define HAVE_FCNTL_H 1
++
++/* Define to 1 if you have the <getopt.h> header file. */
++#define HAVE_GETOPT_H 1
++
++/* Define if you have the iconv() function and it works. */
++#define HAVE_ICONV 1
++
++/* Define to 1 if you have the <inttypes.h> header file. */
++#define HAVE_INTTYPES_H 1
++
++/* Define to 1 if you have the <langinfo.h> header file. */
++#define HAVE_LANGINFO_H 1
++
++/* Define to 1 if you have the `gcrypt' library (-lgcrypt). */
++#define HAVE_LIBGCRYPT 1
++
++/* Define to 1 if you have the <libgen.h> header file. */
++#define HAVE_LIBGEN_H 1
++
++/* Have libusb 0.x */
++/* #undef HAVE_LIBUSB0 */
++
++/* Have libusb 1.0 */
++#define HAVE_LIBUSB1 /**/
++
++/* Define to 1 if you have the <limits.h> header file. */
++#define HAVE_LIMITS_H 1
++
++/* Define to 1 if you have the <locale.h> header file. */
++#define HAVE_LOCALE_H 1
++
++/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
++   to 0 otherwise. */
++#define HAVE_MALLOC 1
++
++/* Define to 1 if you have the <memory.h> header file. */
++#define HAVE_MEMORY_H 1
++
++/* Define to 1 if you have the `memset' function. */
++#define HAVE_MEMSET 1
++
++/* Define to 1 if you have the `mkstemp' function. */
++#define HAVE_MKSTEMP 1
++
++/* Have libopenusb 1.0 */
++/* #undef HAVE_OPENUSB */
++
++/* Define to 1 if you have the `select' function. */
++#define HAVE_SELECT 1
++
++/* Define to 1 if `stat' has the bug that it succeeds when given the
++   zero-length file name argument. */
++/* #undef HAVE_STAT_EMPTY_STRING_BUG */
++
++/* Define to 1 if you have the <stdint.h> header file. */
++#define HAVE_STDINT_H 1
++
++/* Define to 1 if you have the <stdio.h> header file. */
++#define HAVE_STDIO_H 1
++
++/* Define to 1 if you have the <stdlib.h> header file. */
++#define HAVE_STDLIB_H 1
++
++/* Define to 1 if you have the `strdup' function. */
++#define HAVE_STRDUP 1
++
++/* Define to 1 if you have the `strerror' function. */
++#define HAVE_STRERROR 1
++
++/* Define to 1 if you have the <strings.h> header file. */
++#define HAVE_STRINGS_H 1
++
++/* Define to 1 if you have the <string.h> header file. */
++#define HAVE_STRING_H 1
++
++/* Define to 1 if you have the `strndup' function. */
++#define HAVE_STRNDUP 1
++
++/* Define to 1 if you have the `strrchr' function. */
++#define HAVE_STRRCHR 1
++
++/* Define to 1 if you have the `strtoul' function. */
++#define HAVE_STRTOUL 1
++
++/* Define to 1 if `st_blksize' is a member of `struct stat'. */
++#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
++
++/* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use
++   `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */
++#define HAVE_ST_BLKSIZE 1
++
++/* Define to 1 if you have the <sys/stat.h> header file. */
++#define HAVE_SYS_STAT_H 1
++
++/* Define to 1 if you have the <sys/time.h> header file. */
++#define HAVE_SYS_TIME_H 1
++
++/* Define to 1 if you have the <sys/types.h> header file. */
++#define HAVE_SYS_TYPES_H 1
++
++/* Define to 1 if you have the <sys/uio.h> header file. */
++#define HAVE_SYS_UIO_H 1
++
++/* Define to 1 if you have the <unistd.h> header file. */
++#define HAVE_UNISTD_H 1
++
++/* Define to 1 if you have the `usleep' function. */
++#define HAVE_USLEEP 1
++
++/* Define as const if the declaration of iconv() needs const. */
++#define ICONV_CONST 
++
++/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
++   slash. */
++#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
++
++/* Define to the sub-directory in which libtool stores uninstalled libraries.
++   */
++#define LT_OBJDIR ".libs/"
++
++/* Name of package */
++#define PACKAGE "libmtp"
++
++/* Define to the address where bug reports for this package should be sent. */
++#define PACKAGE_BUGREPORT "libmtp-discuss@lists.sourceforge.net"
++
++/* Define to the full name of this package. */
++#define PACKAGE_NAME "libmtp"
++
++/* Define to the full name and version of this package. */
++#define PACKAGE_STRING "libmtp 1.1.5"
++
++/* Define to the one symbol short name of this package. */
++#define PACKAGE_TARNAME "libmtp"
++
++/* Define to the home page for this package. */
++#define PACKAGE_URL ""
++
++/* Define to the version of this package. */
++#define PACKAGE_VERSION "1.1.5"
++
++/* Define as the return type of signal handlers (`int' or `void'). */
++#define RETSIGTYPE void
++
++/* Define to 1 if you have the ANSI C header files. */
++#define STDC_HEADERS 1
++
++/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
++#define TIME_WITH_SYS_TIME 1
++
++/* Enable MTPZ functionality */
++/* #undef USE_MTPZ */
++
++/* Version number of package */
++#define VERSION "1.1.5"
++
++/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
++   significant byte first (like Motorola and SPARC, unlike Intel). */
++#if defined AC_APPLE_UNIVERSAL_BUILD
++# if defined __BIG_ENDIAN__
++#  define WORDS_BIGENDIAN 1
++# endif
++#else
++# ifndef WORDS_BIGENDIAN
++/* #  undef WORDS_BIGENDIAN */
++# endif
++#endif
++
++/* Number of bits in a file offset, on hosts where this is settable. */
++/* #undef _FILE_OFFSET_BITS */
++
++/* Define for large files, on AIX-style hosts. */
++/* #undef _LARGE_FILES */
++
++/* Define to empty if `const' does not conform to ANSI C. */
++/* #undef const */
++
++/* Define to rpl_malloc if the replacement function should be used. */
++/* #undef malloc */
++
++/* Define to `long int' if <sys/types.h> does not define. */
++/* #undef off_t */
++
++/* Define to `unsigned int' if <sys/types.h> does not define. */
++/* #undef size_t */
+
+Property changes on: config.h
+___________________________________________________________________
+Added: svn:eol-style
+   + LF
+
+Index: libmtp.gyp
+===================================================================
+--- libmtp.gyp	(revision 0)
++++ libmtp.gyp	(revision 0)
+@@ -0,0 +1,71 @@
++# Copyright (c) 2012 The Chromium Authors. All rights reserved.
++# Use of this source code is governed by a BSD-style license that can be
++# found in the LICENSE file.
++
++{
++  'variables': {
++    'use_system_libmtp%': 0,
++  },
++  'conditions': [
++    ['use_system_libmtp==0', {
++      'targets': [
++        {
++          'target_name': 'libmtp',
++          'type': 'shared_library',
++          'product_name': 'mtp',
++          'dependencies': [
++            '../../third_party/libusb/libusb.gyp:libusb',
++          ],
++          'sources': [
++            'src/libmtp.c',
++            'src/libusb1-glue.c',
++            'src/ptp.c',
++            'src/unicode.c',
++            'src/util.c',
++          ],
++          'cflags!': ['-fvisibility=hidden'],
++          'include_dirs': [
++            '.',
++            'src',
++          ],
++          'direct_dependent_settings': {
++            'include_dirs': [
++              'src',
++            ],
++          },
++        },
++      ],
++    }, { # use_system_libmtp==1
++      'conditions': [
++        ['sysroot!=""', {
++          'variables': {
++            'pkg-config': '../../build/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)"',
++          },
++        }, {
++          'variables': {
++            'pkg-config': 'pkg-config'
++          },
++        }],
++      ],
++      'targets': [
++        {
++          'target_name': 'libmtp',
++          'type': 'none',
++          'direct_dependent_settings': {
++            'cflags': [
++                '<!@(<(pkg-config) --cflags libmtp)',
++            ],
++          },
++          'link_settings': {
++            'ldflags': [
++              '<!@(<(pkg-config) --libs-only-L --libs-only-other libmtp)',
++            ],
++            'libraries': [
++              '<!@(<(pkg-config) --libs-only-l libmtp)',
++            ],
++          },
++        }
++      ],
++    }],
++  ]
++}
+
+Property changes on: libmtp.gyp
+___________________________________________________________________
+Added: svn:eol-style
+   + LF
+
+Index: src/gphoto2-endian.h
+===================================================================
+--- src/gphoto2-endian.h	(revision 0)
++++ src/gphoto2-endian.h	(revision 0)
+@@ -0,0 +1,124 @@
++/* This file is generated automatically by configure */
++/* It is valid only for the system type x86_64-unknown-linux-gnu */
++
++#ifndef __BYTEORDER_H
++#define __BYTEORDER_H
++
++/* ntohl and relatives live here */
++#include <arpa/inet.h>
++
++/* Define generic byte swapping functions */
++#include <byteswap.h>
++#define swap16(x) bswap_16(x)
++#define swap32(x) bswap_32(x)
++#define swap64(x) bswap_64(x)
++
++/* The byte swapping macros have the form: */
++/*   EENN[a]toh or htoEENN[a] where EE is be (big endian) or */
++/* le (little-endian), NN is 16 or 32 (number of bits) and a, */
++/* if present, indicates that the endian side is a pointer to an */
++/* array of uint8_t bytes instead of an integer of the specified length. */
++/* h refers to the host's ordering method. */
++
++/* So, to convert a 32-bit integer stored in a buffer in little-endian */
++/* format into a uint32_t usable on this machine, you could use: */
++/*   uint32_t value = le32atoh(&buf[3]); */
++/* To put that value back into the buffer, you could use: */
++/*   htole32a(&buf[3], value); */
++
++/* Define aliases for the standard byte swapping macros */
++/* Arguments to these macros must be properly aligned on natural word */
++/* boundaries in order to work properly on all architectures */
++#ifndef htobe16
++# define htobe16(x) htons(x)
++#endif
++#ifndef htobe32
++# define htobe32(x) htonl(x)
++#endif
++#ifndef be16toh
++# define be16toh(x) ntohs(x)
++#endif
++#ifndef be32toh
++# define be32toh(x) ntohl(x)
++#endif
++
++#define HTOBE16(x) (x) = htobe16(x)
++#define HTOBE32(x) (x) = htobe32(x)
++#define BE32TOH(x) (x) = be32toh(x)
++#define BE16TOH(x) (x) = be16toh(x)
++
++/* On little endian machines, these macros are null */
++#ifndef htole16
++# define htole16(x)      (x)
++#endif
++#ifndef htole32
++# define htole32(x)      (x)
++#endif
++#ifndef htole64
++# define htole64(x)      (x)
++#endif
++#ifndef le16toh
++# define le16toh(x)      (x)
++#endif
++#ifndef le32toh
++# define le32toh(x)      (x)
++#endif
++#ifndef le64toh
++# define le64toh(x)      (x)
++#endif
++
++#define HTOLE16(x)      (void) (x)
++#define HTOLE32(x)      (void) (x)
++#define HTOLE64(x)      (void) (x)
++#define LE16TOH(x)      (void) (x)
++#define LE32TOH(x)      (void) (x)
++#define LE64TOH(x)      (void) (x)
++
++/* These don't have standard aliases */
++#ifndef htobe64
++# define htobe64(x)      swap64(x)
++#endif
++#ifndef be64toh
++# define be64toh(x)      swap64(x)
++#endif
++
++#define HTOBE64(x)      (x) = htobe64(x)
++#define BE64TOH(x)      (x) = be64toh(x)
++
++/* Define the C99 standard length-specific integer types */
++#include <_stdint.h>
++
++/* Here are some macros to create integers from a byte array */
++/* These are used to get and put integers from/into a uint8_t array */
++/* with a specific endianness.  This is the most portable way to generate */
++/* and read messages to a network or serial device.  Each member of a */
++/* packet structure must be handled separately. */
++
++/* Non-optimized but portable macros */
++#define be16atoh(x)     ((uint16_t)(((x)[0]<<8)|(x)[1]))
++#define be32atoh(x)     ((uint32_t)(((x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]))
++#define be64atoh_x(x,off,shift) 	(((uint64_t)((x)[off]))<<shift)
++#define be64atoh(x)     ((uint64_t)(be64atoh_x(x,0,56)|be64atoh_x(x,1,48)|be64atoh_x(x,2,40)| \
++        be64atoh_x(x,3,32)|be64atoh_x(x,4,24)|be64atoh_x(x,5,16)|be64atoh_x(x,6,8)|((x)[7])))
++#define le16atoh(x)     ((uint16_t)(((x)[1]<<8)|(x)[0]))
++#define le32atoh(x)     ((uint32_t)(((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|(x)[0]))
++#define le64atoh_x(x,off,shift) (((uint64_t)(x)[off])<<shift)
++#define le64atoh(x)     ((uint64_t)(le64atoh_x(x,7,56)|le64atoh_x(x,6,48)|le64atoh_x(x,5,40)| \
++        le64atoh_x(x,4,32)|le64atoh_x(x,3,24)|le64atoh_x(x,2,16)|le64atoh_x(x,1,8)|((x)[0])))
++
++#define htobe16a(a,x)   (a)[0]=(uint8_t)((x)>>8), (a)[1]=(uint8_t)(x)
++#define htobe32a(a,x)   (a)[0]=(uint8_t)((x)>>24), (a)[1]=(uint8_t)((x)>>16), \
++        (a)[2]=(uint8_t)((x)>>8), (a)[3]=(uint8_t)(x)
++#define htobe64a(a,x)   (a)[0]=(uint8_t)((x)>>56), (a)[1]=(uint8_t)((x)>>48), \
++        (a)[2]=(uint8_t)((x)>>40), (a)[3]=(uint8_t)((x)>>32), \
++        (a)[4]=(uint8_t)((x)>>24), (a)[5]=(uint8_t)((x)>>16), \
++        (a)[6]=(uint8_t)((x)>>8), (a)[7]=(uint8_t)(x)
++#define htole16a(a,x)   (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
++#define htole32a(a,x)   (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \
++        (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
++#define htole64a(a,x)   (a)[7]=(uint8_t)((x)>>56), (a)[6]=(uint8_t)((x)>>48), \
++        (a)[5]=(uint8_t)((x)>>40), (a)[4]=(uint8_t)((x)>>32), \
++        (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \
++        (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
++
++#endif /*__BYTEORDER_H*/
+
+Property changes on: src/gphoto2-endian.h
+___________________________________________________________________
+Added: svn:eol-style
+   + LF
+
+Index: src/libmtp.h
+===================================================================
+--- src/libmtp.h	(revision 0)
++++ src/libmtp.h	(revision 0)
+@@ -0,0 +1,1026 @@
++/**
++ * \file libmtp.h
++ * Interface to the Media Transfer Protocol library.
++ *
++ * Copyright (C) 2005-2012 Linus Walleij <triad@df.lth.se>
++ * Copyright (C) 2005-2008 Richard A. Low <richard@wentnet.com>
++ * Copyright (C) 2007 Ted Bullock <tbullock@canada.com>
++ * Copyright (C) 2008 Florent Mertens <flomertens@gmail.com>
++ *
++ * This library is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU Lesser General Public
++ * License as published by the Free Software Foundation; either
++ * version 2 of the License, or (at your option) any later version.
++ *
++ * This library 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
++ * Lesser General Public License for more details.
++ *
++ * You should have received a copy of the GNU Lesser General Public
++ * License along with this library; if not, write to the
++ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ * Boston, MA 02111-1307, USA.
++ *
++ * <code>
++ * #include <libmtp.h>
++ * </code>
++ */
++#ifndef LIBMTP_H_INCLUSION_GUARD
++#define LIBMTP_H_INCLUSION_GUARD
++
++#define LIBMTP_VERSION 1.1.5
++#define LIBMTP_VERSION_STRING "1.1.5"
++
++/* This handles MSVC pecularities */
++#ifdef _MSC_VER
++#include <windows.h>
++#define __WIN32__
++#define snprintf _snprintf
++#define ssize_t SSIZE_T
++/*
++ * Types that do not exist in Windows
++ * sys/types.h, but they exist in mingw32
++ * sys/types.h.
++ */
++typedef char int8_t;
++typedef unsigned char uint8_t;
++typedef __int16 int16_t;
++typedef unsigned __int16 uint16_t;
++typedef __int32 int32_t;
++typedef unsigned __int32 uint32_t;
++typedef unsigned __int64 uint64_t;
++#endif
++
++#include <stdio.h>
++#include <stdint.h>
++/* We use time_t */
++#include <time.h>
++
++/**
++ * @defgroup types libmtp global type definitions
++ * @{
++ */
++
++/**
++ * The debug flags defined here are the external flags used
++ * by the libmtp library interface.
++ *
++ * Please keep this list in sync with libmtp.c.
++ */
++#define LIBMTP_DEBUG_NONE		0x00
++#define LIBMTP_DEBUG_PTP		0x01
++#define LIBMTP_DEBUG_PLST		0x02
++#define LIBMTP_DEBUG_USB		0x04
++#define LIBMTP_DEBUG_DATA		0x08
++#define LIBMTP_DEBUG_ALL		0xFF
++
++
++/**
++ * The filetypes defined here are the external types used
++ * by the libmtp library interface. The types used internally
++ * as PTP-defined enumerator types is something different.
++ */
++typedef enum {
++  LIBMTP_FILETYPE_FOLDER,
++  LIBMTP_FILETYPE_WAV,
++  LIBMTP_FILETYPE_MP3,
++  LIBMTP_FILETYPE_WMA,
++  LIBMTP_FILETYPE_OGG,
++  LIBMTP_FILETYPE_AUDIBLE,
++  LIBMTP_FILETYPE_MP4,
++  LIBMTP_FILETYPE_UNDEF_AUDIO,
++  LIBMTP_FILETYPE_WMV,
++  LIBMTP_FILETYPE_AVI,
++  LIBMTP_FILETYPE_MPEG,
++  LIBMTP_FILETYPE_ASF,
++  LIBMTP_FILETYPE_QT,
++  LIBMTP_FILETYPE_UNDEF_VIDEO,
++  LIBMTP_FILETYPE_JPEG,
++  LIBMTP_FILETYPE_JFIF,
++  LIBMTP_FILETYPE_TIFF,
++  LIBMTP_FILETYPE_BMP,
++  LIBMTP_FILETYPE_GIF,
++  LIBMTP_FILETYPE_PICT,
++  LIBMTP_FILETYPE_PNG,
++  LIBMTP_FILETYPE_VCALENDAR1,
++  LIBMTP_FILETYPE_VCALENDAR2,
++  LIBMTP_FILETYPE_VCARD2,
++  LIBMTP_FILETYPE_VCARD3,
++  LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT,
++  LIBMTP_FILETYPE_WINEXEC,
++  LIBMTP_FILETYPE_TEXT,
++  LIBMTP_FILETYPE_HTML,
++  LIBMTP_FILETYPE_FIRMWARE,
++  LIBMTP_FILETYPE_AAC,
++  LIBMTP_FILETYPE_MEDIACARD,
++  LIBMTP_FILETYPE_FLAC,
++  LIBMTP_FILETYPE_MP2,
++  LIBMTP_FILETYPE_M4A,
++  LIBMTP_FILETYPE_DOC,
++  LIBMTP_FILETYPE_XML,
++  LIBMTP_FILETYPE_XLS,
++  LIBMTP_FILETYPE_PPT,
++  LIBMTP_FILETYPE_MHT,
++  LIBMTP_FILETYPE_JP2,
++  LIBMTP_FILETYPE_JPX,
++  LIBMTP_FILETYPE_ALBUM,
++  LIBMTP_FILETYPE_PLAYLIST,
++  LIBMTP_FILETYPE_UNKNOWN
++} LIBMTP_filetype_t;
++
++/**
++ * \def LIBMTP_FILETYPE_IS_AUDIO
++ * Audio filetype test.
++ *
++ * For filetypes that can be either audio
++ * or video, use LIBMTP_FILETYPE_IS_AUDIOVIDEO
++ */
++#define LIBMTP_FILETYPE_IS_AUDIO(a)\
++(a == LIBMTP_FILETYPE_WAV ||\
++ a == LIBMTP_FILETYPE_MP3 ||\
++ a == LIBMTP_FILETYPE_MP2 ||\
++ a == LIBMTP_FILETYPE_WMA ||\
++ a == LIBMTP_FILETYPE_OGG ||\
++ a == LIBMTP_FILETYPE_FLAC ||\
++ a == LIBMTP_FILETYPE_AAC ||\
++ a == LIBMTP_FILETYPE_M4A ||\
++ a == LIBMTP_FILETYPE_AUDIBLE ||\
++ a == LIBMTP_FILETYPE_UNDEF_AUDIO)
++
++/**
++ *  \def LIBMTP_FILETYPE_IS_VIDEO
++ *  Video filetype test.
++ *
++ * For filetypes that can be either audio
++ * or video, use LIBMTP_FILETYPE_IS_AUDIOVIDEO
++ */
++#define LIBMTP_FILETYPE_IS_VIDEO(a)\
++(a == LIBMTP_FILETYPE_WMV ||\
++ a == LIBMTP_FILETYPE_AVI ||\
++ a == LIBMTP_FILETYPE_MPEG ||\
++ a == LIBMTP_FILETYPE_UNDEF_VIDEO)
++
++/**
++ *  \def LIBMTP_FILETYPE_IS_AUDIOVIDEO
++ *  Audio and&slash;or video filetype test.
++ */
++#define LIBMTP_FILETYPE_IS_AUDIOVIDEO(a)\
++(a == LIBMTP_FILETYPE_MP4 ||\
++ a == LIBMTP_FILETYPE_ASF ||\
++ a == LIBMTP_FILETYPE_QT)
++
++/**
++ *  \def LIBMTP_FILETYPE_IS_TRACK
++ *  Test if filetype is a track.
++ *  Use this to determine if the File API or Track API
++ *  should be used to upload or download an object.
++ */
++#define LIBMTP_FILETYPE_IS_TRACK(a)\
++(LIBMTP_FILETYPE_IS_AUDIO(a) ||\
++ LIBMTP_FILETYPE_IS_VIDEO(a) ||\
++ LIBMTP_FILETYPE_IS_AUDIOVIDEO(a))
++
++/**
++ *  \def LIBMTP_FILETYPE_IS_IMAGE
++ *  Image filetype test
++ */
++#define LIBMTP_FILETYPE_IS_IMAGE(a)\
++(a == LIBMTP_FILETYPE_JPEG ||\
++a == LIBMTP_FILETYPE_JFIF ||\
++a == LIBMTP_FILETYPE_TIFF ||\
++a == LIBMTP_FILETYPE_BMP ||\
++a == LIBMTP_FILETYPE_GIF ||\
++a == LIBMTP_FILETYPE_PICT ||\
++a == LIBMTP_FILETYPE_PNG ||\
++a == LIBMTP_FILETYPE_JP2 ||\
++a == LIBMTP_FILETYPE_JPX ||\
++a == LIBMTP_FILETYPE_WINDOWSIMAGEFORMAT)
++
++/**
++ *  \def LIBMTP_FILETYPE_IS_ADDRESSBOOK
++ *  Addressbook and Business card filetype test
++ */
++#define LIBMTP_FILETYPE_IS_ADDRESSBOOK(a)\
++(a == LIBMTP_FILETYPE_VCARD2 ||\
++a == LIBMTP_FILETYPE_VCARD3)
++
++/**
++ *  \def LIBMTP_FILETYPE_IS_CALENDAR
++ *  Calendar and Appointment filetype test
++ */
++#define LIBMTP_FILETYPE_IS_CALENDAR(a)\
++(a == LIBMTP_FILETYPE_VCALENDAR1 ||\
++a == LIBMTP_FILETYPE_VCALENDAR2)
++
++/**
++ * The properties defined here are the external types used
++ * by the libmtp library interface.
++ */
++typedef enum {
++  LIBMTP_PROPERTY_StorageID,
++  LIBMTP_PROPERTY_ObjectFormat,
++  LIBMTP_PROPERTY_ProtectionStatus,
++  LIBMTP_PROPERTY_ObjectSize,
++  LIBMTP_PROPERTY_AssociationType,
++  LIBMTP_PROPERTY_AssociationDesc,
++  LIBMTP_PROPERTY_ObjectFileName,
++  LIBMTP_PROPERTY_DateCreated,
++  LIBMTP_PROPERTY_DateModified,
++  LIBMTP_PROPERTY_Keywords,
++  LIBMTP_PROPERTY_ParentObject,
++  LIBMTP_PROPERTY_AllowedFolderContents,
++  LIBMTP_PROPERTY_Hidden,
++  LIBMTP_PROPERTY_SystemObject,
++  LIBMTP_PROPERTY_PersistantUniqueObjectIdentifier,
++  LIBMTP_PROPERTY_SyncID,
++  LIBMTP_PROPERTY_PropertyBag,
++  LIBMTP_PROPERTY_Name,
++  LIBMTP_PROPERTY_CreatedBy,
++  LIBMTP_PROPERTY_Artist,
++  LIBMTP_PROPERTY_DateAuthored,
++  LIBMTP_PROPERTY_Description,
++  LIBMTP_PROPERTY_URLReference,
++  LIBMTP_PROPERTY_LanguageLocale,
++  LIBMTP_PROPERTY_CopyrightInformation,
++  LIBMTP_PROPERTY_Source,
++  LIBMTP_PROPERTY_OriginLocation,
++  LIBMTP_PROPERTY_DateAdded,
++  LIBMTP_PROPERTY_NonConsumable,
++  LIBMTP_PROPERTY_CorruptOrUnplayable,
++  LIBMTP_PROPERTY_ProducerSerialNumber,
++  LIBMTP_PROPERTY_RepresentativeSampleFormat,
++  LIBMTP_PROPERTY_RepresentativeSampleSize,
++  LIBMTP_PROPERTY_RepresentativeSampleHeight,
++  LIBMTP_PROPERTY_RepresentativeSampleWidth,
++  LIBMTP_PROPERTY_RepresentativeSampleDuration,
++  LIBMTP_PROPERTY_RepresentativeSampleData,
++  LIBMTP_PROPERTY_Width,
++  LIBMTP_PROPERTY_Height,
++  LIBMTP_PROPERTY_Duration,
++  LIBMTP_PROPERTY_Rating,
++  LIBMTP_PROPERTY_Track,
++  LIBMTP_PROPERTY_Genre,
++  LIBMTP_PROPERTY_Credits,
++  LIBMTP_PROPERTY_Lyrics,
++  LIBMTP_PROPERTY_SubscriptionContentID,
++  LIBMTP_PROPERTY_ProducedBy,
++  LIBMTP_PROPERTY_UseCount,
++  LIBMTP_PROPERTY_SkipCount,
++  LIBMTP_PROPERTY_LastAccessed,
++  LIBMTP_PROPERTY_ParentalRating,
++  LIBMTP_PROPERTY_MetaGenre,
++  LIBMTP_PROPERTY_Composer,
++  LIBMTP_PROPERTY_EffectiveRating,
++  LIBMTP_PROPERTY_Subtitle,
++  LIBMTP_PROPERTY_OriginalReleaseDate,
++  LIBMTP_PROPERTY_AlbumName,
++  LIBMTP_PROPERTY_AlbumArtist,
++  LIBMTP_PROPERTY_Mood,
++  LIBMTP_PROPERTY_DRMStatus,
++  LIBMTP_PROPERTY_SubDescription,
++  LIBMTP_PROPERTY_IsCropped,
++  LIBMTP_PROPERTY_IsColorCorrected,
++  LIBMTP_PROPERTY_ImageBitDepth,
++  LIBMTP_PROPERTY_Fnumber,
++  LIBMTP_PROPERTY_ExposureTime,
++  LIBMTP_PROPERTY_ExposureIndex,
++  LIBMTP_PROPERTY_DisplayName,
++  LIBMTP_PROPERTY_BodyText,
++  LIBMTP_PROPERTY_Subject,
++  LIBMTP_PROPERTY_Priority,
++  LIBMTP_PROPERTY_GivenName,
++  LIBMTP_PROPERTY_MiddleNames,
++  LIBMTP_PROPERTY_FamilyName,
++  LIBMTP_PROPERTY_Prefix,
++  LIBMTP_PROPERTY_Suffix,
++  LIBMTP_PROPERTY_PhoneticGivenName,
++  LIBMTP_PROPERTY_PhoneticFamilyName,
++  LIBMTP_PROPERTY_EmailPrimary,
++  LIBMTP_PROPERTY_EmailPersonal1,
++  LIBMTP_PROPERTY_EmailPersonal2,
++  LIBMTP_PROPERTY_EmailBusiness1,
++  LIBMTP_PROPERTY_EmailBusiness2,
++  LIBMTP_PROPERTY_EmailOthers,
++  LIBMTP_PROPERTY_PhoneNumberPrimary,
++  LIBMTP_PROPERTY_PhoneNumberPersonal,
++  LIBMTP_PROPERTY_PhoneNumberPersonal2,
++  LIBMTP_PROPERTY_PhoneNumberBusiness,
++  LIBMTP_PROPERTY_PhoneNumberBusiness2,
++  LIBMTP_PROPERTY_PhoneNumberMobile,
++  LIBMTP_PROPERTY_PhoneNumberMobile2,
++  LIBMTP_PROPERTY_FaxNumberPrimary,
++  LIBMTP_PROPERTY_FaxNumberPersonal,
++  LIBMTP_PROPERTY_FaxNumberBusiness,
++  LIBMTP_PROPERTY_PagerNumber,
++  LIBMTP_PROPERTY_PhoneNumberOthers,
++  LIBMTP_PROPERTY_PrimaryWebAddress,
++  LIBMTP_PROPERTY_PersonalWebAddress,
++  LIBMTP_PROPERTY_BusinessWebAddress,
++  LIBMTP_PROPERTY_InstantMessengerAddress,
++  LIBMTP_PROPERTY_InstantMessengerAddress2,
++  LIBMTP_PROPERTY_InstantMessengerAddress3,
++  LIBMTP_PROPERTY_PostalAddressPersonalFull,
++  LIBMTP_PROPERTY_PostalAddressPersonalFullLine1,
++  LIBMTP_PROPERTY_PostalAddressPersonalFullLine2,
++  LIBMTP_PROPERTY_PostalAddressPersonalFullCity,
++  LIBMTP_PROPERTY_PostalAddressPersonalFullRegion,
++  LIBMTP_PROPERTY_PostalAddressPersonalFullPostalCode,
++  LIBMTP_PROPERTY_PostalAddressPersonalFullCountry,
++  LIBMTP_PROPERTY_PostalAddressBusinessFull,
++  LIBMTP_PROPERTY_PostalAddressBusinessLine1,
++  LIBMTP_PROPERTY_PostalAddressBusinessLine2,
++  LIBMTP_PROPERTY_PostalAddressBusinessCity,
++  LIBMTP_PROPERTY_PostalAddressBusinessRegion,
++  LIBMTP_PROPERTY_PostalAddressBusinessPostalCode,
++  LIBMTP_PROPERTY_PostalAddressBusinessCountry,
++  LIBMTP_PROPERTY_PostalAddressOtherFull,
++  LIBMTP_PROPERTY_PostalAddressOtherLine1,
++  LIBMTP_PROPERTY_PostalAddressOtherLine2,
++  LIBMTP_PROPERTY_PostalAddressOtherCity,
++  LIBMTP_PROPERTY_PostalAddressOtherRegion,
++  LIBMTP_PROPERTY_PostalAddressOtherPostalCode,
++  LIBMTP_PROPERTY_PostalAddressOtherCountry,
++  LIBMTP_PROPERTY_OrganizationName,
++  LIBMTP_PROPERTY_PhoneticOrganizationName,
++  LIBMTP_PROPERTY_Role,
++  LIBMTP_PROPERTY_Birthdate,
++  LIBMTP_PROPERTY_MessageTo,
++  LIBMTP_PROPERTY_MessageCC,
++  LIBMTP_PROPERTY_MessageBCC,
++  LIBMTP_PROPERTY_MessageRead,
++  LIBMTP_PROPERTY_MessageReceivedTime,
++  LIBMTP_PROPERTY_MessageSender,
++  LIBMTP_PROPERTY_ActivityBeginTime,
++  LIBMTP_PROPERTY_ActivityEndTime,
++  LIBMTP_PROPERTY_ActivityLocation,
++  LIBMTP_PROPERTY_ActivityRequiredAttendees,
++  LIBMTP_PROPERTY_ActivityOptionalAttendees,
++  LIBMTP_PROPERTY_ActivityResources,
++  LIBMTP_PROPERTY_ActivityAccepted,
++  LIBMTP_PROPERTY_Owner,
++  LIBMTP_PROPERTY_Editor,
++  LIBMTP_PROPERTY_Webmaster,
++  LIBMTP_PROPERTY_URLSource,
++  LIBMTP_PROPERTY_URLDestination,
++  LIBMTP_PROPERTY_TimeBookmark,
++  LIBMTP_PROPERTY_ObjectBookmark,
++  LIBMTP_PROPERTY_ByteBookmark,
++  LIBMTP_PROPERTY_LastBuildDate,
++  LIBMTP_PROPERTY_TimetoLive,
++  LIBMTP_PROPERTY_MediaGUID,
++  LIBMTP_PROPERTY_TotalBitRate,
++  LIBMTP_PROPERTY_BitRateType,
++  LIBMTP_PROPERTY_SampleRate,
++  LIBMTP_PROPERTY_NumberOfChannels,
++  LIBMTP_PROPERTY_AudioBitDepth,
++  LIBMTP_PROPERTY_ScanDepth,
++  LIBMTP_PROPERTY_AudioWAVECodec,
++  LIBMTP_PROPERTY_AudioBitRate,
++  LIBMTP_PROPERTY_VideoFourCCCodec,
++  LIBMTP_PROPERTY_VideoBitRate,
++  LIBMTP_PROPERTY_FramesPerThousandSeconds,
++  LIBMTP_PROPERTY_KeyFrameDistance,
++  LIBMTP_PROPERTY_BufferSize,
++  LIBMTP_PROPERTY_EncodingQuality,
++  LIBMTP_PROPERTY_EncodingProfile,
++  LIBMTP_PROPERTY_BuyFlag,
++  LIBMTP_PROPERTY_UNKNOWN
++} LIBMTP_property_t;
++
++/**
++ * These are the data types
++ */
++typedef enum {
++  LIBMTP_DATATYPE_INT8,
++  LIBMTP_DATATYPE_UINT8,
++  LIBMTP_DATATYPE_INT16,
++  LIBMTP_DATATYPE_UINT16,
++  LIBMTP_DATATYPE_INT32,
++  LIBMTP_DATATYPE_UINT32,
++  LIBMTP_DATATYPE_INT64,
++  LIBMTP_DATATYPE_UINT64,
++} LIBMTP_datatype_t;
++
++/**
++ * These are the numbered error codes. You can also
++ * get string representations for errors.
++ */
++typedef enum {
++  LIBMTP_ERROR_NONE,
++  LIBMTP_ERROR_GENERAL,
++  LIBMTP_ERROR_PTP_LAYER,
++  LIBMTP_ERROR_USB_LAYER,
++  LIBMTP_ERROR_MEMORY_ALLOCATION,
++  LIBMTP_ERROR_NO_DEVICE_ATTACHED,
++  LIBMTP_ERROR_STORAGE_FULL,
++  LIBMTP_ERROR_CONNECTING,
++  LIBMTP_ERROR_CANCELLED
++} LIBMTP_error_number_t;
++
++typedef struct LIBMTP_device_entry_struct LIBMTP_device_entry_t; /**< @see LIBMTP_device_entry_struct */
++typedef struct LIBMTP_raw_device_struct LIBMTP_raw_device_t; /**< @see LIBMTP_raw_device_struct */
++typedef struct LIBMTP_error_struct LIBMTP_error_t; /**< @see LIBMTP_error_struct */
++typedef struct LIBMTP_allowed_values_struct LIBMTP_allowed_values_t; /**< @see LIBMTP_allowed_values_struct */
++typedef struct LIBMTP_device_extension_struct LIBMTP_device_extension_t; /** < @see LIBMTP_device_extension_struct */
++typedef struct LIBMTP_mtpdevice_struct LIBMTP_mtpdevice_t; /**< @see LIBMTP_mtpdevice_struct */
++typedef struct LIBMTP_file_struct LIBMTP_file_t; /**< @see LIBMTP_file_struct */
++typedef struct LIBMTP_track_struct LIBMTP_track_t; /**< @see LIBMTP_track_struct */
++typedef struct LIBMTP_playlist_struct LIBMTP_playlist_t; /**< @see LIBMTP_playlist_struct */
++typedef struct LIBMTP_album_struct LIBMTP_album_t; /**< @see LIBMTP_album_struct */
++typedef struct LIBMTP_folder_struct LIBMTP_folder_t; /**< @see LIBMTP_folder_t */
++typedef struct LIBMTP_object_struct LIBMTP_object_t; /**< @see LIBMTP_object_t */
++typedef struct LIBMTP_filesampledata_struct LIBMTP_filesampledata_t; /**< @see LIBMTP_filesample_t */
++typedef struct LIBMTP_devicestorage_struct LIBMTP_devicestorage_t; /**< @see LIBMTP_devicestorage_t */
++
++/**
++ * The callback type definition. Notice that a progress percentage ratio
++ * is easy to calculate by dividing <code>sent</code> by
++ * <code>total</code>.
++ * @param sent the number of bytes sent so far
++ * @param total the total number of bytes to send
++ * @param data a user-defined dereferencable pointer
++ * @return if anything else than 0 is returned, the current transfer will be
++ *         interrupted / cancelled.
++ */
++typedef int (* LIBMTP_progressfunc_t) (uint64_t const sent, uint64_t const total,
++                		void const * const data);
++
++/**
++ * Callback function for get by handler function
++ * @param params the device parameters
++ * @param priv a user-defined dereferencable pointer
++ * @param wantlen the number of bytes wanted
++ * @param data a buffer to write the data to
++ * @param gotlen pointer to the number of bytes actually written
++ *        to data
++ * @return LIBMTP_HANDLER_RETURN_OK if successful,
++ *         LIBMTP_HANDLER_RETURN_ERROR on error or
++ *         LIBMTP_HANDLER_RETURN_CANCEL to cancel the transfer
++ */
++typedef uint16_t (* MTPDataGetFunc)	(void* params, void* priv,
++					uint32_t wantlen, unsigned char *data, uint32_t *gotlen);
++
++/**
++ * Callback function for put by handler function
++ * @param params the device parameters
++ * @param priv a user-defined dereferencable pointer
++ * @param sendlen the number of bytes available
++ * @param data a buffer to read the data from
++ * @param putlen pointer to the number of bytes actually read
++ *        from data
++ * @return LIBMTP_HANDLER_RETURN_OK if successful,
++ *         LIBMTP_HANDLER_RETURN_ERROR on error or
++ *         LIBMTP_HANDLER_RETURN_CANCEL to cancel the transfer
++ */
++typedef uint16_t (* MTPDataPutFunc)	(void* params, void* priv,
++					uint32_t sendlen, unsigned char *data, uint32_t *putlen);
++
++/**
++ * The return codes for the get/put functions
++ */
++#define LIBMTP_HANDLER_RETURN_OK 0
++#define LIBMTP_HANDLER_RETURN_ERROR 1
++#define LIBMTP_HANDLER_RETURN_CANCEL 2
++
++/**
++ * @}
++ * @defgroup structar libmtp data structures
++ * @{
++ */
++
++/**
++ * A data structure to hold MTP device entries.
++ */
++struct LIBMTP_device_entry_struct {
++  char *vendor; /**< The vendor of this device */
++  uint16_t vendor_id; /**< Vendor ID for this device */
++  char *product; /**< The product name of this device */
++  uint16_t product_id; /**< Product ID for this device */
++  uint32_t device_flags; /**< Bugs, device specifics etc */
++};
++
++/**
++ * A data structure to hold a raw MTP device connected
++ * to the bus.
++ */
++struct LIBMTP_raw_device_struct {
++  LIBMTP_device_entry_t device_entry; /**< The device entry for this raw device */
++  uint32_t bus_location; /**< Location of the bus, if device available */
++  uint8_t devnum; /**< Device number on the bus, if device available */
++};
++
++/**
++ * A data structure to hold errors from the library.
++ */
++struct LIBMTP_error_struct {
++  LIBMTP_error_number_t errornumber;
++  char *error_text;
++  LIBMTP_error_t *next;
++};
++
++/**
++ * A data structure to hold allowed ranges of values
++ */
++struct LIBMTP_allowed_values_struct {
++  uint8_t   u8max;
++  uint8_t   u8min;
++  uint8_t   u8step;
++  uint8_t*  u8vals;
++  int8_t    i8max;
++  int8_t    i8min;
++  int8_t    i8step;
++  int8_t*   i8vals;
++  uint16_t  u16max;
++  uint16_t  u16min;
++  uint16_t  u16step;
++  uint16_t* u16vals;
++  int16_t   i16max;
++  int16_t   i16min;
++  int16_t   i16step;
++  int16_t*  i16vals;
++  uint32_t  u32max;
++  uint32_t  u32min;
++  uint32_t  u32step;
++  uint32_t* u32vals;
++  int32_t   i32max;
++  int32_t   i32min;
++  int32_t   i32step;
++  int32_t*  i32vals;
++  uint64_t  u64max;
++  uint64_t  u64min;
++  uint64_t  u64step;
++  uint64_t* u64vals;
++  int64_t   i64max;
++  int64_t   i64min;
++  int64_t   i64step;
++  int64_t*  i64vals;
++  /**
++   * Number of entries in the vals array
++   */
++  uint16_t  num_entries;
++  /**
++   * The datatype specifying which of the above is used
++  */
++  LIBMTP_datatype_t datatype;
++  /**
++   * Non zero for range, 0 for enum
++  */
++  int is_range;
++};
++
++/**
++ * MTP device extension holder struct
++ */
++struct LIBMTP_device_extension_struct {
++  /**
++   * Name of extension e.g. "foo.com"
++   */
++  char *name;
++  /**
++   * Major revision of extension
++   */
++  int major;
++  /**
++   * Minor revision of extension
++   */
++  int minor;
++  /**
++   * Pointer to the next extension or NULL if this is the
++   * last extension.
++   */
++  LIBMTP_device_extension_t *next;
++};
++
++/**
++ * Main MTP device object struct
++ */
++struct LIBMTP_mtpdevice_struct {
++  /**
++   * Object bitsize, typically 32 or 64.
++   */
++  uint8_t object_bitsize;
++  /**
++   * Parameters for this device, must be cast into
++   * \c (PTPParams*) before internal use.
++   */
++  void *params;
++  /**
++   * USB device for this device, must be cast into
++   * \c (PTP_USB*) before internal use.
++   */
++  void *usbinfo;
++  /**
++   * The storage for this device, do not use strings in here without
++   * copying them first, and beware that this list may be rebuilt at
++   * any time.
++   * @see LIBMTP_Get_Storage()
++   */
++  LIBMTP_devicestorage_t *storage;
++  /**
++   * The error stack. This shall be handled using the error getting
++   * and clearing functions, not by dereferencing this list.
++   */
++  LIBMTP_error_t *errorstack;
++  /** The maximum battery level for this device */
++  uint8_t maximum_battery_level;
++  /** Default music folder */
++  uint32_t default_music_folder;
++  /** Default playlist folder */
++  uint32_t default_playlist_folder;
++  /** Default picture folder */
++  uint32_t default_picture_folder;
++  /** Default video folder */
++  uint32_t default_video_folder;
++  /** Default organizer folder */
++  uint32_t default_organizer_folder;
++  /** Default ZENcast folder (only Creative devices...) */
++  uint32_t default_zencast_folder;
++  /** Default Album folder */
++  uint32_t default_album_folder;
++  /** Default Text folder */
++  uint32_t default_text_folder;
++  /** Per device iconv() converters, only used internally */
++  void *cd;
++  /** Extension list */
++  LIBMTP_device_extension_t *extensions;
++  /** Whether the device uses caching, only used internally */
++  int cached;
++
++  /** Pointer to next device in linked list; NULL if this is the last device */
++  LIBMTP_mtpdevice_t *next;
++};
++
++/**
++ * MTP file struct
++ */
++struct LIBMTP_file_struct {
++  uint32_t item_id; /**< Unique item ID */
++  uint32_t parent_id; /**< ID of parent folder */
++  uint32_t storage_id; /**< ID of storage holding this file */
++  char *filename; /**< Filename of this file */
++  uint64_t filesize; /**< Size of file in bytes */
++  time_t modificationdate; /**< Date of last alteration of the file */
++  LIBMTP_filetype_t filetype; /**< Filetype used for the current file */
++  LIBMTP_file_t *next; /**< Next file in list or NULL if last file */
++};
++
++/**
++ * MTP track struct
++ */
++struct LIBMTP_track_struct {
++  uint32_t item_id; /**< Unique item ID */
++  uint32_t parent_id; /**< ID of parent folder */
++  uint32_t storage_id; /**< ID of storage holding this track */
++  char *title; /**< Track title */
++  char *artist; /**< Name of recording artist */
++  char *composer; /**< Name of recording composer */
++  char *genre; /**< Genre name for track */
++  char *album; /**< Album name for track */
++  char *date; /**< Date of original recording as a string */
++  char *filename; /**< Original filename of this track */
++  uint16_t tracknumber; /**< Track number (in sequence on recording) */
++  uint32_t duration; /**< Duration in milliseconds */
++  uint32_t samplerate; /**< Sample rate of original file, min 0x1f80 max 0xbb80 */
++  uint16_t nochannels; /**< Number of channels in this recording 0 = unknown, 1 or 2 */
++  uint32_t wavecodec; /**< FourCC wave codec name */
++  uint32_t bitrate; /**< (Average) bitrate for this file min=1 max=0x16e360 */
++  uint16_t bitratetype; /**< 0 = unused, 1 = constant, 2 = VBR, 3 = free */
++  uint16_t rating; /**< User rating 0-100 (0x00-0x64) */
++  uint32_t usecount; /**< Number of times used/played */
++  uint64_t filesize; /**< Size of track file in bytes */
++  time_t modificationdate; /**< Date of last alteration of the track */
++  LIBMTP_filetype_t filetype; /**< Filetype used for the current track */
++  LIBMTP_track_t *next; /**< Next track in list or NULL if last track */
++};
++
++/**
++ * MTP Playlist structure
++ */
++struct LIBMTP_playlist_struct {
++  uint32_t playlist_id; /**< Unique playlist ID */
++  uint32_t parent_id; /**< ID of parent folder */
++  uint32_t storage_id; /**< ID of storage holding this playlist */
++  char *name; /**< Name of playlist */
++  uint32_t *tracks; /**< The tracks in this playlist */
++  uint32_t no_tracks; /**< The number of tracks in this playlist */
++  LIBMTP_playlist_t *next; /**< Next playlist or NULL if last playlist */
++};
++
++/**
++ * MTP Album structure
++ */
++struct LIBMTP_album_struct {
++  uint32_t album_id; /**< Unique playlist ID */
++  uint32_t parent_id; /**< ID of parent folder */
++  uint32_t storage_id; /**< ID of storage holding this album */
++  char *name; /**< Name of album */
++  char *artist; /**< Name of album artist */
++  char *composer; /**< Name of recording composer */
++  char *genre; /**< Genre of album */
++  uint32_t *tracks; /**< The tracks in this album */
++  uint32_t no_tracks; /**< The number of tracks in this album */
++  LIBMTP_album_t *next; /**< Next album or NULL if last album */
++};
++
++/**
++ * MTP Folder structure
++ */
++struct LIBMTP_folder_struct {
++  uint32_t folder_id; /**< Unique folder ID */
++  uint32_t parent_id; /**< ID of parent folder */
++  uint32_t storage_id; /**< ID of storage holding this folder */
++  char *name; /**< Name of folder */
++  LIBMTP_folder_t *sibling; /**< Next folder at same level or NULL if no more */
++  LIBMTP_folder_t *child; /**< Child folder or NULL if no children */
++};
++
++/**
++ * LIBMTP Object RepresentativeSampleData Structure
++ */
++struct LIBMTP_filesampledata_struct {
++  uint32_t width; /**< Width of sample if it is an image */
++  uint32_t height; /**< Height of sample if it is an image */
++  uint32_t duration; /**< Duration in milliseconds if it is audio */
++  LIBMTP_filetype_t filetype; /**< Filetype used for the sample */
++  uint64_t size; /**< Size of sample data in bytes */
++  char *data; /**< Sample data */
++};
++
++/**
++ * LIBMTP Device Storage structure
++ */
++struct LIBMTP_devicestorage_struct {
++  uint32_t id; /**< Unique ID for this storage */
++  uint16_t StorageType; /**< Storage type */
++  uint16_t FilesystemType; /**< Filesystem type */
++  uint16_t AccessCapability; /**< Access capability */
++  uint64_t MaxCapacity; /**< Maximum capability */
++  uint64_t FreeSpaceInBytes; /**< Free space in bytes */
++  uint64_t FreeSpaceInObjects; /**< Free space in objects */
++  char *StorageDescription; /**< A brief description of this storage */
++  char *VolumeIdentifier; /**< A volume identifier */
++  LIBMTP_devicestorage_t *next; /**< Next storage, follow this link until NULL */
++  LIBMTP_devicestorage_t *prev; /**< Previous storage */
++};
++
++/**
++ * LIBMTP Event structure
++ * TODO: add all externally visible events here
++ */
++enum LIBMTP_event_enum {
++  LIBMTP_EVENT_NONE,
++  LIBMTP_EVENT_STORE_ADDED,
++};
++typedef enum LIBMTP_event_enum LIBMTP_event_t;
++
++/** @} */
++
++/* Make functions available for C++ */
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++extern int LIBMTP_debug;
++
++/**
++ * @defgroup internals The libmtp internals API.
++ * @{
++ */
++void LIBMTP_Set_Debug(int);
++void LIBMTP_Init(void);
++int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const, int * const);
++/**
++ * @}
++ * @defgroup basic The basic device management API.
++ * @{
++ */
++LIBMTP_error_number_t LIBMTP_Detect_Raw_Devices(LIBMTP_raw_device_t **, int *);
++int LIBMTP_Check_Specific_Device(int busno, int devno);
++LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device(LIBMTP_raw_device_t *);
++LIBMTP_mtpdevice_t *LIBMTP_Open_Raw_Device_Uncached(LIBMTP_raw_device_t *);
++/* Begin old, legacy interface */
++LIBMTP_mtpdevice_t *LIBMTP_Get_First_Device(void);
++LIBMTP_error_number_t LIBMTP_Get_Connected_Devices(LIBMTP_mtpdevice_t **);
++uint32_t LIBMTP_Number_Devices_In_List(LIBMTP_mtpdevice_t *);
++void LIBMTP_Release_Device_List(LIBMTP_mtpdevice_t*);
++/* End old, legacy interface */
++void LIBMTP_Release_Device(LIBMTP_mtpdevice_t*);
++void LIBMTP_Dump_Device_Info(LIBMTP_mtpdevice_t*);
++int LIBMTP_Reset_Device(LIBMTP_mtpdevice_t*);
++char *LIBMTP_Get_Manufacturername(LIBMTP_mtpdevice_t*);
++char *LIBMTP_Get_Modelname(LIBMTP_mtpdevice_t*);
++char *LIBMTP_Get_Serialnumber(LIBMTP_mtpdevice_t*);
++char *LIBMTP_Get_Deviceversion(LIBMTP_mtpdevice_t*);
++char *LIBMTP_Get_Friendlyname(LIBMTP_mtpdevice_t*);
++int LIBMTP_Set_Friendlyname(LIBMTP_mtpdevice_t*, char const * const);
++char *LIBMTP_Get_Syncpartner(LIBMTP_mtpdevice_t*);
++int LIBMTP_Set_Syncpartner(LIBMTP_mtpdevice_t*, char const * const);
++int LIBMTP_Get_Batterylevel(LIBMTP_mtpdevice_t *,
++			    uint8_t * const,
++			    uint8_t * const);
++int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
++int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
++int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
++LIBMTP_error_t *LIBMTP_Get_Errorstack(LIBMTP_mtpdevice_t*);
++void LIBMTP_Clear_Errorstack(LIBMTP_mtpdevice_t*);
++void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*);
++
++#define LIBMTP_STORAGE_SORTBY_NOTSORTED 0
++#define LIBMTP_STORAGE_SORTBY_FREESPACE 1
++#define LIBMTP_STORAGE_SORTBY_MAXSPACE  2
++
++int LIBMTP_Get_Storage(LIBMTP_mtpdevice_t *, int const);
++int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t *);
++
++/**
++ * Get/set arbitrary properties.  These do not update the cache; should only be used on
++ * properties not stored in structs
++ */
++char *LIBMTP_Get_String_From_Object(LIBMTP_mtpdevice_t *, uint32_t const, LIBMTP_property_t const);
++uint64_t LIBMTP_Get_u64_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
++      LIBMTP_property_t const, uint64_t const);
++uint32_t LIBMTP_Get_u32_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
++      LIBMTP_property_t const, uint32_t const);
++uint16_t LIBMTP_Get_u16_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
++      LIBMTP_property_t const, uint16_t const);
++uint8_t LIBMTP_Get_u8_From_Object(LIBMTP_mtpdevice_t *, uint32_t const,
++      LIBMTP_property_t const, uint8_t const);
++int LIBMTP_Set_Object_String(LIBMTP_mtpdevice_t *, uint32_t const,
++      LIBMTP_property_t const, char const * const);
++int LIBMTP_Set_Object_u32(LIBMTP_mtpdevice_t *, uint32_t const,
++      LIBMTP_property_t const, uint32_t const);
++int LIBMTP_Set_Object_u16(LIBMTP_mtpdevice_t *, uint32_t const,
++      LIBMTP_property_t const, uint16_t const);
++int LIBMTP_Set_Object_u8(LIBMTP_mtpdevice_t *, uint32_t const,
++      LIBMTP_property_t const, uint8_t const);
++char const * LIBMTP_Get_Property_Description(LIBMTP_property_t inproperty);
++int LIBMTP_Is_Property_Supported(LIBMTP_mtpdevice_t*, LIBMTP_property_t const,
++            LIBMTP_filetype_t const);
++int LIBMTP_Get_Allowed_Property_Values(LIBMTP_mtpdevice_t*, LIBMTP_property_t const,
++            LIBMTP_filetype_t const, LIBMTP_allowed_values_t*);
++void LIBMTP_destroy_allowed_values_t(LIBMTP_allowed_values_t*);
++
++/**
++ * @}
++ * @defgroup files The file management API.
++ * @{
++ */
++LIBMTP_file_t *LIBMTP_new_file_t(void);
++void LIBMTP_destroy_file_t(LIBMTP_file_t*);
++char const * LIBMTP_Get_Filetype_Description(LIBMTP_filetype_t);
++LIBMTP_file_t *LIBMTP_Get_Filelisting(LIBMTP_mtpdevice_t *);
++LIBMTP_file_t *LIBMTP_Get_Filelisting_With_Callback(LIBMTP_mtpdevice_t *,
++      LIBMTP_progressfunc_t const, void const * const);
++LIBMTP_file_t * LIBMTP_Get_Files_And_Folders(LIBMTP_mtpdevice_t *,
++					     uint32_t const,
++					     uint32_t const);
++LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
++int LIBMTP_Get_File_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
++			LIBMTP_progressfunc_t const, void const * const);
++int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t*,
++				       uint32_t const,
++				       int const,
++				       LIBMTP_progressfunc_t const,
++				       void const * const);
++int LIBMTP_Get_File_To_Handler(LIBMTP_mtpdevice_t *,
++			       uint32_t const,
++			       MTPDataPutFunc,
++			       void *,
++			       LIBMTP_progressfunc_t const,
++			       void const * const);
++int LIBMTP_Send_File_From_File(LIBMTP_mtpdevice_t *,
++			       char const * const,
++			       LIBMTP_file_t * const,
++			       LIBMTP_progressfunc_t const,
++			       void const * const);
++int LIBMTP_Send_File_From_File_Descriptor(LIBMTP_mtpdevice_t *,
++					  int const,
++					  LIBMTP_file_t * const,
++					  LIBMTP_progressfunc_t const,
++					  void const * const);
++int LIBMTP_Send_File_From_Handler(LIBMTP_mtpdevice_t *,
++				  MTPDataGetFunc, void *,
++				  LIBMTP_file_t * const,
++				  LIBMTP_progressfunc_t const,
++				  void const * const);
++int LIBMTP_Set_File_Name(LIBMTP_mtpdevice_t *,
++			 LIBMTP_file_t *,
++			 const char *);
++LIBMTP_filesampledata_t *LIBMTP_new_filesampledata_t(void);
++void LIBMTP_destroy_filesampledata_t(LIBMTP_filesampledata_t *);
++int LIBMTP_Get_Representative_Sample_Format(LIBMTP_mtpdevice_t *,
++                        LIBMTP_filetype_t const,
++                        LIBMTP_filesampledata_t **);
++int LIBMTP_Send_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
++                          LIBMTP_filesampledata_t *);
++int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
++                          LIBMTP_filesampledata_t *);
++int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
++                         unsigned char **data, unsigned int *size);
++
++/**
++ * @}
++ * @defgroup tracks The track management API.
++ * @{
++ */
++LIBMTP_track_t *LIBMTP_new_track_t(void);
++void LIBMTP_destroy_track_t(LIBMTP_track_t*);
++LIBMTP_track_t *LIBMTP_Get_Tracklisting(LIBMTP_mtpdevice_t*);
++LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback(LIBMTP_mtpdevice_t*,
++      LIBMTP_progressfunc_t const, void const * const);
++LIBMTP_track_t *LIBMTP_Get_Tracklisting_With_Callback_For_Storage(LIBMTP_mtpdevice_t*, uint32_t const,
++      LIBMTP_progressfunc_t const, void const * const);
++LIBMTP_track_t *LIBMTP_Get_Trackmetadata(LIBMTP_mtpdevice_t*, uint32_t const);
++int LIBMTP_Get_Track_To_File(LIBMTP_mtpdevice_t*, uint32_t, char const * const,
++			LIBMTP_progressfunc_t const, void const * const);
++int LIBMTP_Get_Track_To_File_Descriptor(LIBMTP_mtpdevice_t*, uint32_t const, int const,
++			LIBMTP_progressfunc_t const, void const * const);
++int LIBMTP_Get_Track_To_Handler(LIBMTP_mtpdevice_t *, uint32_t const, MTPDataPutFunc,
++      void *, LIBMTP_progressfunc_t const, void const * const);
++int LIBMTP_Send_Track_From_File(LIBMTP_mtpdevice_t *,
++			 char const * const, LIBMTP_track_t * const,
++                         LIBMTP_progressfunc_t const,
++			 void const * const);
++int LIBMTP_Send_Track_From_File_Descriptor(LIBMTP_mtpdevice_t *,
++			 int const, LIBMTP_track_t * const,
++                         LIBMTP_progressfunc_t const,
++			 void const * const);
++int LIBMTP_Send_Track_From_Handler(LIBMTP_mtpdevice_t *,
++			 MTPDataGetFunc, void *, LIBMTP_track_t * const,
++                         LIBMTP_progressfunc_t const,
++			 void const * const);
++int LIBMTP_Update_Track_Metadata(LIBMTP_mtpdevice_t *,
++			LIBMTP_track_t const * const);
++int LIBMTP_Track_Exists(LIBMTP_mtpdevice_t *, uint32_t const);
++int LIBMTP_Set_Track_Name(LIBMTP_mtpdevice_t *, LIBMTP_track_t *, const char *);
++/** @} */
++
++/**
++ * @}
++ * @defgroup folders The folder management API.
++ * @{
++ */
++LIBMTP_folder_t *LIBMTP_new_folder_t(void);
++void LIBMTP_destroy_folder_t(LIBMTP_folder_t*);
++LIBMTP_folder_t *LIBMTP_Get_Folder_List(LIBMTP_mtpdevice_t*);
++LIBMTP_folder_t *LIBMTP_Get_Folder_List_For_Storage(LIBMTP_mtpdevice_t*,
++						    uint32_t const);
++LIBMTP_folder_t *LIBMTP_Find_Folder(LIBMTP_folder_t*, uint32_t const);
++uint32_t LIBMTP_Create_Folder(LIBMTP_mtpdevice_t*, char *, uint32_t, uint32_t);
++int LIBMTP_Set_Folder_Name(LIBMTP_mtpdevice_t *, LIBMTP_folder_t *, const char *);
++/** @} */
++
++#if 0
++/**
++ * @}
++ * @defgroup playlists The audio/video playlist management API.
++ * @{
++ */
++LIBMTP_playlist_t *LIBMTP_new_playlist_t(void);
++void LIBMTP_destroy_playlist_t(LIBMTP_playlist_t *);
++LIBMTP_playlist_t *LIBMTP_Get_Playlist_List(LIBMTP_mtpdevice_t *);
++LIBMTP_playlist_t *LIBMTP_Get_Playlist(LIBMTP_mtpdevice_t *, uint32_t const);
++int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
++int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
++int LIBMTP_Set_Playlist_Name(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *, const char *);
++#endif
++
++/**
++ * @}
++ * @defgroup albums The audio/video album management API.
++ * @{
++ */
++LIBMTP_album_t *LIBMTP_new_album_t(void);
++void LIBMTP_destroy_album_t(LIBMTP_album_t *);
++LIBMTP_album_t *LIBMTP_Get_Album_List(LIBMTP_mtpdevice_t *);
++LIBMTP_album_t *LIBMTP_Get_Album_List_For_Storage(LIBMTP_mtpdevice_t *, uint32_t const);
++LIBMTP_album_t *LIBMTP_Get_Album(LIBMTP_mtpdevice_t *, uint32_t const);
++int LIBMTP_Create_New_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t * const);
++int LIBMTP_Update_Album(LIBMTP_mtpdevice_t *, LIBMTP_album_t const * const);
++int LIBMTP_Set_Album_Name(LIBMTP_mtpdevice_t *, LIBMTP_album_t *, const char *);
++
++/**
++ * @}
++ * @defgroup objects The object management API.
++ * @{
++ */
++int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
++int LIBMTP_Set_Object_Filename(LIBMTP_mtpdevice_t *, uint32_t , char *);
++
++/**
++ * @}
++ * @defgroup files The events API.
++ * @{
++ */
++int LIBMTP_Read_Event(LIBMTP_mtpdevice_t *, LIBMTP_event_t *, uint32_t *);
++
++
++/** @} */
++
++/* End of C++ exports */
++#ifdef __cplusplus
++}
++#endif
++
++#endif /* LIBMTP_H_INCLUSION_GUARD */
+
+Property changes on: src/libmtp.h
+___________________________________________________________________
+Added: svn:eol-style
+   + LF
+
+Index: src/_stdint.h
+===================================================================
+--- src/_stdint.h	(revision 0)
++++ src/_stdint.h	(revision 0)
+@@ -0,0 +1,2 @@
++/* This file is generated automatically by configure */
++#include <stdint.h>
+
+Property changes on: src/_stdint.h
+___________________________________________________________________
+Added: svn:eol-style
+   + LF
+
diff --git a/patches/12_check_for_libusb_init_failures.patch b/patches/12_check_for_libusb_init_failures.patch
new file mode 100644
index 0000000..3a0a9ba
--- /dev/null
+++ b/patches/12_check_for_libusb_init_failures.patch
@@ -0,0 +1,76 @@
+Index: src/libusb1-glue.c
+===================================================================
+--- src/libusb1-glue.c	(revision 160213)
++++ src/libusb1-glue.c	(working copy)
+@@ -84,7 +84,7 @@
+ static const int mtp_device_table_size = sizeof(mtp_device_table) / sizeof(LIBMTP_device_entry_t);
+ 
+ // Local functions
+-static void init_usb();
++static LIBMTP_error_number_t init_usb();
+ static void close_usb(PTP_USB* ptp_usb);
+ static int find_interface_and_endpoints(libusb_device *dev,
+ 					uint8_t *interface,
+@@ -125,16 +125,20 @@
+ }
+ 
+ 
+-static void init_usb()
++static LIBMTP_error_number_t init_usb()
+ {
+   /*
+    * Some additional libusb debugging please.
+    * We use the same level debug between MTP and USB.
+    */
+-  libusb_init(NULL);
++  if (libusb_init(NULL) < 0) {
++    LIBMTP_ERROR("Libusb1 init failed\n");
++    return LIBMTP_ERROR_USB_LAYER;
++  }
+ 
+   if ((LIBMTP_debug & LIBMTP_DEBUG_USB) != 0)
+     libusb_set_debug(NULL,9);
++  return LIBMTP_ERROR_NONE;
+ }
+ 
+ /**
+@@ -478,8 +482,11 @@
+   ssize_t nrofdevs;
+   libusb_device **devs = NULL;
+   int ret, i;
++  LIBMTP_error_number_t init_usb_ret;
+ 
+-  init_usb();
++  init_usb_ret = init_usb();
++  if (init_usb_ret != LIBMTP_ERROR_NONE)
++    return init_usb_ret;
+ 
+   nrofdevs = libusb_get_device_list (NULL, &devs);
+   for (i = 0; i < nrofdevs ; i++) {
+@@ -551,8 +558,11 @@
+   ssize_t nrofdevs;
+   libusb_device **devs = NULL;
+   int i;
++  LIBMTP_error_number_t init_usb_ret;
+ 
+-  init_usb();
++  init_usb_ret = init_usb();
++  if (init_usb_ret != LIBMTP_ERROR_NONE)
++    return 0;
+ 
+   nrofdevs = libusb_get_device_list (NULL, &devs);
+   for (i = 0; i < nrofdevs ; i++ ) {
+@@ -1904,9 +1914,12 @@
+   ssize_t nrofdevs;
+   libusb_device **devs = NULL;
+   struct libusb_device_descriptor desc;
++  LIBMTP_error_number_t init_usb_ret;
+ 
+   /* See if we can find this raw device again... */
+-  init_usb();
++  init_usb_ret = init_usb();
++  if (init_usb_ret != LIBMTP_ERROR_NONE)
++    return init_usb_ret;
+ 
+   nrofdevs = libusb_get_device_list (NULL, &devs);
+   for (i = 0; i < nrofdevs ; i++) {
diff --git a/patches/14_libusb1_header.patch b/patches/14_libusb1_header.patch
index 9f760ec..065c713 100644
--- a/patches/14_libusb1_header.patch
+++ b/patches/14_libusb1_header.patch
@@ -1,12 +1,12 @@
-diff --git a/src/libusb-glue.h b/src/libusb-glue.h
-index 0ea6b29..55cb373 100644
---- a/src/libusb-glue.h
-+++ b/src/libusb-glue.h
+Index: src/libusb-glue.h
+===================================================================
+--- src/libusb-glue.h	(revision 163078)
++++ src/libusb-glue.h	(working copy)
 @@ -32,7 +32,7 @@
  
  #include "ptp.h"
  #ifdef HAVE_LIBUSB1
--#include <libusb.h>
+-#include <libusb-1.0/libusb.h>
 +#include "libusb.h"
  #endif
  #ifdef HAVE_LIBUSB0
diff --git a/patches/16_fix_leaks.patch b/patches/16_fix_leaks.patch
new file mode 100644
index 0000000..0734570
--- /dev/null
+++ b/patches/16_fix_leaks.patch
@@ -0,0 +1,90 @@
+Index: src/libmtp.c
+===================================================================
+--- src/libmtp.c	(revision 178434)
++++ src/libmtp.c	(working copy)
+@@ -1778,6 +1778,8 @@
+             char *minorstr = strndup(element + i + 1, strlen(element) - i - 1);
+             major = atoi(majorstr);
+             minor = atoi(minorstr);
++	    free(majorstr);
++	    free(minorstr);
+             extension = malloc(sizeof(LIBMTP_device_extension_t));
+             extension->name = name;
+             extension->major = major;
+Index: src/libusb1-glue.c
+===================================================================
+--- src/libusb1-glue.c	(revision 178434)
++++ src/libusb1-glue.c	(working copy)
+@@ -541,6 +541,7 @@
+         }
+       }
+     }
++    libusb_free_device_list (devs, 0);
+ 
+   /* If nothing was found we end up here. */
+   if(*mtp_device_list == NULL) {
+@@ -969,8 +970,10 @@
+       }
+     }
+     int getfunc_ret = handler->getfunc(NULL, handler->priv,towrite,bytes,&towrite);
+-    if (getfunc_ret != PTP_RC_OK)
++    if (getfunc_ret != PTP_RC_OK) {
++      free(bytes);
+       return getfunc_ret;
++    }
+     while (usbwritten < towrite) {
+ 	    ret = USB_BULK_WRITE(ptp_usb->handle,
+ 				    ptp_usb->outep,
+@@ -982,6 +985,7 @@
+ 	    LIBMTP_USB_DEBUG("USB OUT==>\n");
+ 
+ 	    if (ret != LIBUSB_SUCCESS) {
++              free(bytes);
+ 	      return PTP_ERROR_IO;
+ 	    }
+ 	    LIBMTP_USB_DATA(bytes+usbwritten, xwritten, 16);
+@@ -1004,6 +1008,7 @@
+ 						 ptp_usb->current_transfer_total,
+ 						 ptp_usb->current_transfer_callback_data);
+ 	if (ret != 0) {
++          free(bytes);
+ 	  return PTP_ERROR_CANCEL;
+ 	}
+       }
+@@ -2036,6 +2041,7 @@
+   /* Attempt to initialize this device */
+   if (init_ptp_usb(params, ptp_usb, ldevice) < 0) {
+     LIBMTP_ERROR("LIBMTP PANIC: Unable to initialize device\n");
++    libusb_free_device_list (devs, 0);
+     return LIBMTP_ERROR_CONNECTING;
+   }
+ 
+@@ -2051,12 +2057,14 @@
+ 
+     if(init_ptp_usb(params, ptp_usb, ldevice) <0) {
+       LIBMTP_ERROR("LIBMTP PANIC: Could not init USB on second attempt\n");
++      libusb_free_device_list (devs, 0);
+       return LIBMTP_ERROR_CONNECTING;
+     }
+ 
+     /* Device has been reset, try again */
+     if ((ret = ptp_opensession(params, 1)) == PTP_ERROR_IO) {
+       LIBMTP_ERROR("LIBMTP PANIC: failed to open session on second attempt\n");
++      libusb_free_device_list (devs, 0);
+       return LIBMTP_ERROR_CONNECTING;
+     }
+   }
+@@ -2073,11 +2081,13 @@
+ 	    "(Return code %d)\n  Try to reset the device.\n",
+ 	    ret);
+     libusb_release_interface(ptp_usb->handle, ptp_usb->interface);
++    libusb_free_device_list (devs, 0);
+     return LIBMTP_ERROR_CONNECTING;
+   }
+ 
+   /* OK configured properly */
+   *usbinfo = (void *) ptp_usb;
++  libusb_free_device_list (devs, 0);
+   return LIBMTP_ERROR_NONE;
+ }
+ 
diff --git a/patches/17_fix_leak_in_libmtp_release_device.patch b/patches/17_fix_leak_in_libmtp_release_device.patch
new file mode 100644
index 0000000..be36871
--- /dev/null
+++ b/patches/17_fix_leak_in_libmtp_release_device.patch
@@ -0,0 +1,12 @@
+Index: src/libmtp.c
+===================================================================
+--- src/libmtp.c	(revision 178530)
++++ src/libmtp.c	(working copy)
+@@ -2357,6 +2357,7 @@
+   iconv_close(params->cd_ucs2_to_locale);
+   free(ptp_usb);
+   ptp_free_params(params);
++  free(params);
+   free_storage_list(device);
+   // Free extension list...
+   if (device->extensions != NULL) {
diff --git a/patches/20_get_thumbnail_format.patch b/patches/20_get_thumbnail_format.patch
index bc475e2..e30cda0 100644
--- a/patches/20_get_thumbnail_format.patch
+++ b/patches/20_get_thumbnail_format.patch
@@ -1,9 +1,9 @@
 diff --git a/src/libmtp.c b/src/libmtp.c
-index 288440f..c3df3f5 100644
+index bbe2642..b8f856b 100644
 --- a/src/libmtp.c
 +++ b/src/libmtp.c
-@@ -9229,6 +9229,27 @@ int LIBMTP_TruncateObject(LIBMTP_mtpdevice_t *device, uint32_t const id,
- 
+@@ -8962,6 +8962,27 @@ int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *device, uint32_t const id,
+ }
  
  /**
 + * Get thumbnail format of a file.
@@ -31,10 +31,10 @@
   * supplied. If the <code>tracks</code> field of the metadata
   * contains a track listing, these tracks will be added to the
 diff --git a/src/libmtp.h b/src/libmtp.h
-index ade0da0..7b31a8a 100644
+index f923cc1..07aa273 100644
 --- a/src/libmtp.h
 +++ b/src/libmtp.h
-@@ -954,6 +954,8 @@ int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
+@@ -924,6 +924,8 @@ int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
                            LIBMTP_filesampledata_t *);
  int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
                           unsigned char **data, unsigned int *size);
@@ -44,10 +44,10 @@
  /**
   * @}
 diff --git a/src/libmtp.h.in b/src/libmtp.h.in
-index 7523ac0..9935e2b 100644
+index 2b2f0bb..49edd3c 100644
 --- a/src/libmtp.h.in
 +++ b/src/libmtp.h.in
-@@ -954,6 +954,8 @@ int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
+@@ -924,6 +924,8 @@ int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
                            LIBMTP_filesampledata_t *);
  int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
                           unsigned char **data, unsigned int *size);
@@ -57,14 +57,12 @@
  /**
   * @}
 diff --git a/src/libmtp.sym b/src/libmtp.sym
-index 66b87f9..ee65ce4 100644
+index 4130fe8..1148edd 100644
 --- a/src/libmtp.sym
 +++ b/src/libmtp.sym
-@@ -103,6 +103,7 @@ LIBMTP_Set_Playlist_Name
+@@ -103,4 +103,5 @@ LIBMTP_Set_Playlist_Name
  LIBMTP_Set_Album_Name
  LIBMTP_Set_Object_Filename
  LIBMTP_Get_Thumbnail
 +LIBMTP_Get_Thumbnail_Format
  LIBMTP_Read_Event
- LIBMTP_Read_Event_Async
- LIBMTP_Handle_Events_Timeout_Completed
diff --git a/patches/21_fix_build_with_new_glibc.patch b/patches/21_fix_build_with_new_glibc.patch
index b02630d..afd9ea1 100644
--- a/patches/21_fix_build_with_new_glibc.patch
+++ b/patches/21_fix_build_with_new_glibc.patch
@@ -1,15 +1,15 @@
 diff --git a/src/util.h b/src/util.h
-index 0a2d941..e888e9f 100644
+index 64c2d04..02be5bf 100644
 --- a/src/util.h
 +++ b/src/util.h
-@@ -22,7 +22,10 @@
- 
+@@ -23,6 +23,10 @@
  #ifndef __MTP__UTIL__H
  #define __MTP__UTIL__H
-+
+
 +#ifdef HAVE_CONFIG_H
- #include "config.h" // To get HAVE_STRNDUP
++#include "config.h"
 +#endif
- 
++
  void data_dump(FILE *f, void *buf, uint32_t nbytes);
  void data_dump_ascii (FILE *f, void *buf, uint32_t n, uint32_t dump_boundry);
+ #ifndef HAVE_STRNDUP
diff --git a/src/Makefile.am b/src/Makefile.am
index 39f1c61..e0b91a4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,8 +3,7 @@
 libmtp_la_CFLAGS = @LIBUSB_CFLAGS@
 libmtp_la_SOURCES = libmtp.c unicode.c unicode.h util.c util.h \
 	gphoto2-endian.h _stdint.h ptp.c ptp.h libusb-glue.h \
-	music-players.h device-flags.h mtpz.h \
-	chdk_live_view.h chdk_ptp.h
+	music-players.h device-flags.h mtpz.h
 
 if MTPZ_COMPILE
 libmtp_la_SOURCES += mtpz.c
@@ -47,9 +46,9 @@
 #  increment AGE, Otherwise AGE is reset to 0. If CURRENT has changed,
 #  REVISION is set to 0, otherwise REVISION is incremented.
 # ---------------------------------------------------------------------------
-CURRENT=12
-AGE=3
-REVISION=0
+CURRENT=9
+AGE=0
+REVISION=5
 SOVERSION=$(CURRENT):$(REVISION):$(AGE)
 LT_CURRENT_MINUS_AGE=`expr $(CURRENT) - $(AGE)`
 
diff --git a/src/Makefile.in b/src/Makefile.in
index 2c4cc96..2623281 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
-
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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,61 +18,6 @@
 
 
 VPATH = @srcdir@
-am__is_gnu_make = { \
-  if test -z '$(MAKELEVEL)'; then \
-    false; \
-  elif test -n '$(MAKE_HOST)'; then \
-    true; \
-  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
-    true; \
-  else \
-    false; \
-  fi; \
-}
-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@
@@ -95,6 +41,8 @@
 @LIBUSB0_COMPILE_TRUE@am__append_3 = libusb-glue.c
 @LIBOPENUSB_COMPILE_TRUE@am__append_4 = libopenusb1-glue.c
 subdir = src
+DIST_COMMON = README $(include_HEADERS) $(srcdir)/Makefile.am \
+	$(srcdir)/Makefile.in $(srcdir)/libmtp.h.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/byteorder.m4 \
 	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/libtool.m4 \
@@ -103,8 +51,6 @@
 	$(top_srcdir)/m4/stdint.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \
-	$(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = libmtp.h
@@ -142,8 +88,7 @@
 am__libmtp_la_SOURCES_DIST = libmtp.c unicode.c unicode.h util.c \
 	util.h gphoto2-endian.h _stdint.h ptp.c ptp.h \
 	libusb-glue.h music-players.h device-flags.h \
-	mtpz.h chdk_live_view.h chdk_ptp.h mtpz.c libusb1-glue.c \
-	libusb-glue.c libopenusb1-glue.c
+	mtpz.h mtpz.c libusb1-glue.c libusb-glue.c libopenusb1-glue.c
 @MTPZ_COMPILE_TRUE@am__objects_1 = libmtp_la-mtpz.lo
 @LIBUSB1_COMPILE_TRUE@am__objects_2 = libmtp_la-libusb1-glue.lo
 @LIBUSB0_COMPILE_TRUE@am__objects_3 = libmtp_la-libusb-glue.lo
@@ -154,81 +99,31 @@
 	$(am__objects_1) $(am__objects_2) $(am__objects_3) \
 	$(am__objects_4)
 libmtp_la_OBJECTS = $(am_libmtp_la_OBJECTS)
-AM_V_lt = $(am__v_lt_@AM_V@)
-am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
-am__v_lt_0 = --silent
-am__v_lt_1 = 
-libmtp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+libmtp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libmtp_la_CFLAGS) \
 	$(CFLAGS) $(libmtp_la_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_P = $(am__v_P_@AM_V@)
-am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
-am__v_P_0 = false
-am__v_P_1 = :
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo "  GEN     " $@;
-am__v_GEN_1 = 
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
-am__v_at_0 = @
-am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
-	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
-	$(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_@AM_V@)
-am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
-am__v_CC_0 = @echo "  CC      " $@;
-am__v_CC_1 = 
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_@AM_V@)
-am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
-am__v_CCLD_0 = @echo "  CCLD    " $@;
-am__v_CCLD_1 = 
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+	$(LDFLAGS) -o $@
 SOURCES = $(libmtp_la_SOURCES)
 DIST_SOURCES = $(am__libmtp_la_SOURCES_DIST)
-am__can_run_installinfo = \
-  case $$AM_UPDATE_INFO_DIR in \
-    n|no|NO) false;; \
-    *) (install-info --version) >/dev/null 2>&1;; \
-  esac
 DATA = $(noinst_DATA)
 HEADERS = $(include_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
-am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libmtp.h.in \
-	$(top_srcdir)/depcomp README
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AS = @AS@
 AUTOCONF = @AUTOCONF@
@@ -362,8 +257,8 @@
 libmtp_la_SOURCES = libmtp.c unicode.c unicode.h util.c util.h \
 	gphoto2-endian.h _stdint.h ptp.c ptp.h \
 	libusb-glue.h music-players.h device-flags.h \
-	mtpz.h chdk_live_view.h chdk_ptp.h $(am__append_1) \
-	$(am__append_2) $(am__append_3) $(am__append_4)
+	mtpz.h $(am__append_1) $(am__append_2) $(am__append_3) \
+	$(am__append_4)
 include_HEADERS = libmtp.h
 EXTRA_DIST = libmtp.h.in libmtp.sym ptp-pack.c
 
@@ -389,9 +284,9 @@
 #  increment AGE, Otherwise AGE is reset to 0. If CURRENT has changed,
 #  REVISION is set to 0, otherwise REVISION is incremented.
 # ---------------------------------------------------------------------------
-CURRENT = 12
-AGE = 3
-REVISION = 0
+CURRENT = 9
+AGE = 0
+REVISION = 5
 SOVERSION = $(CURRENT):$(REVISION):$(AGE)
 LT_CURRENT_MINUS_AGE = `expr $(CURRENT) - $(AGE)`
 @COMPILE_MINGW32_TRUE@W32_LIBS = -lws2_32
@@ -417,6 +312,7 @@
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign src/Makefile
+.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -436,9 +332,9 @@
 $(am__aclocal_m4_deps):
 libmtp.h: $(top_builddir)/config.status $(srcdir)/libmtp.h.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-
 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 \
@@ -446,8 +342,6 @@
 	  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)"; \
 	}
@@ -463,17 +357,14 @@
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@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}; \
-	}
-
+	@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
 libmtp.la: $(libmtp_la_OBJECTS) $(libmtp_la_DEPENDENCIES) $(EXTRA_libmtp_la_DEPENDENCIES) 
-	$(AM_V_CCLD)$(libmtp_la_LINK) -rpath $(libdir) $(libmtp_la_OBJECTS) $(libmtp_la_LIBADD) $(LIBS)
+	$(libmtp_la_LINK) -rpath $(libdir) $(libmtp_la_OBJECTS) $(libmtp_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -491,81 +382,81 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmtp_la-util.Plo@am__quote@
 
 .c.o:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
 
 .c.obj:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
 
 .c.lo:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
 
 libmtp_la-libmtp.lo: libmtp.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-libmtp.lo -MD -MP -MF $(DEPDIR)/libmtp_la-libmtp.Tpo -c -o libmtp_la-libmtp.lo `test -f 'libmtp.c' || echo '$(srcdir)/'`libmtp.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-libmtp.Tpo $(DEPDIR)/libmtp_la-libmtp.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libmtp.c' object='libmtp_la-libmtp.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-libmtp.lo -MD -MP -MF $(DEPDIR)/libmtp_la-libmtp.Tpo -c -o libmtp_la-libmtp.lo `test -f 'libmtp.c' || echo '$(srcdir)/'`libmtp.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-libmtp.Tpo $(DEPDIR)/libmtp_la-libmtp.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='libmtp.c' object='libmtp_la-libmtp.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-libmtp.lo `test -f 'libmtp.c' || echo '$(srcdir)/'`libmtp.c
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-libmtp.lo `test -f 'libmtp.c' || echo '$(srcdir)/'`libmtp.c
 
 libmtp_la-unicode.lo: unicode.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-unicode.lo -MD -MP -MF $(DEPDIR)/libmtp_la-unicode.Tpo -c -o libmtp_la-unicode.lo `test -f 'unicode.c' || echo '$(srcdir)/'`unicode.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-unicode.Tpo $(DEPDIR)/libmtp_la-unicode.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='unicode.c' object='libmtp_la-unicode.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-unicode.lo -MD -MP -MF $(DEPDIR)/libmtp_la-unicode.Tpo -c -o libmtp_la-unicode.lo `test -f 'unicode.c' || echo '$(srcdir)/'`unicode.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-unicode.Tpo $(DEPDIR)/libmtp_la-unicode.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='unicode.c' object='libmtp_la-unicode.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-unicode.lo `test -f 'unicode.c' || echo '$(srcdir)/'`unicode.c
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-unicode.lo `test -f 'unicode.c' || echo '$(srcdir)/'`unicode.c
 
 libmtp_la-util.lo: util.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-util.lo -MD -MP -MF $(DEPDIR)/libmtp_la-util.Tpo -c -o libmtp_la-util.lo `test -f 'util.c' || echo '$(srcdir)/'`util.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-util.Tpo $(DEPDIR)/libmtp_la-util.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='util.c' object='libmtp_la-util.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-util.lo -MD -MP -MF $(DEPDIR)/libmtp_la-util.Tpo -c -o libmtp_la-util.lo `test -f 'util.c' || echo '$(srcdir)/'`util.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-util.Tpo $(DEPDIR)/libmtp_la-util.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='util.c' object='libmtp_la-util.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-util.lo `test -f 'util.c' || echo '$(srcdir)/'`util.c
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-util.lo `test -f 'util.c' || echo '$(srcdir)/'`util.c
 
 libmtp_la-ptp.lo: ptp.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-ptp.lo -MD -MP -MF $(DEPDIR)/libmtp_la-ptp.Tpo -c -o libmtp_la-ptp.lo `test -f 'ptp.c' || echo '$(srcdir)/'`ptp.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-ptp.Tpo $(DEPDIR)/libmtp_la-ptp.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='ptp.c' object='libmtp_la-ptp.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-ptp.lo -MD -MP -MF $(DEPDIR)/libmtp_la-ptp.Tpo -c -o libmtp_la-ptp.lo `test -f 'ptp.c' || echo '$(srcdir)/'`ptp.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-ptp.Tpo $(DEPDIR)/libmtp_la-ptp.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='ptp.c' object='libmtp_la-ptp.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-ptp.lo `test -f 'ptp.c' || echo '$(srcdir)/'`ptp.c
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-ptp.lo `test -f 'ptp.c' || echo '$(srcdir)/'`ptp.c
 
 libmtp_la-mtpz.lo: mtpz.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-mtpz.lo -MD -MP -MF $(DEPDIR)/libmtp_la-mtpz.Tpo -c -o libmtp_la-mtpz.lo `test -f 'mtpz.c' || echo '$(srcdir)/'`mtpz.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-mtpz.Tpo $(DEPDIR)/libmtp_la-mtpz.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='mtpz.c' object='libmtp_la-mtpz.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-mtpz.lo -MD -MP -MF $(DEPDIR)/libmtp_la-mtpz.Tpo -c -o libmtp_la-mtpz.lo `test -f 'mtpz.c' || echo '$(srcdir)/'`mtpz.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-mtpz.Tpo $(DEPDIR)/libmtp_la-mtpz.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mtpz.c' object='libmtp_la-mtpz.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-mtpz.lo `test -f 'mtpz.c' || echo '$(srcdir)/'`mtpz.c
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-mtpz.lo `test -f 'mtpz.c' || echo '$(srcdir)/'`mtpz.c
 
 libmtp_la-libusb1-glue.lo: libusb1-glue.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-libusb1-glue.lo -MD -MP -MF $(DEPDIR)/libmtp_la-libusb1-glue.Tpo -c -o libmtp_la-libusb1-glue.lo `test -f 'libusb1-glue.c' || echo '$(srcdir)/'`libusb1-glue.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-libusb1-glue.Tpo $(DEPDIR)/libmtp_la-libusb1-glue.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libusb1-glue.c' object='libmtp_la-libusb1-glue.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-libusb1-glue.lo -MD -MP -MF $(DEPDIR)/libmtp_la-libusb1-glue.Tpo -c -o libmtp_la-libusb1-glue.lo `test -f 'libusb1-glue.c' || echo '$(srcdir)/'`libusb1-glue.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-libusb1-glue.Tpo $(DEPDIR)/libmtp_la-libusb1-glue.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='libusb1-glue.c' object='libmtp_la-libusb1-glue.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-libusb1-glue.lo `test -f 'libusb1-glue.c' || echo '$(srcdir)/'`libusb1-glue.c
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-libusb1-glue.lo `test -f 'libusb1-glue.c' || echo '$(srcdir)/'`libusb1-glue.c
 
 libmtp_la-libusb-glue.lo: libusb-glue.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-libusb-glue.lo -MD -MP -MF $(DEPDIR)/libmtp_la-libusb-glue.Tpo -c -o libmtp_la-libusb-glue.lo `test -f 'libusb-glue.c' || echo '$(srcdir)/'`libusb-glue.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-libusb-glue.Tpo $(DEPDIR)/libmtp_la-libusb-glue.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libusb-glue.c' object='libmtp_la-libusb-glue.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-libusb-glue.lo -MD -MP -MF $(DEPDIR)/libmtp_la-libusb-glue.Tpo -c -o libmtp_la-libusb-glue.lo `test -f 'libusb-glue.c' || echo '$(srcdir)/'`libusb-glue.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-libusb-glue.Tpo $(DEPDIR)/libmtp_la-libusb-glue.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='libusb-glue.c' object='libmtp_la-libusb-glue.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-libusb-glue.lo `test -f 'libusb-glue.c' || echo '$(srcdir)/'`libusb-glue.c
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-libusb-glue.lo `test -f 'libusb-glue.c' || echo '$(srcdir)/'`libusb-glue.c
 
 libmtp_la-libopenusb1-glue.lo: libopenusb1-glue.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-libopenusb1-glue.lo -MD -MP -MF $(DEPDIR)/libmtp_la-libopenusb1-glue.Tpo -c -o libmtp_la-libopenusb1-glue.lo `test -f 'libopenusb1-glue.c' || echo '$(srcdir)/'`libopenusb1-glue.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libmtp_la-libopenusb1-glue.Tpo $(DEPDIR)/libmtp_la-libopenusb1-glue.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libopenusb1-glue.c' object='libmtp_la-libopenusb1-glue.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -MT libmtp_la-libopenusb1-glue.lo -MD -MP -MF $(DEPDIR)/libmtp_la-libopenusb1-glue.Tpo -c -o libmtp_la-libopenusb1-glue.lo `test -f 'libopenusb1-glue.c' || echo '$(srcdir)/'`libopenusb1-glue.c
+@am__fastdepCC_TRUE@	$(am__mv) $(DEPDIR)/libmtp_la-libopenusb1-glue.Tpo $(DEPDIR)/libmtp_la-libopenusb1-glue.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='libopenusb1-glue.c' object='libmtp_la-libopenusb1-glue.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-libopenusb1-glue.lo `test -f 'libopenusb1-glue.c' || echo '$(srcdir)/'`libopenusb1-glue.c
+@am__fastdepCC_FALSE@	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmtp_la_CFLAGS) $(CFLAGS) -c -o libmtp_la-libopenusb1-glue.lo `test -f 'libopenusb1-glue.c' || echo '$(srcdir)/'`libopenusb1-glue.c
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -574,11 +465,8 @@
 	-rm -rf .libs _libs
 install-includeHEADERS: $(include_HEADERS)
 	@$(NORMAL_INSTALL)
+	test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
 	@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
-	if test -n "$$list"; then \
-	  echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
-	  $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
-	fi; \
 	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  echo "$$d$$p"; \
@@ -594,15 +482,26 @@
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 	dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
 
-ID: $(am__tagged_files)
-	$(am__define_uniq_tagged_files); mkid -fID $$unique
-tags: tags-am
-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-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	set x; \
 	here=`pwd`; \
-	$(am__define_uniq_tagged_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; }; }'`; \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -614,11 +513,15 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: ctags-am
-
-CTAGS: ctags
-ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
-	$(am__define_uniq_tagged_files); \
+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; }; }'`; \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -627,21 +530,6 @@
 	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
@@ -789,24 +677,22 @@
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
-	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-data \
-	install-data-am install-data-local install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
+.PHONY: CTAGS GTAGS all all-am check check-am clean 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-data install-data-am \
+	install-data-local install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am \
 	install-includeHEADERS 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 tags-am uninstall uninstall-am uninstall-includeHEADERS \
+	tags uninstall uninstall-am uninstall-includeHEADERS \
 	uninstall-libLTLIBRARIES
 
-.PRECIOUS: Makefile
-
 @COMPILE_MINGW32_TRUE@@MS_LIB_EXE_TRUE@libmtp.def: $(srcdir)/libmtp.sym
 @COMPILE_MINGW32_TRUE@@MS_LIB_EXE_TRUE@	echo "LIBRARY \"@PACKAGE@\"" > libmtp.def
 @COMPILE_MINGW32_TRUE@@MS_LIB_EXE_TRUE@	echo "DESCRIPTION \"Media Transfer Protocol (MTP) library\"" >> libmtp.def
diff --git a/src/chdk_live_view.h b/src/chdk_live_view.h
deleted file mode 100644
index 8c20669..0000000
--- a/src/chdk_live_view.h
+++ /dev/null
@@ -1,99 +0,0 @@
-#ifndef __LIVE_VIEW_H
-#define __LIVE_VIEW_H
-
-// Note: used in modules and platform independent code. 
-// Do not add platform dependent stuff in here (#ifdef/#endif compile options or camera dependent values)
-
-/*
-Protocol notes:
-- Unless otherwise specified, all structure values are packed in camera native (little
-  endian) byte order
-- Frame buffer and palette data are in native camera formats
-  Some documentation may be found at http://chdk.wikia.com/wiki/Frame_buffers 
-- The frame buffer descriptions returned may not be correct depending on the
-  camera model and various camera settings (shooting mode, digital zoom, aspect ratio)
-  This may result in partial images, garbage in the "valid" area or incorrect position
-- In some cases, the requested data may not be available. If this happens, the framebuffer
-  or palette data offset will be zero. 
-- The frame buffer descriptions are returned regardless of whether the data is available
-*/
-// Live View protocol version
-#define LIVE_VIEW_VERSION_MAJOR 2  // increase only with backwards incompatible changes (and reset minor)
-#define LIVE_VIEW_VERSION_MINOR 1  // increase with extensions of functionality
-
-/*
-protocol version history
-< 2.0 - development versions
-2.0 - initial release, chdk 1.1
-2.1 - added palette type 4 - 16 entry VUYA, 2 bit alpha
-*/
-
-
-// Control flags for determining which data block to transfer
-#define LV_TFR_VIEWPORT     0x01
-#define LV_TFR_BITMAP       0x04
-#define LV_TFR_PALETTE      0x08
-
-enum lv_aspect_rato {
-    LV_ASPECT_4_3,
-    LV_ASPECT_16_9,
-};
-
-/*
-Framebuffer types
-additional values will be added if new data formats appear
-*/
-enum lv_fb_type {
-    LV_FB_YUV8, // 8 bit per element UYVYYY, used for live view
-    LV_FB_PAL8, // 8 bit paletted, used for bitmap overlay. Note palette data and type sent separately
-};
-
-/*
-framebuffer data description
-NOTE YUV pixels widths are based on the number of Y elements
-*/
-typedef struct {
-    int fb_type; // framebuffer type - note future versions might use different structures depending on type
-    int data_start; // offset of data from start of live view header
-    /*
-    buffer width in pixels
-    data size is always buffer_width*visible_height*(buffer bpp based on type)
-    */
-    int buffer_width;
-    /*
-    visible size in pixels
-    describes data within the buffer which contains image data to be displayed
-    any offsets within buffer data are added before sending, so the top left
-    pixel is always the first first byte of data.
-    width must always be <= buffer_width
-    if buffer_width is > width, the additional data should be skipped
-    visible_height also defines the number of data rows
-    */
-    int visible_width;
-    int visible_height;
-
-    /*
-    margins
-    pixels offsets needed to replicate display position on cameras screen
-    not used for any buffer offsets
-    */
-    int margin_left;
-    int margin_top;
-
-    int margin_right;
-    int margin_bot;
-} lv_framebuffer_desc;
-
-typedef struct {
-    // live view sub-protocol version
-    int version_major;
-    int version_minor;
-    int lcd_aspect_ratio; // physical aspect ratio of LCD
-    int palette_type;
-    int palette_data_start;
-    // framebuffer descriptions are given as offsets, to allow expanding the structures in minor protocol changes
-    int vp_desc_start;
-    int bm_desc_start;
-} lv_data_header;
-
-#endif // __LIVE_VIEW_H
diff --git a/src/chdk_ptp.h b/src/chdk_ptp.h
deleted file mode 100644
index 068be02..0000000
--- a/src/chdk_ptp.h
+++ /dev/null
@@ -1,278 +0,0 @@
-#ifndef __CHDK_PTP_H
-#define __CHDK_PTP_H
-
-// CHDK PTP protocol interface (can also be used in client PTP programs)
-
-// Note: used in modules and platform independent code. 
-// Do not add platform dependent stuff in here (#ifdef/#endif compile options or camera dependent values)
-
-#define PTP_CHDK_VERSION_MAJOR 2  // increase only with backwards incompatible changes (and reset minor)
-#define PTP_CHDK_VERSION_MINOR 6  // increase with extensions of functionality
-                                  // minor > 1000 for development versions
-
-/*
-protocol version history
-0.1 - initial proposal from mweerden, + luar
-0.2 - Added ScriptStatus and ScriptSupport, based on work by ultimA
-1.0 - removed old script result code (luar), replace with message system
-2.0 - return PTP_CHDK_TYPE_TABLE for tables instead of TYPE_STRING, allow return of empty strings
-2.1 - experimental live view, not formally released
-2.2 - live view (work in progress)
-2.3 - live view - released in 1.1
-2.4 - live view protocol 2.1
-2.5 - remote capture
-2.6 - script execution flags
-*/
-
-#define PTP_OC_CHDK 0x9999
-
-// N.B.: unused parameters should be set to 0
-//enum ptp_chdk_command {
-enum PTP_CHDK_Command {
-  PTP_CHDK_Version = 0,     // return param1 is major version number
-                            // return param2 is minor version number
-  PTP_CHDK_GetMemory,       // param2 is base address (not NULL; circumvent by taking 0xFFFFFFFF and size+1)
-                            // param3 is size (in bytes)
-                            // return data is memory block
-  PTP_CHDK_SetMemory,       // param2 is address
-                            // param3 is size (in bytes)
-                            // data is new memory block
-  PTP_CHDK_CallFunction,    // data is array of function pointer and 32 bit int arguments (max: 10 args prior to protocol 2.5)
-                            // return param1 is return value
-  PTP_CHDK_TempData,        // data is data to be stored for later
-                            // param2 is for the TD flags below
-  PTP_CHDK_UploadFile,      // data is 4-byte length of filename, followed by filename and contents
-  PTP_CHDK_DownloadFile,    // preceded by PTP_CHDK_TempData with filename
-                            // return data are file contents
-  PTP_CHDK_ExecuteScript,   // data is script to be executed
-                            // param2 is language of script
-                            //  in proto 2.6 and later, language is the lower byte, rest is used for PTP_CHDK_SCRIPT_FL* flags
-                            // return param1 is script id, like a process id
-                            // return param2 is status from ptp_chdk_script_error_type
-  PTP_CHDK_ScriptStatus,    // Script execution status
-                            // return param1 bits
-                            // PTP_CHDK_SCRIPT_STATUS_RUN is set if a script running, cleared if not
-                            // PTP_CHDK_SCRIPT_STATUS_MSG is set if script messages from script waiting to be read
-                            // all other bits and params are reserved for future use
-  PTP_CHDK_ScriptSupport,   // Which scripting interfaces are supported in this build
-                            // param1 CHDK_PTP_SUPPORT_LUA is set if lua is supported, cleared if not
-                            // all other bits and params are reserved for future use
-  PTP_CHDK_ReadScriptMsg,   // read next message from camera script system
-                            // return param1 is chdk_ptp_s_msg_type
-                            // return param2 is message subtype:
-                            //   for script return and users this is ptp_chdk_script_data_type
-                            //   for error ptp_chdk_script_error_type
-                            // return param3 is script id of script that generated the message
-                            // return param4 is length of the message data. 
-                            // return data is message.
-                            // A minimum of 1 bytes of zeros is returned if the message has no data (empty string or type NONE)
-  PTP_CHDK_WriteScriptMsg,  // write a message for scripts running on camera
-                            // input param2 is target script id, 0=don't care. Messages for a non-running script will be discarded
-                            // data length is handled by ptp data phase
-                            // input messages do not have type or subtype, they are always a string destined for the script (similar to USER/string)
-                            // output param1 is ptp_chdk_script_msg_status
-  PTP_CHDK_GetDisplayData,  // Return camera display data
-                            // This is defined as separate sub protocol in live_view.h
-                            // Changes to the sub-protocol will always be considered a minor change to the main protocol
-                            //  param2 bitmask of data
-                            //  output param1 = total size of data
-                            //  return data is protocol information, frame buffer descriptions and selected display data
-                            //  Currently a data phase is always returned. Future versions may define other behavior 
-                            //  for values in currently unused parameters.
-  // Direct image capture over USB.
-  // Use lua get_usb_capture_support for available data types, lua init_usb_capture for setup
-  PTP_CHDK_RemoteCaptureIsReady, // Check if data is available
-                                 // return param1 is status 
-                                 //  0 = not ready
-                                 //  0x10000000 = remote capture not initialized
-                                 //  otherwise bitmask of PTP_CHDK_CAPTURE_* datatypes
-                                 // return param2 is image number
-  PTP_CHDK_RemoteCaptureGetData  // retrieve data
-                                 // param2 is bit indicating data type to get
-                                 // return param1 is length
-                                 // return param2 more chunks available?
-                                 //  0 = no more chunks of selected format
-                                 // return param3 seek required to pos (-1 = no seek)
-};
-
-// data types as used by ReadScriptMessage
-enum ptp_chdk_script_data_type {
-  PTP_CHDK_TYPE_UNSUPPORTED = 0, // type name will be returned in data
-  PTP_CHDK_TYPE_NIL,
-  PTP_CHDK_TYPE_BOOLEAN,
-  PTP_CHDK_TYPE_INTEGER,
-  PTP_CHDK_TYPE_STRING, // Empty strings are returned with length=0
-  PTP_CHDK_TYPE_TABLE,  // tables are converted to a string by usb_msg_table_to_string, 
-                        // this function can be overridden in lua to change the format
-                        // the string may be empty for an empty table
-};
-
-// TempData flags
-#define PTP_CHDK_TD_DOWNLOAD  0x1  // download data instead of upload
-#define PTP_CHDK_TD_CLEAR     0x2  // clear the stored data; with DOWNLOAD this
-                                   // means first download, then clear and
-                                   // without DOWNLOAD this means no uploading,
-                                   // just clear
-
-// Script Languages - for execution only lua is supported for now
-#define PTP_CHDK_SL_LUA    0
-#define PTP_CHDK_SL_UBASIC 1
-#define PTP_CHDK_SL_MASK 0xFF
-
-/* standard message chdkptp sends */
-#define PTP_CHDK_LUA_SERIALIZE "\n\
-serialize_r = function(v,opts,r,seen,depth)\n\
-        local vt = type(v)\n\
-        if vt == 'nil' or  vt == 'boolean' or vt == 'number' then\n\
-                table.insert(r,tostring(v))\n\
-                return\n\
-        end\n\
-        if vt == 'string' then\n\
-                table.insert(r,string.format('%q',v))\n\
-                return\n\
-        end\n\
-        if vt == 'table' then\n\
-                if not depth then\n\
-                        depth = 1\n\
-                end\n\
-                if depth >= opts.maxdepth then\n\
-                        error('serialize: max depth')\n\
-                end\n\
-                if not seen then\n\
-                        seen={}\n\
-                elseif seen[v] then\n\
-                        if opts.err_cycle then\n\
-                                error('serialize: cycle')\n\
-                        else\n\
-                                table.insert(r,'\"cycle:'..tostring(v)..'\"')\n\
-                                return\n\
-                        end\n\
-                end\n\
-                seen[v] = true;\n\
-                table.insert(r,'{')\n\
-                for k,v1 in pairs(v) do\n\
-                        if opts.pretty then\n\
-                                table.insert(r,'\\n'..string.rep(' ',depth))\n\
-                        end\n\
-                        if type(k) == 'string' and string.match(k,'^[_%a][%a%d_]*$') then\n\
-                                table.insert(r,k)\n\
-                        else\n\
-                                table.insert(r,'[')\n\
-                                serialize_r(k,opts,r,seen,depth+1)\n\
-                                table.insert(r,']')\n\
-                        end\n\
-                        table.insert(r,'=')\n\
-                        serialize_r(v1,opts,r,seen,depth+1)\n\
-                        table.insert(r,',')\n\
-                end\n\
-                if opts.pretty then\n\
-                        table.insert(r,'\\n'..string.rep(' ',depth-1))\n\
-                end\n\
-                table.insert(r,'}')\n\
-                return\n\
-        end\n\
-        if opts.err_type then\n\
-                error('serialize: unsupported type ' .. vt, 2)\n\
-        else\n\
-                table.insert(r,'\"'..tostring(v)..'\"')\n\
-        end\n\
-end\n\
-serialize_defaults = {\n\
-        maxdepth=10,\n\
-        err_type=true,\n\
-        err_cycle=true,\n\
-        pretty=false,\n\
-}\n\
-function serialize(v,opts)\n\
-        if opts then\n\
-                for k,v in pairs(serialize_defaults) do\n\
-                        if not opts[k] then\n\
-                                opts[k]=v\n\
-                        end\n\
-                end\n\
-        else\n\
-                opts=serialize_defaults\n\
-        end\n\
-        local r={}\n\
-        serialize_r(v,opts,r)\n\
-        return table.concat(r)\n\
-end\n\
-\n\
-usb_msg_table_to_string=serialize\n"
-
-
-// bit flags for script start
-#define PTP_CHDK_SCRIPT_FL_NOKILL           0x100 // if script is running return error instead of killing
-#define PTP_CHDK_SCRIPT_FL_FLUSH_CAM_MSGS   0x200 // discard existing cam->host messages before starting
-#define PTP_CHDK_SCRIPT_FL_FLUSH_HOST_MSGS  0x400 // discard existing host->cam messages before starting
-
-// bit flags for script status
-#define PTP_CHDK_SCRIPT_STATUS_RUN   0x1 // script running
-#define PTP_CHDK_SCRIPT_STATUS_MSG   0x2 // messages waiting
-// bit flags for scripting support
-#define PTP_CHDK_SCRIPT_SUPPORT_LUA  0x1
-
-
-// bit flags for remote capture
-// used to select and also to indicate available data in PTP_CHDK_RemoteCaptureIsReady
-/*
-Full jpeg file. Note supported on all cameras, use Lua get_usb_capture_support to check
-*/
-#define PTP_CHDK_CAPTURE_JPG    0x1 
-
-/*
-Raw framebuffer data, in camera native format.
-A subset of rows may be requested in init_usb_capture.
-*/
-#define PTP_CHDK_CAPTURE_RAW    0x2
-
-/*
-DNG header. 
-The header will be DNG version 1.3
-Does not include image data, clients wanting to create a DNG file should also request RAW
-Raw data for all known cameras will be packed, little endian. Client is responsible for
-reversing the byte order if creating a DNG.
-Can requested without RAW to get sensor dimensions, exif values etc.
-
-ifd 0 specifies a 128x96 RGB thumbnail, 4 byte aligned following the header
-client is responsible for generating thumbnail data.
-
-ifd 0 subifd 0 specifies the main image
-The image dimensions always contain the full sensor dimensions, if a sub-image was requested
-with init_usb_capture, the client is responsible for padding the data to the full image or
-adjusting dimensions.
-
-Bad pixels will not be patched, but DNG opcodes will specify how to patch them
-*/
-#define PTP_CHDK_CAPTURE_DNGHDR 0x4  
-
-// status from PTP_CHDK_RemoteCaptureIsReady if capture not enabled
-#define PTP_CHDK_CAPTURE_NOTSET 0x10000000
-
-// message types
-enum ptp_chdk_script_msg_type {
-    PTP_CHDK_S_MSGTYPE_NONE = 0, // no messages waiting
-    PTP_CHDK_S_MSGTYPE_ERR,      // error message
-    PTP_CHDK_S_MSGTYPE_RET,      // script return value
-    PTP_CHDK_S_MSGTYPE_USER,     // message queued by script
-// TODO chdk console data ?
-};
-
-// error subtypes for PTP_CHDK_S_MSGTYPE_ERR and script startup status
-enum ptp_chdk_script_error_type {
-    PTP_CHDK_S_ERRTYPE_NONE = 0,
-    PTP_CHDK_S_ERRTYPE_COMPILE,
-    PTP_CHDK_S_ERRTYPE_RUN,
-    // the following are for ExecuteScript status only, not message types
-    PTP_CHDK_S_ERR_SCRIPTRUNNING = 0x1000, // script already running with NOKILL
-};
-
-// message status
-enum ptp_chdk_script_msg_status {
-    PTP_CHDK_S_MSGSTATUS_OK = 0, // queued ok
-    PTP_CHDK_S_MSGSTATUS_NOTRUN, // no script is running
-    PTP_CHDK_S_MSGSTATUS_QFULL,  // queue is full
-    PTP_CHDK_S_MSGSTATUS_BADID,  // specified ID is not running
-};
-
-#endif // __CHDK_PTP_H
diff --git a/src/device-flags.h b/src/device-flags.h
index ba3f22b..06ef62a 100644
--- a/src/device-flags.h
+++ b/src/device-flags.h
@@ -241,7 +241,7 @@
  * Direct PTP match required.
  * (libgphoto2)
  */
-#define DEVICE_FLAG_OLYMPUS_XML_WRAPPED		0x00800000
+#define DEVICE_FLAG_MATCH_PTP_INTERFACE		0x00800000
 /**
  * This flag is like DEVICE_FLAG_OGG_IS_UNKNOWN but for FLAC
  * files instead. Using the unknown filetype for FLAC files.
@@ -272,9 +272,6 @@
  * Early Creative Zen (etc) models actually only support
  * command 9805 (Get object property list) and will hang
  * if you try to get individual properties of an object.
- * Or so it seemed. Later bug fixes to the library has made
- * this work flawlessly so the bug flag is moot.
- * NOT USED ANYMORE, THIS FLAG MAY BE RECYCLED.
  */
 #define DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL	0x20000000
 /**
@@ -298,7 +295,7 @@
   (DEVICE_FLAG_UNLOAD_DRIVER | \
    DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | \
    DEVICE_FLAG_UNIQUE_FILENAMES | \
-   DEVICE_FLAG_FORCE_RESET_ON_CLOSE)
+   DEVICE_FLAG_FORCE_RESET_ON_CLOSE )
 /**
  * All these bug flags need to be set on Android devices,
  * they claim to support MTP operations they actually
@@ -311,8 +308,7 @@
    DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST | \
    DEVICE_FLAG_BROKEN_SEND_OBJECT_PROPLIST | \
    DEVICE_FLAG_UNLOAD_DRIVER | \
-   DEVICE_FLAG_LONG_TIMEOUT | \
-   DEVICE_FLAG_FORCE_RESET_ON_CLOSE)
+   DEVICE_FLAG_LONG_TIMEOUT )
 /**
  * All these bug flags appear on a number of SonyEricsson
  * devices including Android devices not using the stock
@@ -330,4 +326,4 @@
 #define DEVICE_FLAGS_ARICENT_BUGS \
   (DEVICE_FLAG_IGNORE_HEADER_ERRORS | \
    DEVICE_FLAG_BROKEN_SEND_OBJECT_PROPLIST | \
-   DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST)
+   DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST )
diff --git a/src/gphoto2-endian.h b/src/gphoto2-endian.h
index ddc17f3..4794882 100644
--- a/src/gphoto2-endian.h
+++ b/src/gphoto2-endian.h
@@ -1,5 +1,5 @@
 /* This file is generated automatically by configure */
-/* It is valid only for the system type x86_64-suse-linux-gnu */
+/* It is valid only for the system type x86_64-unknown-linux-gnu */
 
 #ifndef __BYTEORDER_H
 #define __BYTEORDER_H
diff --git a/src/libmtp.c b/src/libmtp.c
index c3df3f5..b8f856b 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -116,20 +116,11 @@
   struct propertymap_struct *next;
 } propertymap_t;
 
-/*
- * This is a simple container for holding our callback and user_data
- * for parsing onwards to the usb_event_async function.
- */
-typedef struct event_cb_data_struct {
-  LIBMTP_event_cb_fn cb;
-  void *user_data;
-} event_cb_data_t;
-
 // Global variables
 // This holds the global filetype mapping table
-static filemap_t *g_filemap = NULL;
+static filemap_t *filemap = NULL;
 // This holds the global property mapping table
-static propertymap_t *g_propertymap = NULL;
+static propertymap_t *propertymap = NULL;
 
 /*
  * Forward declarations of local (static) functions.
@@ -153,8 +144,7 @@
 				    uint32_t parent);
 static void free_storage_list(LIBMTP_mtpdevice_t *device);
 static int sort_storage_by(LIBMTP_mtpdevice_t *device, int const sortby);
-static uint32_t get_writeable_storageid(LIBMTP_mtpdevice_t *device,
-					uint64_t fitsize);
+static uint32_t get_writeable_storageid(LIBMTP_mtpdevice_t *device, uint64_t fitsize);
 static int get_storage_freespace(LIBMTP_mtpdevice_t *device,
 				 LIBMTP_devicestorage_t *storage,
 				 uint64_t *freespace);
@@ -221,8 +211,6 @@
                 const char **newname);
 static char *generate_unique_filename(PTPParams* params, char const * const filename);
 static int check_filename_exists(PTPParams* params, char const * const filename);
-static void LIBMTP_Handle_Event(PTPContainer *ptp_event,
-                                LIBMTP_event_t *event, uint32_t *out1);
 
 /**
  * These are to wrap the get/put handlers to convert from the MTP types to PTP types
@@ -235,7 +223,7 @@
 } MTPDataHandler;
 
 static uint16_t get_func_wrapper(PTPParams* params, void* priv, unsigned long wantlen, unsigned char *data, unsigned long *gotlen);
-static uint16_t put_func_wrapper(PTPParams* params, void* priv, unsigned long sendlen, unsigned char *data);
+static uint16_t put_func_wrapper(PTPParams* params, void* priv, unsigned long sendlen, unsigned char *data, unsigned long *putlen);
 
 /**
  * Checks if a filename ends with ".ogg". Used in various
@@ -317,7 +305,7 @@
   filemap_t *new = NULL, *current;
 
   // Has this LIBMTP filetype been registered before ?
-  current = g_filemap;
+  current = filemap;
   while (current != NULL) {
     if(current->id == id) {
       break;
@@ -339,10 +327,10 @@
     new->ptp_id = ptp_id;
 
     // Add the entry to the list
-    if(g_filemap == NULL) {
-      g_filemap = new;
+    if(filemap == NULL) {
+      filemap = new;
     } else {
-      current = g_filemap;
+      current = filemap;
       while (current->next != NULL ) current=current->next;
       current->next = new;
     }
@@ -419,7 +407,7 @@
 {
   filemap_t *current;
 
-  current = g_filemap;
+  current = filemap;
 
   while (current != NULL) {
     if(current->id == intype) {
@@ -442,7 +430,7 @@
 {
   filemap_t *current;
 
-  current = g_filemap;
+  current = filemap;
 
   while (current != NULL) {
     if(current->ptp_id == intype) {
@@ -488,7 +476,7 @@
   propertymap_t *new = NULL, *current;
 
   // Has this LIBMTP propety been registered before ?
-  current = g_propertymap;
+  current = propertymap;
   while (current != NULL) {
     if(current->id == id) {
       break;
@@ -510,10 +498,10 @@
     new->ptp_id = ptp_id;
 
     // Add the entry to the list
-    if(g_propertymap == NULL) {
-      g_propertymap = new;
+    if(propertymap == NULL) {
+      propertymap = new;
     } else {
-      current = g_propertymap;
+      current = propertymap;
       while (current->next != NULL ) current=current->next;
       current->next = new;
     }
@@ -713,7 +701,7 @@
 {
   propertymap_t *current;
 
-  current = g_propertymap;
+  current = propertymap;
 
   while (current != NULL) {
     if(current->id == inproperty) {
@@ -735,7 +723,7 @@
 {
   propertymap_t *current;
 
-  current = g_propertymap;
+  current = propertymap;
 
   while (current != NULL) {
     if(current->ptp_id == inproperty) {
@@ -808,7 +796,7 @@
 {
   filemap_t *current;
 
-  current = g_filemap;
+  current = filemap;
 
   while (current != NULL) {
     if(current->id == intype) {
@@ -831,7 +819,7 @@
 {
   propertymap_t *current;
 
-  current = g_propertymap;
+  current = propertymap;
 
   while (current != NULL) {
     if(current->id == inproperty) {
@@ -1340,14 +1328,13 @@
 {
   PTPPropertyValue propval;
   char *retstring = NULL;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
   MTPProperties *prop;
 
-  if (!device || !object_id)
+  if ( device == NULL || object_id == 0) {
     return NULL;
-
-  params = (PTPParams *) device->params;
+  }
 
   prop = ptp_find_object_prop_in_cache(params, object_id, attribute_id);
   if (prop) {
@@ -1384,14 +1371,13 @@
 {
   PTPPropertyValue propval;
   uint64_t retval = value_default;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
   MTPProperties *prop;
 
-  if (!device)
+  if ( device == NULL ) {
     return value_default;
-
-  params = (PTPParams *) device->params;
+  }
 
   prop = ptp_find_object_prop_in_cache(params, object_id, attribute_id);
   if (prop)
@@ -1424,14 +1410,13 @@
 {
   PTPPropertyValue propval;
   uint32_t retval = value_default;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
   MTPProperties *prop;
 
-  if (!device)
+  if ( device == NULL ) {
     return value_default;
-
-  params = (PTPParams *) device->params;
+  }
 
   prop = ptp_find_object_prop_in_cache(params, object_id, attribute_id);
   if (prop)
@@ -1463,14 +1448,13 @@
 {
   PTPPropertyValue propval;
   uint16_t retval = value_default;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
   MTPProperties *prop;
 
-  if (!device)
+  if ( device == NULL ) {
     return value_default;
-
-  params = (PTPParams *) device->params;
+  }
 
   // This O(n) search should not be used so often, since code
   // using the cached properties don't usually call this function.
@@ -1505,14 +1489,13 @@
 {
   PTPPropertyValue propval;
   uint8_t retval = value_default;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
   MTPProperties *prop;
 
-  if (!device)
+  if ( device == NULL ) {
     return value_default;
-
-  params = (PTPParams *) device->params;
+  }
 
   // This O(n) search should not be used so often, since code
   // using the cached properties don't usually call this function.
@@ -1546,13 +1529,12 @@
 			     uint16_t const attribute_id, char const * const string)
 {
   PTPPropertyValue propval;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
 
-  if (!device || !string)
+  if (device == NULL || string == NULL) {
     return -1;
-
-  params = (PTPParams *) device->params;
+  }
 
   if (!ptp_operation_issupported(params,PTP_OC_MTP_SetObjectPropValue)) {
     add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "set_object_string(): could not set object string: "
@@ -1583,13 +1565,12 @@
 			  uint16_t const attribute_id, uint32_t const value)
 {
   PTPPropertyValue propval;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
 
-  if (!device)
+  if (device == NULL) {
     return -1;
-
-  params = (PTPParams *) device->params;
+  }
 
   if (!ptp_operation_issupported(params,PTP_OC_MTP_SetObjectPropValue)) {
     add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "set_object_u32(): could not set unsigned 32bit integer property: "
@@ -1620,13 +1601,12 @@
 			  uint16_t const attribute_id, uint16_t const value)
 {
   PTPPropertyValue propval;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
 
-  if (!device)
+  if (device == NULL) {
     return 1;
-
-  params = (PTPParams *) device->params;
+  }
 
   if (!ptp_operation_issupported(params,PTP_OC_MTP_SetObjectPropValue)) {
     add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "set_object_u16(): could not set unsigned 16bit integer property: "
@@ -1656,13 +1636,12 @@
 			 uint16_t const attribute_id, uint8_t const value)
 {
   PTPPropertyValue propval;
-  PTPParams *params;
+  PTPParams *params = (PTPParams *) device->params;
   uint16_t ret;
 
-  if (!device)
+  if (device == NULL) {
     return 1;
-
-  params = (PTPParams *) device->params;
+  }
 
   if (!ptp_operation_issupported(params,PTP_OC_MTP_SetObjectPropValue)) {
     add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "set_object_u8(): could not set unsigned 8bit integer property: "
@@ -1697,7 +1676,6 @@
   }
 
   if (devices == NULL || numdevs == 0) {
-    free(devices);
     return NULL;
   }
 
@@ -1768,12 +1746,12 @@
   /* descriptors are divided by semicolons */
   while (end < strlen(desc)) {
     /* Skip past initial whitespace */
-    while ((end < strlen(desc)) && (desc[start] == ' ' )) {
+    while (desc[start] == ' ' && end < strlen(desc)) {
       start++;
       end++;
     }
     /* Detect extension */
-    while ((end < strlen(desc)) && (desc[end] != ';'))
+    while (desc[end] != ';' && end < strlen(desc))
       end++;
     if (end < strlen(desc)) {
       char *element = strndup(desc + start, end-start);
@@ -1782,7 +1760,7 @@
         // printf("  Element: \"%s\"\n", element);
 
         /* Parse for an extension */
-        while ((i < strlen(element)) && (element[i] != ':'))
+        while (element[i] != ':' && i < strlen(element))
           i++;
         if (i < strlen(element)) {
           char *name = strndup(element, i);
@@ -1790,7 +1768,7 @@
           // printf("    Extension: \"%s\"\n", name);
 
           /* Parse for minor/major punctuation mark for this extension */
-          while ((i < strlen(element)) && (element[i] != '.'))
+          while (element[i] != '.' && i < strlen(element))
             i++;
           if (i > majstart && i < strlen(element)) {
             LIBMTP_device_extension_t *extension;
@@ -1800,8 +1778,6 @@
             char *minorstr = strndup(element + i + 1, strlen(element) - i - 1);
             major = atoi(majorstr);
             minor = atoi(minorstr);
-            // printf("    Major: \"%s\" (parsed %d) Minor: \"%s\" (parsed %d)\n",
-            //      majorstr, major, minorstr, minor);
 	    free(majorstr);
 	    free(minorstr);
             extension = malloc(sizeof(LIBMTP_device_extension_t));
@@ -1817,6 +1793,8 @@
                 tmp = tmp->next;
               tmp->next = extension;
             }
+            // printf("    Major: \"%s\" (parsed %d) Minor: \"%s\" (parsed %d)\n",
+            //      majorstr, major, minorstr, minor);
           } else {
             LIBMTP_ERROR("LIBMTP ERROR: couldnt parse extension %s\n",
                          element);
@@ -1849,6 +1827,7 @@
 
   /* Allocate dynamic space for our device */
   mtp_device = (LIBMTP_mtpdevice_t *) malloc(sizeof(LIBMTP_mtpdevice_t));
+  memset(mtp_device, 0, sizeof(LIBMTP_mtpdevice_t));
   /* Check if there was a memory allocation error */
   if(mtp_device == NULL) {
     /* There has been an memory allocation error. We are going to ignore this
@@ -1861,7 +1840,6 @@
 
     return NULL;
   }
-  memset(mtp_device, 0, sizeof(LIBMTP_mtpdevice_t));
   // Non-cached by default
   mtp_device->cached = 0;
 
@@ -2175,27 +2153,27 @@
   PTPParams *params = (PTPParams *) device->params;
   PTPContainer ptp_event;
   uint16_t ret = ptp_usb_event_wait(params, &ptp_event);
+  uint16_t code;
+  uint32_t session_id;
+  uint32_t transaction_id;
+  uint32_t param1;
+  uint32_t param2;
+  uint32_t param3;
 
   if (ret != PTP_RC_OK) {
     /* Device is closing down or other fatal stuff, exit thread */
     return -1;
   }
-  LIBMTP_Handle_Event(&ptp_event, event, out1);
-  return 0;
-}
-
-void LIBMTP_Handle_Event(PTPContainer *ptp_event,
-                         LIBMTP_event_t *event, uint32_t *out1) {
-  uint16_t code;
-  uint32_t session_id;
-  uint32_t param1;
 
   *event = LIBMTP_EVENT_NONE;
 
   /* Process the event */
-  code = ptp_event->Code;
-  session_id = ptp_event->SessionID;
-  param1 = ptp_event->Param1;
+  code = ptp_event.Code;
+  session_id = ptp_event.SessionID;
+  transaction_id = ptp_event.Transaction_ID;
+  param1 = ptp_event.Param1;
+  param2 = ptp_event.Param2;
+  param3 = ptp_event.Param3;
 
   switch(code) {
     case PTP_EC_Undefined:
@@ -2206,13 +2184,9 @@
       break;
     case PTP_EC_ObjectAdded:
       LIBMTP_INFO("Received event PTP_EC_ObjectAdded in session %u\n", session_id);
-      *event = LIBMTP_EVENT_OBJECT_ADDED;
-      *out1 = param1;
       break;
     case PTP_EC_ObjectRemoved:
       LIBMTP_INFO("Received event PTP_EC_ObjectRemoved in session %u\n", session_id);
-      *event = LIBMTP_EVENT_OBJECT_REMOVED;
-      *out1 = param1;
       break;
     case PTP_EC_StoreAdded:
       LIBMTP_INFO("Received event PTP_EC_StoreAdded in session %u\n", session_id);
@@ -2223,8 +2197,6 @@
     case PTP_EC_StoreRemoved:
       LIBMTP_INFO("Received event PTP_EC_StoreRemoved in session %u\n", session_id);
       /* TODO: rescan storages */
-      *event = LIBMTP_EVENT_STORE_REMOVED;
-      *out1 = param1;
       break;
     case PTP_EC_DevicePropChanged:
       LIBMTP_INFO("Received event PTP_EC_DevicePropChanged in session %u\n", session_id);
@@ -2261,60 +2233,8 @@
       LIBMTP_INFO( "Received unknown event in session %u\n", session_id);
       break;
   }
-}
 
-static void LIBMTP_Read_Event_Cb(PTPParams *params, uint16_t ret_code,
-                                 PTPContainer *ptp_event, void *user_data) {
-  event_cb_data_t *data = user_data;
-  LIBMTP_event_t event = LIBMTP_EVENT_NONE;
-  uint32_t param1 = 0;
-  int handler_ret;
-
-  switch (ret_code) {
-  case PTP_RC_OK:
-    handler_ret = LIBMTP_HANDLER_RETURN_OK;
-    LIBMTP_Handle_Event(ptp_event, &event, &param1);
-    break;
-  case PTP_ERROR_CANCEL:
-    handler_ret = LIBMTP_HANDLER_RETURN_CANCEL;
-    break;
-  default:
-    handler_ret = LIBMTP_HANDLER_RETURN_ERROR;
-    break;
-  }
-
-  data->cb(handler_ret, event, param1, data->user_data);
-  free(data);
-}
-
-/**
- * This function reads events sent by the device, in a non-blocking manner.
- * The callback function will be called when an event is received, but for the function
- * to make progress, polling must take place, using LIBMTP_Handle_Events_Timeout_Completed.
- *
- * After an event is received, this function should be called again to listen for the next
- * event.
- *
- * For now, this non-blocking mechanism only works with libusb-1.0, and not any of the
- * other usb library backends. Attempting to call this method with another backend will
- * always return an error.
- *
- * @param device a pointer to the MTP device to poll for events.
- * @param cb a callback to be invoked when an event is received.
- * @param user_data arbitrary user data passed to the callback.
- * @return 0 on success, any other value means that the callback was not registered and
- *         no event notification will take place.
- */
-int LIBMTP_Read_Event_Async(LIBMTP_mtpdevice_t *device, LIBMTP_event_cb_fn cb, void *user_data) {
-  PTPParams *params = (PTPParams *) device->params;
-  event_cb_data_t *data =  malloc(sizeof(event_cb_data_t));
-  uint16_t ret;
-
-  data->cb = cb;
-  data->user_data = user_data;
-
-  ret = ptp_usb_event_async(params, LIBMTP_Read_Event_Cb, data);
-  return ret == PTP_RC_OK ? 0 : -1;
+  return 0;
 }
 
 /**
@@ -2388,7 +2308,6 @@
   /* Assign linked list of devices */
   if (devices == NULL || numdevs == 0) {
     *device_list = NULL;
-    free(devices);
     return LIBMTP_ERROR_NO_DEVICE_ATTACHED;
   }
 
@@ -2496,8 +2415,6 @@
 					uint16_t ptp_error,
 					char const * const error_text)
 {
-  PTPParams      *params = (PTPParams *) device->params;
-
   if (device == NULL) {
     LIBMTP_ERROR("LIBMTP PANIC: Trying to add PTP error to a NULL device!\n");
     return;
@@ -2507,7 +2424,7 @@
     outstr[sizeof(outstr)-1] = '\0';
     add_error_to_errorstack(device, LIBMTP_ERROR_PTP_LAYER, outstr);
 
-    snprintf(outstr, sizeof(outstr), "Error %04x: %s", ptp_error, ptp_strerror(ptp_error, params->deviceinfo.VendorExtensionID));
+    snprintf(outstr, sizeof(outstr), "Error %04x: %s", ptp_error, ptp_strerror(ptp_error));
     outstr[sizeof(outstr)-1] = '\0';
     add_error_to_errorstack(device, LIBMTP_ERROR_PTP_LAYER, outstr);
   }
@@ -2663,7 +2580,7 @@
       prop++;
   }
   lasthandle = 0xffffffff;
-  params->objects = calloc (cnt, sizeof(PTPObject));
+  params->objects = calloc (sizeof(PTPObject),cnt);
   prop = props;
   i = -1;
   for (j=0;j<nrofprops;j++) {
@@ -2713,7 +2630,7 @@
         newprops = realloc(params->objects[i].mtpprops,
 		(params->objects[i].nrofmtpprops+1)*sizeof(MTPProperties));
       } else {
-        newprops = calloc(1,sizeof(MTPProperties));
+        newprops = calloc(sizeof(MTPProperties),1);
       }
       if (!newprops) return 0; /* FIXME: error handling? */
       params->objects[i].mtpprops = newprops;
@@ -2729,7 +2646,6 @@
   /* mark last entry also */
   params->objects[i].flags |= PTPOBJECT_OBJECTINFO_LOADED;
   params->nrofobjects = i+1;
-  free (props);
   /* The device might not give the list in linear ascending order */
   ptp_objects_sort (params);
   return 0;
@@ -3013,8 +2929,7 @@
  *        storage for.
  * @param fitsize a file of this file must fit on the device.
  */
-static uint32_t get_writeable_storageid(LIBMTP_mtpdevice_t *device,
-					uint64_t fitsize)
+static uint32_t get_writeable_storageid(LIBMTP_mtpdevice_t *device, uint64_t fitsize)
 {
   LIBMTP_devicestorage_t *storage;
   uint32_t store = 0x00000000; //Should this be 0xffffffffu instead?
@@ -3067,32 +2982,6 @@
 }
 
 /**
- * Tries to suggest a storage_id of a given ID when we have a parent
- * @param device a pointer to the device where to search for the storage ID
- * @param fitsize a file of this file must fit on the device.
- * @param parent_id look for this ID
- * @ret storageID
- */
-static int get_suggested_storage_id(LIBMTP_mtpdevice_t *device,
-				    uint64_t fitsize,
-				    uint32_t parent_id)
-{
-  PTPParams *params = (PTPParams *) device->params;
-  PTPObject *ob;
-  uint16_t ret;
-
-  ret = ptp_object_want(params, parent_id, PTPOBJECT_MTPPROPLIST_LOADED, &ob);
-  if ((ret != PTP_RC_OK) || (ob->oi.StorageID == 0)) {
-    add_ptp_error_to_errorstack(device, ret, "get_suggested_storage_id(): "
-				"could not get storage id from parent id.");
-    return get_writeable_storageid(device, fitsize);
-  } else {
-    /* OK we know the parent storage, then use that */
-    return ob->oi.StorageID;
-  }
-}
-
-/**
  * This function grabs the freespace from a certain storage in
  * device storage list.
  * @param device a pointer to the MTP device to free the storage
@@ -3181,7 +3070,7 @@
   for (i=0;i<params->deviceinfo.OperationsSupported_len;i++) {
     char txt[256];
 
-    (void) ptp_render_ofc(params, params->deviceinfo.OperationsSupported[i],
+    (void) ptp_render_opcode(params, params->deviceinfo.OperationsSupported[i],
 			     sizeof(txt), txt);
     printf("   %04x: %s\n", params->deviceinfo.OperationsSupported[i], txt);
   }
@@ -4026,45 +3915,6 @@
 }
 
 /**
- * This function checks if the device has some specific capabilities, in
- * order to avoid calling APIs that may disturb the device.
- *
- * @param device a pointer to the device to check the capability on.
- * @param cap the capability to check.
- * @return 0 if not supported, any other value means the device has the
- * requested capability.
- */
-int LIBMTP_Check_Capability(LIBMTP_mtpdevice_t *device, LIBMTP_devicecap_t cap)
-{
-  switch (cap) {
-  case LIBMTP_DEVICECAP_GetPartialObject:
-    return (ptp_operation_issupported(device->params,
-				      PTP_OC_GetPartialObject) ||
-	    ptp_operation_issupported(device->params,
-				      PTP_OC_ANDROID_GetPartialObject64));
-  case LIBMTP_DEVICECAP_SendPartialObject:
-    return ptp_operation_issupported(device->params,
-				     PTP_OC_ANDROID_SendPartialObject);
-  case LIBMTP_DEVICECAP_EditObjects:
-    return (ptp_operation_issupported(device->params,
-				      PTP_OC_ANDROID_TruncateObject) &&
-	    ptp_operation_issupported(device->params,
-				      PTP_OC_ANDROID_BeginEditObject) &&
-	    ptp_operation_issupported(device->params,
-				      PTP_OC_ANDROID_EndEditObject));
-  /*
-   * Handle other capabilities here, this is also a good place to
-   * blacklist some advanced operations on specific devices if need
-   * be.
-   */
-
-  default:
-    break;
-  }
-  return 0;
-}
-
-/**
  * This function updates all the storage id's of a device and their
  * properties, then creates a linked list and puts the list head into
  * the device struct. It also optionally sorts this list. If you want
@@ -5274,19 +5124,16 @@
  * This is a manual conversion from MTPDataPutFunc to PTPDataPutFunc
  * to isolate the internal type.
  */
-static uint16_t put_func_wrapper(PTPParams* params, void* priv, unsigned long sendlen, unsigned char *data)
+static uint16_t put_func_wrapper(PTPParams* params, void* priv, unsigned long sendlen, unsigned char *data, unsigned long *putlen)
 {
   MTPDataHandler *handler = (MTPDataHandler *)priv;
   uint16_t ret;
   uint32_t local_putlen = 0;
-
   ret = handler->putfunc(params, handler->priv, sendlen, data, &local_putlen);
-
+  *putlen = local_putlen;
   switch (ret)
   {
     case LIBMTP_HANDLER_RETURN_OK:
-      if (local_putlen != sendlen)
-	return PTP_ERROR_IO;
       return PTP_RC_OK;
     case LIBMTP_HANDLER_RETURN_ERROR:
       return PTP_ERROR_IO;
@@ -6242,12 +6089,12 @@
     return -1;
   }
 #endif
+
   if (filedata->storage_id != 0) {
     store = filedata->storage_id;
   } else {
-    store = get_suggested_storage_id(device, filedata->filesize, localph);
+    store = get_writeable_storageid(device, filedata->filesize);
   }
-
   // Detect if something non-primary is in use.
   storage = device->storage;
   if (storage != NULL && store != storage->id) {
@@ -6462,12 +6309,8 @@
     if (FLAG_ONLY_7BIT_FILENAMES(ptp_usb)) {
       strip_7bit_from_utf8(new_file.Filename);
     }
-    if (filedata->filesize > 0xFFFFFFFFL) {
-      // This is a kludge in the MTP standard for large files.
-      new_file.ObjectCompressedSize = (uint32_t) 0xFFFFFFFF;
-    } else {
-      new_file.ObjectCompressedSize = (uint32_t) filedata->filesize;
-    }
+    // We lose precision here.
+    new_file.ObjectCompressedSize = (uint32_t) filedata->filesize;
     new_file.ObjectFormat = of;
     new_file.StorageID = store;
     new_file.ParentObject = localph;
@@ -7471,7 +7314,7 @@
  *        if the device does not support all the characters in the
  *        name.
  * @param parent_id id of parent folder to add the new folder to,
- *        or 0xFFFFFFFF to put it in the root directory.
+ *        or 0 to put it in the root directory.
  * @param storage_id id of the storage to add this new folder to.
  *        notice that you cannot mismatch storage id and parent id:
  *        they must both be on the same storage! Pass in 0 if you
@@ -7491,7 +7334,7 @@
 
   if (storage_id == 0) {
     // I'm just guessing that a folder may require 512 bytes
-    store = get_suggested_storage_id(device, 512, parent_id);
+    store = get_writeable_storageid(device, 512);
   } else {
     store = storage_id;
   }
@@ -7798,7 +7641,7 @@
 
   if (storageid == 0) {
     // I'm just guessing that an abstract list may require 512 bytes
-    store = get_suggested_storage_id(device, 512, localph);
+    store = get_writeable_storageid(device, 512);
   } else {
     store = storageid;
   }
@@ -8240,7 +8083,6 @@
 	  add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "update_abstract_list(): "
 				  "could not set artist name.");
 	}
-	break;
       case PTP_OPC_Composer:
 	// Update composer
 	ret = set_object_string(device, objecthandle, PTP_OPC_Composer, composer);
@@ -8270,7 +8112,6 @@
 	  }
 	  free(tmpdate);
 	}
-	break;
       default:
 	break;
       }
@@ -9120,114 +8961,6 @@
   return -1;
 }
 
-
-int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *device, uint32_t const id,
-                            uint64_t offset, uint32_t maxbytes,
-                            unsigned char **data, unsigned int *size)
-{
-  PTPParams *params = (PTPParams *) device->params;
-  uint16_t ret;
-
-  if (!ptp_operation_issupported(params, PTP_OC_ANDROID_GetPartialObject64)) {
-    if  (!ptp_operation_issupported(params, PTP_OC_GetPartialObject)) {
-      add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
-        "LIBMTP_GetPartialObject: PTP_OC_GetPartialObject not supported");
-      return -1;
-    }
-
-    if (offset >> 32 != 0) {
-      add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
-        "LIBMTP_GetPartialObject: PTP_OC_GetPartialObject only supports 32bit offsets");
-      return -1;
-    }
-
-    ret = ptp_getpartialobject(params, id, (uint32_t)offset, maxbytes, data, size);
-  } else {
-    ret = ptp_android_getpartialobject64(params, id, offset, maxbytes, data, size);
-  }
-  if (ret == PTP_RC_OK)
-      return 0;
-  return -1;
-}
-
-
-int LIBMTP_SendPartialObject(LIBMTP_mtpdevice_t *device, uint32_t const id,
-                             uint64_t offset, unsigned char *data, unsigned int size)
-{
-  PTPParams *params = (PTPParams *) device->params;
-  uint16_t ret;
-
-  if (!ptp_operation_issupported(params, PTP_OC_ANDROID_SendPartialObject)) {
-    add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
-      "LIBMTP_SendPartialObject: PTP_OC_ANDROID_SendPartialObject not supported");
-    return -1;
-  }
-
-  ret = ptp_android_sendpartialobject(params, id, offset, data, size);
-  if (ret == PTP_RC_OK)
-      return 0;
-  return -1;
-}
-
-
-int LIBMTP_BeginEditObject(LIBMTP_mtpdevice_t *device, uint32_t const id)
-{
-  PTPParams *params = (PTPParams *) device->params;
-  uint16_t ret;
-
-  if (!ptp_operation_issupported(params, PTP_OC_ANDROID_BeginEditObject)) {
-    add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
-      "LIBMTP_BeginEditObject: PTP_OC_ANDROID_BeginEditObject not supported");
-    return -1;
-  }
-
-  ret = ptp_android_begineditobject(params, id);
-  if (ret == PTP_RC_OK)
-      return 0;
-  return -1;
-}
-
-
-int LIBMTP_EndEditObject(LIBMTP_mtpdevice_t *device, uint32_t const id)
-{
-  PTPParams *params = (PTPParams *) device->params;
-  uint16_t ret;
-
-  if (!ptp_operation_issupported(params, PTP_OC_ANDROID_EndEditObject)) {
-    add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
-      "LIBMTP_EndEditObject: PTP_OC_ANDROID_EndEditObject not supported");
-    return -1;
-  }
-
-  ret = ptp_android_endeditobject(params, id);
-  if (ret == PTP_RC_OK) {
-      // update cached object properties if metadata cache exists
-      update_metadata_cache(device, id);
-      return 0;
-  }
-  return -1;
-}
-
-
-int LIBMTP_TruncateObject(LIBMTP_mtpdevice_t *device, uint32_t const id,
-                          uint64_t offset)
-{
-  PTPParams *params = (PTPParams *) device->params;
-  uint16_t ret;
-
-  if (!ptp_operation_issupported(params, PTP_OC_ANDROID_TruncateObject)) {
-    add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
-      "LIBMTP_TruncateObject: PTP_OC_ANDROID_TruncateObject not supported");
-    return -1;
-  }
-
-  ret = ptp_android_truncate(params, id, offset);
-  if (ret == PTP_RC_OK)
-      return 0;
-  return -1;
-}
-
-
 /**
  * Get thumbnail format of a file.
  * @param device a pointer to the device to get thumbnail format of.
diff --git a/src/libmtp.h b/src/libmtp.h
index 7b31a8a..07aa273 100644
--- a/src/libmtp.h
+++ b/src/libmtp.h
@@ -2,7 +2,7 @@
  * \file libmtp.h
  * Interface to the Media Transfer Protocol library.
  *
- * Copyright (C) 2005-2013 Linus Walleij <triad@df.lth.se>
+ * Copyright (C) 2005-2012 Linus Walleij <triad@df.lth.se>
  * Copyright (C) 2005-2008 Richard A. Low <richard@wentnet.com>
  * Copyright (C) 2007 Ted Bullock <tbullock@canada.com>
  * Copyright (C) 2008 Florent Mertens <flomertens@gmail.com>
@@ -29,8 +29,8 @@
 #ifndef LIBMTP_H_INCLUSION_GUARD
 #define LIBMTP_H_INCLUSION_GUARD
 
-#define LIBMTP_VERSION 1.1.12
-#define LIBMTP_VERSION_STRING "1.1.12"
+#define LIBMTP_VERSION 1.1.5
+#define LIBMTP_VERSION_STRING "1.1.5"
 
 /* This handles MSVC pecularities */
 #ifdef _MSC_VER
@@ -50,8 +50,6 @@
 typedef __int32 int32_t;
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int64 uint64_t;
-#else
-#include <sys/time.h>
 #endif
 
 #include <stdio.h>
@@ -405,30 +403,6 @@
 } LIBMTP_datatype_t;
 
 /**
- * These are device capabilities
- */
-typedef enum {
-  /**
-   * This capability tells whether you can call the funcion getting
-   * partial objects, @see LIBMTP_GetPartialObject()
-   */
-  LIBMTP_DEVICECAP_GetPartialObject,
-  /**
-   * This capability tells whether you can call the function sending
-   * partial objects. @see LIBMTP_SendPartialObject()
-   */
-  LIBMTP_DEVICECAP_SendPartialObject,
-  /**
-   * This capability tells whether you can call the functions editing
-   * objects in-place on a device.
-   * @see LIBMTP_BeginEditObject()
-   * @see LIBMTP_EndEditObject()
-   * @see LIBMTP_TruncateObject()
-   */
-  LIBMTP_DEVICECAP_EditObjects,
-} LIBMTP_devicecap_t;
-
-/**
  * These are the numbered error codes. You can also
  * get string representations for errors.
  */
@@ -797,9 +771,6 @@
 enum LIBMTP_event_enum {
   LIBMTP_EVENT_NONE,
   LIBMTP_EVENT_STORE_ADDED,
-  LIBMTP_EVENT_STORE_REMOVED,
-  LIBMTP_EVENT_OBJECT_ADDED,
-  LIBMTP_EVENT_OBJECT_REMOVED,
 };
 typedef enum LIBMTP_event_enum LIBMTP_event_t;
 
@@ -851,7 +822,6 @@
 int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
 int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
 int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
-int LIBMTP_Check_Capability(LIBMTP_mtpdevice_t *, LIBMTP_devicecap_t);
 LIBMTP_error_t *LIBMTP_Get_Errorstack(LIBMTP_mtpdevice_t*);
 void LIBMTP_Clear_Errorstack(LIBMTP_mtpdevice_t*);
 void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*);
@@ -1009,7 +979,7 @@
 int LIBMTP_Set_Folder_Name(LIBMTP_mtpdevice_t *, LIBMTP_folder_t *, const char *);
 /** @} */
 
-
+#if 0
 /**
  * @}
  * @defgroup playlists The audio/video playlist management API.
@@ -1022,6 +992,7 @@
 int LIBMTP_Create_New_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
 int LIBMTP_Update_Playlist(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t * const);
 int LIBMTP_Set_Playlist_Name(LIBMTP_mtpdevice_t *, LIBMTP_playlist_t *, const char *);
+#endif
 
 /**
  * @}
@@ -1044,24 +1015,14 @@
  */
 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
 int LIBMTP_Set_Object_Filename(LIBMTP_mtpdevice_t *, uint32_t , char *);
-int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
-                            uint64_t, uint32_t,
-                            unsigned char **, unsigned int *);
-int LIBMTP_SendPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
-                             uint64_t, unsigned char *, unsigned int);
-int LIBMTP_BeginEditObject(LIBMTP_mtpdevice_t *, uint32_t const);
-int LIBMTP_EndEditObject(LIBMTP_mtpdevice_t *, uint32_t const);
-int LIBMTP_TruncateObject(LIBMTP_mtpdevice_t *, uint32_t const, uint64_t);
 
 /**
  * @}
  * @defgroup files The events API.
  * @{
  */
-typedef void(* LIBMTP_event_cb_fn) (int, LIBMTP_event_t, uint32_t, void *);
 int LIBMTP_Read_Event(LIBMTP_mtpdevice_t *, LIBMTP_event_t *, uint32_t *);
-int LIBMTP_Read_Event_Async(LIBMTP_mtpdevice_t *, LIBMTP_event_cb_fn, void *);
-int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *, int *);
+
 
 /** @} */
 
@@ -1071,4 +1032,3 @@
 #endif
 
 #endif /* LIBMTP_H_INCLUSION_GUARD */
-
diff --git a/src/libmtp.h.in b/src/libmtp.h.in
index 9935e2b..49edd3c 100644
--- a/src/libmtp.h.in
+++ b/src/libmtp.h.in
@@ -2,7 +2,7 @@
  * \file libmtp.h
  * Interface to the Media Transfer Protocol library.
  *
- * Copyright (C) 2005-2013 Linus Walleij <triad@df.lth.se>
+ * Copyright (C) 2005-2012 Linus Walleij <triad@df.lth.se>
  * Copyright (C) 2005-2008 Richard A. Low <richard@wentnet.com>
  * Copyright (C) 2007 Ted Bullock <tbullock@canada.com>
  * Copyright (C) 2008 Florent Mertens <flomertens@gmail.com>
@@ -50,8 +50,6 @@
 typedef __int32 int32_t;
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int64 uint64_t;
-#else
-#include <sys/time.h>
 #endif
 
 #include <stdio.h>
@@ -405,30 +403,6 @@
 } LIBMTP_datatype_t;
 
 /**
- * These are device capabilities
- */
-typedef enum {
-  /**
-   * This capability tells whether you can call the funcion getting
-   * partial objects, @see LIBMTP_GetPartialObject()
-   */
-  LIBMTP_DEVICECAP_GetPartialObject,
-  /**
-   * This capability tells whether you can call the function sending
-   * partial objects. @see LIBMTP_SendPartialObject()
-   */
-  LIBMTP_DEVICECAP_SendPartialObject,
-  /**
-   * This capability tells whether you can call the functions editing
-   * objects in-place on a device.
-   * @see LIBMTP_BeginEditObject()
-   * @see LIBMTP_EndEditObject()
-   * @see LIBMTP_TruncateObject()
-   */
-  LIBMTP_DEVICECAP_EditObjects,
-} LIBMTP_devicecap_t;
-
-/**
  * These are the numbered error codes. You can also
  * get string representations for errors.
  */
@@ -797,9 +771,6 @@
 enum LIBMTP_event_enum {
   LIBMTP_EVENT_NONE,
   LIBMTP_EVENT_STORE_ADDED,
-  LIBMTP_EVENT_STORE_REMOVED,
-  LIBMTP_EVENT_OBJECT_ADDED,
-  LIBMTP_EVENT_OBJECT_REMOVED,
 };
 typedef enum LIBMTP_event_enum LIBMTP_event_t;
 
@@ -851,7 +822,6 @@
 int LIBMTP_Get_Secure_Time(LIBMTP_mtpdevice_t *, char ** const);
 int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *, char ** const);
 int LIBMTP_Get_Supported_Filetypes(LIBMTP_mtpdevice_t *, uint16_t ** const, uint16_t * const);
-int LIBMTP_Check_Capability(LIBMTP_mtpdevice_t *, LIBMTP_devicecap_t);
 LIBMTP_error_t *LIBMTP_Get_Errorstack(LIBMTP_mtpdevice_t*);
 void LIBMTP_Clear_Errorstack(LIBMTP_mtpdevice_t*);
 void LIBMTP_Dump_Errorstack(LIBMTP_mtpdevice_t*);
@@ -1045,24 +1015,14 @@
  */
 int LIBMTP_Delete_Object(LIBMTP_mtpdevice_t *, uint32_t);
 int LIBMTP_Set_Object_Filename(LIBMTP_mtpdevice_t *, uint32_t , char *);
-int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
-                            uint64_t, uint32_t,
-                            unsigned char **, unsigned int *);
-int LIBMTP_SendPartialObject(LIBMTP_mtpdevice_t *, uint32_t const,
-                             uint64_t, unsigned char *, unsigned int);
-int LIBMTP_BeginEditObject(LIBMTP_mtpdevice_t *, uint32_t const);
-int LIBMTP_EndEditObject(LIBMTP_mtpdevice_t *, uint32_t const);
-int LIBMTP_TruncateObject(LIBMTP_mtpdevice_t *, uint32_t const, uint64_t);
 
 /**
  * @}
  * @defgroup files The events API.
  * @{
  */
-typedef void(* LIBMTP_event_cb_fn) (int, LIBMTP_event_t, uint32_t, void *);
 int LIBMTP_Read_Event(LIBMTP_mtpdevice_t *, LIBMTP_event_t *, uint32_t *);
-int LIBMTP_Read_Event_Async(LIBMTP_mtpdevice_t *, LIBMTP_event_cb_fn, void *);
-int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *, int *);
+
 
 /** @} */
 
diff --git a/src/libmtp.sym b/src/libmtp.sym
index ee65ce4..1148edd 100644
--- a/src/libmtp.sym
+++ b/src/libmtp.sym
@@ -105,11 +105,3 @@
 LIBMTP_Get_Thumbnail
 LIBMTP_Get_Thumbnail_Format
 LIBMTP_Read_Event
-LIBMTP_Read_Event_Async
-LIBMTP_Handle_Events_Timeout_Completed
-LIBMTP_GetPartialObject
-LIBMTP_SendPartialObject
-LIBMTP_BeginEditObject
-LIBMTP_EndEditObject
-LIBMTP_TruncateObject
-LIBMTP_Check_Capability
diff --git a/src/libopenusb1-glue.c b/src/libopenusb1-glue.c
index da9b935..8bd3757 100644
--- a/src/libopenusb1-glue.c
+++ b/src/libopenusb1-glue.c
@@ -661,7 +661,17 @@
             }
         }
         if (!device_known) {
-            device_unknown(i, desc.idVendor, desc.idProduct);
+            // This device is unknown to the developers
+            LIBMTP_ERROR("Device %d (VID=%04x and PID=%04x) is UNKNOWN.\n",
+                    i,
+                    desc.idVendor,
+                    desc.idProduct);
+            LIBMTP_ERROR("Please report this VID/PID and the device model to the libmtp development team\n");
+            /*
+             * Trying to get iManufacturer or iProduct from the device at this
+             * point would require opening a device handle, that we don't want
+             * to do right now. (Takes time for no good enough reason.)
+             */
         }
         // Save the location on the bus
         retdevs[i].bus_location = 0;
@@ -793,23 +803,7 @@
     unsigned long written;
     unsigned char *bytes;
     int expect_terminator_byte = 0;
-    unsigned long usb_inep_maxpacket_size;
-    unsigned long context_block_size_1;
-    unsigned long context_block_size_2;
-    uint16_t ptp_dev_vendor_id = ptp_usb->rawdevice.device_entry.vendor_id;
 
-    //"iRiver" device special handling
-    if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) {
-	    usb_inep_maxpacket_size = ptp_usb->inep_maxpacket;
-	    if (usb_inep_maxpacket_size == 0x400) {
-		    context_block_size_1 = CONTEXT_BLOCK_SIZE_1 - 0x200;
-		    context_block_size_2 = CONTEXT_BLOCK_SIZE_2 + 0x200;
-	    }
-	    else {
-		    context_block_size_1 = CONTEXT_BLOCK_SIZE_1;
-		    context_block_size_2 = CONTEXT_BLOCK_SIZE_2;
-	    }
-    }
     struct openusb_bulk_request bulk;
     // This is the largest block we'll need to read in.
     bytes = malloc(CONTEXT_BLOCK_SIZE);
@@ -826,21 +820,16 @@
                 toread += 1;
                 expect_terminator_byte = 1;
             }
-        } else if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) {
-		//"iRiver" device special handling
-		if (curread == 0)
-			// we are first packet, but not last packet
-			toread = context_block_size_1;
-		else if (toread == context_block_size_1)
-			toread = context_block_size_2;
-		else if (toread == context_block_size_2)
-			toread = context_block_size_1;
-		else
-			LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n",
-				    (unsigned int) toread, (unsigned int) (size - curread));
-	}
-	else
-		toread = CONTEXT_BLOCK_SIZE;
+        } else if (curread == 0)
+            // we are first packet, but not last packet
+            toread = CONTEXT_BLOCK_SIZE_1;
+        else if (toread == CONTEXT_BLOCK_SIZE_1)
+            toread = CONTEXT_BLOCK_SIZE_2;
+        else if (toread == CONTEXT_BLOCK_SIZE_2)
+            toread = CONTEXT_BLOCK_SIZE_1;
+        else
+            LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n",
+                (unsigned int) toread, (unsigned int) (size - curread));
 
         LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread);
 
@@ -877,7 +866,7 @@
             xread--;
         }
 
-        int putfunc_ret = handler->putfunc(NULL, handler->priv, xread, bytes);
+        int putfunc_ret = handler->putfunc(NULL, handler->priv, xread, bytes, &written);
         LIBMTP_USB_DEBUG("handler->putfunc ret = 0x%x\n", putfunc_ret);
         if (putfunc_ret != PTP_RC_OK)
             return putfunc_ret;
@@ -1085,7 +1074,8 @@
 
 static uint16_t
 memory_putfunc(PTPParams* params, void* private,
-        unsigned long sendlen, unsigned char *data
+        unsigned long sendlen, unsigned char *data,
+        unsigned long *putlen
         ) {
     PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*) private;
 
@@ -1095,6 +1085,7 @@
     }
     memcpy(priv->data + priv->curoff, data, sendlen);
     priv->curoff += sendlen;
+    *putlen = sendlen;
     return PTP_RC_OK;
 }
 
@@ -1157,7 +1148,7 @@
 /* send / receive functions */
 
 uint16_t
-ptp_usb_sendreq(PTPParams* params, PTPContainer* req, int dataphase) {
+ptp_usb_sendreq(PTPParams* params, PTPContainer* req) {
     uint16_t ret;
     PTPUSBBulkContainer usbreq;
     PTPDataHandler memhandler;
@@ -1166,7 +1157,7 @@
 
     char txt[256];
 
-    (void) ptp_render_ofc(params, req->Code, sizeof (txt), txt);
+    (void) ptp_render_opcode(params, req->Code, sizeof (txt), txt);
     LIBMTP_USB_DEBUG("REQUEST: 0x%04x, %s\n", req->Code, txt);
 
     /* build appropriate USB container */
@@ -1205,13 +1196,13 @@
 
 uint16_t
 ptp_usb_senddata(PTPParams* params, PTPContainer* ptp,
-        uint64_t size, PTPDataHandler *handler
+        unsigned long size, PTPDataHandler *handler
         ) {
     uint16_t ret;
     int wlen, datawlen;
     unsigned long written;
     PTPUSBBulkContainer usbdata;
-    uint64_t bytes_left_to_transfer;
+    uint32_t bytes_left_to_transfer;
     PTPDataHandler memhandler;
 
     LIBMTP_USB_DEBUG("SEND DATA PHASE\n");
@@ -1275,10 +1266,6 @@
     PTPDataHandler memhandler;
     uint16_t ret;
     unsigned char *x = NULL;
-    unsigned long packet_size;
-    PTP_USB *ptp_usb = (PTP_USB *) params->data;
-
-    packet_size = ptp_usb->inep_maxpacket;
 
     /* read the header and potentially the first data */
     if (params->response_packet_size > 0) {
@@ -1292,7 +1279,7 @@
         return PTP_RC_OK;
     }
     ptp_init_recv_memory_handler(&memhandler);
-    ret = ptp_read_func(packet_size, &memhandler, params->data, rlen, 0);
+    ret = ptp_read_func(PTP_USB_BULK_HS_MAX_PACKET_LEN_READ, &memhandler, params->data, rlen, 0);
     ptp_exit_recv_memory_handler(&memhandler, &x, rlen);
     if (x) {
         memcpy(packet, x, *rlen);
@@ -1349,11 +1336,12 @@
                 break;
             }
         }
-        if (rlen == ptp_usb->inep_maxpacket) {
+        if (usbdata.length == 0xffffffffU) {
             /* Copy first part of data to 'data' */
             putfunc_ret =
                     handler->putfunc(
-                    params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data
+                    params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data,
+                    &written
                     );
             if (putfunc_ret != PTP_RC_OK)
                 return putfunc_ret;
@@ -1364,7 +1352,7 @@
                 uint16_t xret;
 
                 xret = ptp_read_func(
-                        0x20000000,
+                        PTP_USB_BULK_HS_MAX_PACKET_LEN_READ,
                         handler,
                         params->data,
                         &readdata,
@@ -1372,7 +1360,7 @@
                         );
                 if (xret != PTP_RC_OK)
                     return xret;
-                if (readdata < 0x20000000)
+                if (readdata < PTP_USB_BULK_HS_MAX_PACKET_LEN_READ)
                     break;
             }
             return PTP_RC_OK;
@@ -1423,13 +1411,14 @@
         putfunc_ret =
                 handler->putfunc(
                 params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN,
-                usbdata.payload.data
+                usbdata.payload.data,
+                &written
                 );
         if (putfunc_ret != PTP_RC_OK)
             return putfunc_ret;
 
         if (FLAG_NO_ZERO_READS(ptp_usb) &&
-                len + PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket) {
+                len + PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ) {
 
             LIBMTP_USB_DEBUG("Reading in extra terminating byte\n");
 
@@ -1455,8 +1444,8 @@
             xread = bulk.result.transferred_bytes;
 
             if (result != 1)
-                LIBMTP_INFO("Could not read in extra byte for %d bytes long file, return value 0x%04x\n", ptp_usb->inep_maxpacket, result);
-        } else if (len + PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket && params->split_header_data == 0) {
+                LIBMTP_INFO("Could not read in extra byte for PTP_USB_BULK_HS_MAX_PACKET_LEN_READ long file, return value 0x%04x\n", result);
+        } else if (len + PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ && params->split_header_data == 0) {
             int zeroresult = 0, xread;
             unsigned char zerobyte = 0;
 
@@ -1692,17 +1681,6 @@
 }
 
 uint16_t
-ptp_usb_event_async (PTPParams* params, PTPEventCbFn cb, void *user_data) {
-	/* Unsupported */
-	return PTP_ERROR_CANCEL;
-}
-
-int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *tv, int *completed) {
-	/* Unsupported */
-	return -12;
-}
-
-uint16_t
 ptp_usb_control_cancel_request(PTPParams *params, uint32_t transactionid) {
     PTP_USB *ptp_usb = (PTP_USB *) (params->data);
     int ret;
diff --git a/src/libusb-glue.c b/src/libusb-glue.c
index bdf41b4..7c23f14 100644
--- a/src/libusb-glue.c
+++ b/src/libusb-glue.c
@@ -676,9 +676,18 @@
       }
     }
     if (!device_known) {
-      device_unknown(i,
-                     dev->libusb_device->descriptor.idVendor,
-                     dev->libusb_device->descriptor.idProduct);
+      // This device is unknown to the developers
+      LIBMTP_ERROR("Device %d (VID=%04x and PID=%04x) is UNKNOWN.\n",
+	      i,
+	      dev->libusb_device->descriptor.idVendor,
+	      dev->libusb_device->descriptor.idProduct);
+      LIBMTP_ERROR("Please report this VID/PID and the device model to the "
+	      "libmtp development team\n");
+      /*
+       * Trying to get iManufacturer or iProduct from the device at this
+       * point would require opening a device handle, that we don't want
+       * to do right now. (Takes time for no good enough reason.)
+       */
     }
     // Save the location on the bus
     retdevs[i].bus_location = dev->bus_location;
@@ -812,7 +821,6 @@
 #define CONTEXT_BLOCK_SIZE_1	0x3e00
 #define CONTEXT_BLOCK_SIZE_2  0x200
 #define CONTEXT_BLOCK_SIZE    CONTEXT_BLOCK_SIZE_1+CONTEXT_BLOCK_SIZE_2
-
 static short
 ptp_read_func (
 	unsigned long size, PTPDataHandler *handler,void *data,
@@ -823,25 +831,9 @@
   unsigned long toread = 0;
   int result = 0;
   unsigned long curread = 0;
+  unsigned long written;
   unsigned char *bytes;
   int expect_terminator_byte = 0;
-  unsigned long usb_inep_maxpacket_size;
-  unsigned long context_block_size_1;
-  unsigned long context_block_size_2;
-  uint16_t ptp_dev_vendor_id = ptp_usb->rawdevice.device_entry.vendor_id;
-
-  //"iRiver" device special handling
-  if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) {
-	  usb_inep_maxpacket_size = ptp_usb->inep_maxpacket;
-	  if (usb_inep_maxpacket_size == 0x400) {
-		  context_block_size_1 = CONTEXT_BLOCK_SIZE_1 - 0x200;
-		  context_block_size_2 = CONTEXT_BLOCK_SIZE_2 + 0x200;
-	  }
-	  else {
-		  context_block_size_1 = CONTEXT_BLOCK_SIZE_1;
-		  context_block_size_2 = CONTEXT_BLOCK_SIZE_2;
-	  }
-  }
 
   // This is the largest block we'll need to read in.
   bytes = malloc(CONTEXT_BLOCK_SIZE);
@@ -860,21 +852,16 @@
         expect_terminator_byte = 1;
       }
     }
-    else if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) {
-	    //"iRiver" device special handling
-	    if (curread == 0)
-		    // we are first packet, but not last packet
-		    toread = context_block_size_1;
-	    else if (toread == context_block_size_1)
-		    toread = context_block_size_2;
-	    else if (toread == context_block_size_2)
-		    toread = context_block_size_1;
-	    else
-		    LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n",
-				(unsigned int) toread, (unsigned int) (size-curread));
-
-    } else
-	    toread = CONTEXT_BLOCK_SIZE;
+    else if (curread == 0)
+      // we are first packet, but not last packet
+      toread = CONTEXT_BLOCK_SIZE_1;
+    else if (toread == CONTEXT_BLOCK_SIZE_1)
+      toread = CONTEXT_BLOCK_SIZE_2;
+    else if (toread == CONTEXT_BLOCK_SIZE_2)
+      toread = CONTEXT_BLOCK_SIZE_1;
+    else
+      LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n", 
+	     (unsigned int) toread, (unsigned int) (size-curread));
 
     LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread);
 
@@ -904,7 +891,7 @@
       result--;
     }
 
-    int putfunc_ret = handler->putfunc(NULL, handler->priv, result, bytes);
+    int putfunc_ret = handler->putfunc(NULL, handler->priv, result, bytes, &written);
     if (putfunc_ret != PTP_RC_OK)
       return putfunc_ret;
 
@@ -1077,7 +1064,8 @@
 
 static uint16_t
 memory_putfunc(PTPParams* params, void* private,
-	       unsigned long sendlen, unsigned char *data
+	       unsigned long sendlen, unsigned char *data,
+	       unsigned long *putlen
 ) {
 	PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)private;
 
@@ -1087,6 +1075,7 @@
 	}
 	memcpy (priv->data + priv->curoff, data, sendlen);
 	priv->curoff += sendlen;
+	*putlen = sendlen;
 	return PTP_RC_OK;
 }
 
@@ -1148,7 +1137,7 @@
 /* send / receive functions */
 
 uint16_t
-ptp_usb_sendreq (PTPParams* params, PTPContainer* req, int dataphase)
+ptp_usb_sendreq (PTPParams* params, PTPContainer* req)
 {
 	uint16_t ret;
 	PTPUSBBulkContainer usbreq;
@@ -1158,7 +1147,7 @@
 
 	char txt[256];
 
-	(void) ptp_render_ofc (params, req->Code, sizeof(txt), txt);
+	(void) ptp_render_opcode (params, req->Code, sizeof(txt), txt);
 	LIBMTP_USB_DEBUG("REQUEST: 0x%04x, %s\n", req->Code, txt);
 
 	/* build appropriate USB container */
@@ -1197,13 +1186,13 @@
 
 uint16_t
 ptp_usb_senddata (PTPParams* params, PTPContainer* ptp,
-		  uint64_t size, PTPDataHandler *handler
+		  unsigned long size, PTPDataHandler *handler
 ) {
 	uint16_t ret;
 	int wlen, datawlen;
 	unsigned long written;
 	PTPUSBBulkContainer usbdata;
-	uint64_t bytes_left_to_transfer;
+	uint32_t bytes_left_to_transfer;
 	PTPDataHandler memhandler;
 
 
@@ -1265,10 +1254,6 @@
 	PTPDataHandler	memhandler;
 	uint16_t	ret;
 	unsigned char	*x = NULL;
-	unsigned long packet_size;
-	PTP_USB *ptp_usb = (PTP_USB *) params->data;
-
-	packet_size = ptp_usb->inep_maxpacket;
 
 	/* read the header and potentially the first data */
 	if (params->response_packet_size > 0) {
@@ -1282,7 +1267,7 @@
 		return PTP_RC_OK;
 	}
 	ptp_init_recv_memory_handler (&memhandler);
-	ret = ptp_read_func(packet_size, &memhandler, params->data, rlen, 0);
+	ret = ptp_read_func(PTP_USB_BULK_HS_MAX_PACKET_LEN_READ, &memhandler, params->data, rlen, 0);
 	ptp_exit_recv_memory_handler (&memhandler, &x, rlen);
 	if (x) {
 		memcpy (packet, x, *rlen);
@@ -1296,6 +1281,7 @@
 {
 	uint16_t ret;
 	PTPUSBBulkContainer usbdata;
+	unsigned long	written;
 	PTP_USB *ptp_usb = (PTP_USB *) params->data;
 	int putfunc_ret;
 
@@ -1337,11 +1323,12 @@
 				break;
 			}
 		}
-		if (rlen == ptp_usb->inep_maxpacket) {
+		if (usbdata.length == 0xffffffffU) {
 		  /* Copy first part of data to 'data' */
 		  putfunc_ret =
 		    handler->putfunc(
-				     params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data
+				     params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data,
+				     &written
 				     );
 		  if (putfunc_ret != PTP_RC_OK)
 		    return putfunc_ret;
@@ -1352,7 +1339,7 @@
 		    uint16_t xret;
 
 		    xret = ptp_read_func(
-					 0x20000000,
+					 PTP_USB_BULK_HS_MAX_PACKET_LEN_READ,
 					 handler,
 					 params->data,
 					 &readdata,
@@ -1360,7 +1347,7 @@
 					 );
 		    if (xret != PTP_RC_OK)
 		      return xret;
-		    if (readdata < 0x20000000)
+		    if (readdata < PTP_USB_BULK_HS_MAX_PACKET_LEN_READ)
 		      break;
 		  }
 		  return PTP_RC_OK;
@@ -1411,13 +1398,14 @@
 		putfunc_ret =
 		  handler->putfunc(
 				   params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN,
-				   usbdata.payload.data
+				   usbdata.payload.data,
+				   &written
 				   );
 		if (putfunc_ret != PTP_RC_OK)
 		  return putfunc_ret;
 
 		if (FLAG_NO_ZERO_READS(ptp_usb) &&
-		    len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket) {
+		    len+PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ) {
 
 		  LIBMTP_USB_DEBUG("Reading in extra terminating byte\n");
 
@@ -1431,8 +1419,8 @@
 					 ptp_usb->timeout);
 
 		  if (result != 1)
-		    LIBMTP_INFO("Could not read in extra byte for %d bytes long file, return value 0x%04x\n", ptp_usb->inep_maxpacket, result);
-		} else if (len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket && params->split_header_data == 0) {
+		    LIBMTP_INFO("Could not read in extra byte for PTP_USB_BULK_HS_MAX_PACKET_LEN_READ long file, return value 0x%04x\n", result);
+		} else if (len+PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ && params->split_header_data == 0) {
 		  int zeroresult = 0;
 		  char zerobyte = 0;
 
@@ -1618,17 +1606,6 @@
 }
 
 uint16_t
-ptp_usb_event_async (PTPParams* params, PTPEventCbFn cb, void *user_data) {
-	/* Unsupported */
-	return PTP_ERROR_CANCEL;
-}
-
-int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *tv, int *completed) {
-	/* Unsupported */
-	return -12;
-}
-
-uint16_t
 ptp_usb_control_cancel_request (PTPParams *params, uint32_t transactionid) {
 	PTP_USB *ptp_usb = (PTP_USB *)(params->data);
 	int ret;
@@ -1841,14 +1818,11 @@
      * STALL is persistant or not).
      */
     clear_stall(ptp_usb);
-#if 0
-    // causes troubles due to a kernel bug in 3.x kernels before/around 3.8
     // Clear halts on any endpoints
     clear_halt(ptp_usb);
     // Added to clear some stuff on the OUT endpoint
     // TODO: is this good on the Mac too?
     // HINT: some devices may need that you comment these two out too.
-#endif
     usb_resetep(ptp_usb->handle, ptp_usb->outep);
     usb_release_interface(ptp_usb->handle, (int) ptp_usb->interface);
   }
diff --git a/src/libusb1-glue.c b/src/libusb1-glue.c
index 187c485..2ae89c4 100644
--- a/src/libusb1-glue.c
+++ b/src/libusb1-glue.c
@@ -77,18 +77,11 @@
 };
 typedef struct mtpdevice_list_struct mtpdevice_list_t;
 
-struct ptp_event_cb_data {
-  PTPEventCbFn cb;
-  void *user_data;
-  PTPParams *params;
-};
-
 static const LIBMTP_device_entry_t mtp_device_table[] = {
 /* We include an .h file which is shared between us and libgphoto2 */
 #include "music-players.h"
 };
-static const int mtp_device_table_size =
-  sizeof(mtp_device_table) / sizeof(LIBMTP_device_entry_t);
+static const int mtp_device_table_size = sizeof(mtp_device_table) / sizeof(LIBMTP_device_entry_t);
 
 // Local functions
 static LIBMTP_error_number_t init_usb();
@@ -103,14 +96,10 @@
 					int* outep_maxpacket,
 					int* intep);
 static void clear_stall(PTP_USB* ptp_usb);
-static int init_ptp_usb(PTPParams* params,
-		PTP_USB* ptp_usb, libusb_device* dev);
-static short ptp_write_func(unsigned long,
-		PTPDataHandler*, void *data, unsigned long*);
-static short ptp_read_func (unsigned long,
-		PTPDataHandler*, void *data, unsigned long*, int);
-static int usb_get_endpoint_status(PTP_USB* ptp_usb,
-		int ep, uint16_t* status);
+static int init_ptp_usb (PTPParams* params, PTP_USB* ptp_usb, libusb_device* dev);
+static short ptp_write_func (unsigned long,PTPDataHandler*,void *data,unsigned long*);
+static short ptp_read_func (unsigned long,PTPDataHandler*,void *data,unsigned long*,int);
+static int usb_get_endpoint_status(PTP_USB* ptp_usb, int ep, uint16_t* status);
 
 /**
  * Get a list of the supported USB devices.
@@ -130,8 +119,7 @@
  * @return 0 if the list was successfull retrieved, any other
  *        value means failure.
  */
-int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const devices,
-				      int * const numdevs)
+int LIBMTP_Get_Supported_Devices_List(LIBMTP_device_entry_t ** const devices, int * const numdevs)
 {
   *devices = (LIBMTP_device_entry_t *) &mtp_device_table;
   *numdevs = mtp_device_table_size;
@@ -141,38 +129,32 @@
 
 static LIBMTP_error_number_t init_usb()
 {
-  static int libusb1_initialized = 0;
-
   /*
    * Some additional libusb debugging please.
    * We use the same level debug between MTP and USB.
    */
-  if (libusb1_initialized)
-     return LIBMTP_ERROR_NONE;
-
   if (libusb_init(NULL) < 0) {
     LIBMTP_ERROR("Libusb1 init failed\n");
     return LIBMTP_ERROR_USB_LAYER;
   }
 
-  libusb1_initialized = 1;
-
   if ((LIBMTP_debug & LIBMTP_DEBUG_USB) != 0)
     libusb_set_debug(NULL,9);
   return LIBMTP_ERROR_NONE;
 }
 
 /**
- * Small recursive function to append a new usb_device to the linked
- * list of USB MTP devices
- * @param devlist dynamic linked list of pointers to usb devices with
- *        MTP properties, to be extended with new device.
+ * Small recursive function to append a new usb_device to the linked list of
+ * USB MTP devices
+ * @param devlist dynamic linked list of pointers to usb devices with MTP
+ *        properties, to be extended with new device.
  * @param newdevice the new device to add.
  * @param bus_location bus for this device.
  * @return an extended array or NULL on failure.
  */
 static mtpdevice_list_t *append_to_mtpdevice_list(mtpdevice_list_t *devlist,
 						  libusb_device *newdevice,
+
 						  uint32_t bus_location)
 {
   mtpdevice_list_t *new_list_entry;
@@ -310,8 +292,8 @@
 	  }
 
 	  /*
-	   * TODO: Check for Still Image Capture class with PIMA 15740
-	   * protocol, also known as PTP
+	   * Check for Still Image Capture class with PIMA 15740 protocol,
+	   * also known as PTP
 	   */
 	  if (intf->bInterfaceClass == LIBUSB_CLASS_PTP
 	      && intf->bInterfaceSubClass == 0x01
@@ -356,7 +338,6 @@
 		LIBUSB_CLASS_MASS_STORAGE) {
 	      LIBMTP_INFO("avoid probing device using attached kernel interface\n");
               libusb_free_config_descriptor(config);
-	      libusb_close(devh);
 	      return 0;
 	    }
 	  }
@@ -590,11 +571,13 @@
 
   nrofdevs = libusb_get_device_list (NULL, &devs);
   for (i = 0; i < nrofdevs ; i++ ) {
+
     if (libusb_get_bus_number(devs[i]) != busno)
-	continue;
+      continue;
     if (libusb_get_device_address(devs[i]) != devno)
-	continue;
-    if (probe_device_descriptor(devs[i], NULL))
+      continue;
+
+      if (probe_device_descriptor(devs[i], NULL))
 	return 1;
   }
   return 0;
@@ -688,7 +671,18 @@
       }
     }
     if (!device_known) {
-      device_unknown(i, desc.idVendor, desc.idProduct);
+      // This device is unknown to the developers
+      LIBMTP_ERROR("Device %d (VID=%04x and PID=%04x) is UNKNOWN.\n",
+	      i,
+	      desc.idVendor,
+	      desc.idProduct);
+      LIBMTP_ERROR("Please report this VID/PID and the device model to the "
+	      "libmtp development team\n");
+      /*
+       * Trying to get iManufacturer or iProduct from the device at this
+       * point would require opening a device handle, that we don't want
+       * to do right now. (Takes time for no good enough reason.)
+       */
     }
     // Save the location on the bus
     retdevs[i].bus_location = libusb_get_bus_number (dev->device);
@@ -830,25 +824,10 @@
   int ret = 0;
   int xread;
   unsigned long curread = 0;
+  unsigned long written;
   unsigned char *bytes;
   int expect_terminator_byte = 0;
-  unsigned long usb_inep_maxpacket_size;
-  unsigned long context_block_size_1;
-  unsigned long context_block_size_2;
-  uint16_t ptp_dev_vendor_id = ptp_usb->rawdevice.device_entry.vendor_id;
 
-  //"iRiver" device special handling
-  if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) {
-	  usb_inep_maxpacket_size = ptp_usb->inep_maxpacket;
-	  if (usb_inep_maxpacket_size == 0x400) {
-		  context_block_size_1 = CONTEXT_BLOCK_SIZE_1 - 0x200;
-		  context_block_size_2 = CONTEXT_BLOCK_SIZE_2 + 0x200;
-	  }
-	  else {
-		  context_block_size_1 = CONTEXT_BLOCK_SIZE_1;
-		  context_block_size_2 = CONTEXT_BLOCK_SIZE_2;
-	  }
-  }
   // This is the largest block we'll need to read in.
   bytes = malloc(CONTEXT_BLOCK_SIZE);
   while (curread < size) {
@@ -866,21 +845,16 @@
         expect_terminator_byte = 1;
       }
     }
-    else if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) {
-	    //"iRiver" device special handling
-	    if (curread == 0)
-		    // we are first packet, but not last packet
-		    toread = context_block_size_1;
-	    else if (toread == context_block_size_1)
-		    toread = context_block_size_2;
-	    else if (toread == context_block_size_2)
-		    toread = context_block_size_1;
-	    else
-		    LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n",
-				(unsigned int) toread, (unsigned int) (size-curread));
-    }
+    else if (curread == 0)
+      // we are first packet, but not last packet
+      toread = CONTEXT_BLOCK_SIZE_1;
+    else if (toread == CONTEXT_BLOCK_SIZE_1)
+      toread = CONTEXT_BLOCK_SIZE_2;
+    else if (toread == CONTEXT_BLOCK_SIZE_2)
+      toread = CONTEXT_BLOCK_SIZE_1;
     else
-	    toread = CONTEXT_BLOCK_SIZE;
+      LIBMTP_INFO("unexpected toread size 0x%04x, 0x%04x remaining bytes\n", 
+	     (unsigned int) toread, (unsigned int) (size-curread));
 
     LIBMTP_USB_DEBUG("Reading in 0x%04lx bytes\n", toread);
 
@@ -910,7 +884,7 @@
       xread--;
     }
 
-    int putfunc_ret = handler->putfunc(NULL, handler->priv, xread, bytes);
+    int putfunc_ret = handler->putfunc(NULL, handler->priv, xread, bytes, &written);
     if (putfunc_ret != PTP_RC_OK)
       return putfunc_ret;
 
@@ -984,7 +958,7 @@
   }
   while (curwrite < size) {
     unsigned long usbwritten = 0;
-    int xwritten = 0;
+    int xwritten;
 
     towrite = size-curwrite;
     if (towrite > CONTEXT_BLOCK_SIZE) {
@@ -1093,7 +1067,8 @@
 
 static uint16_t
 memory_putfunc(PTPParams* params, void* private,
-	       unsigned long sendlen, unsigned char *data
+	       unsigned long sendlen, unsigned char *data,
+	       unsigned long *putlen
 ) {
 	PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)private;
 
@@ -1103,6 +1078,7 @@
 	}
 	memcpy (priv->data + priv->curoff, data, sendlen);
 	priv->curoff += sendlen;
+	*putlen = sendlen;
 	return PTP_RC_OK;
 }
 
@@ -1164,7 +1140,7 @@
 /* send / receive functions */
 
 uint16_t
-ptp_usb_sendreq (PTPParams* params, PTPContainer* req, int dataphase)
+ptp_usb_sendreq (PTPParams* params, PTPContainer* req)
 {
 	uint16_t ret;
 	PTPUSBBulkContainer usbreq;
@@ -1174,7 +1150,7 @@
 
 	char txt[256];
 
-	(void) ptp_render_ofc (params, req->Code, sizeof(txt), txt);
+	(void) ptp_render_opcode (params, req->Code, sizeof(txt), txt);
 	LIBMTP_USB_DEBUG("REQUEST: 0x%04x, %s\n", req->Code, txt);
 
 	/* build appropriate USB container */
@@ -1213,13 +1189,13 @@
 
 uint16_t
 ptp_usb_senddata (PTPParams* params, PTPContainer* ptp,
-		  uint64_t size, PTPDataHandler *handler
+		  unsigned long size, PTPDataHandler *handler
 ) {
 	uint16_t ret;
 	int wlen, datawlen;
 	unsigned long written;
 	PTPUSBBulkContainer usbdata;
-	uint64_t bytes_left_to_transfer;
+	uint32_t bytes_left_to_transfer;
 	PTPDataHandler memhandler;
 
 
@@ -1281,10 +1257,6 @@
 	PTPDataHandler	memhandler;
 	uint16_t	ret;
 	unsigned char	*x = NULL;
-	unsigned long packet_size;
-	PTP_USB *ptp_usb = (PTP_USB *) params->data;
-
-	packet_size = ptp_usb->inep_maxpacket;
 
 	/* read the header and potentially the first data */
 	if (params->response_packet_size > 0) {
@@ -1298,7 +1270,7 @@
 		return PTP_RC_OK;
 	}
 	ptp_init_recv_memory_handler (&memhandler);
-	ret = ptp_read_func(packet_size, &memhandler, params->data, rlen, 0);
+	ret = ptp_read_func(PTP_USB_BULK_HS_MAX_PACKET_LEN_READ, &memhandler, params->data, rlen, 0);
 	ptp_exit_recv_memory_handler (&memhandler, &x, rlen);
 	if (x) {
 		memcpy (packet, x, *rlen);
@@ -1312,6 +1284,7 @@
 {
 	uint16_t ret;
 	PTPUSBBulkContainer usbdata;
+	unsigned long	written;
 	PTP_USB *ptp_usb = (PTP_USB *) params->data;
 	int putfunc_ret;
 
@@ -1353,11 +1326,12 @@
 				break;
 			}
 		}
-		if (rlen == ptp_usb->inep_maxpacket) {
+		if (usbdata.length == 0xffffffffU) {
 		  /* Copy first part of data to 'data' */
 		  putfunc_ret =
 		    handler->putfunc(
-				     params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data
+				     params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN, usbdata.payload.data,
+				     &written
 				     );
 		  if (putfunc_ret != PTP_RC_OK)
 		    return putfunc_ret;
@@ -1368,7 +1342,7 @@
 		    uint16_t xret;
 
 		    xret = ptp_read_func(
-					 0x20000000,
+					 PTP_USB_BULK_HS_MAX_PACKET_LEN_READ,
 					 handler,
 					 params->data,
 					 &readdata,
@@ -1376,7 +1350,7 @@
 					 );
 		    if (xret != PTP_RC_OK)
 		      return xret;
-		    if (readdata < 0x20000000)
+		    if (readdata < PTP_USB_BULK_HS_MAX_PACKET_LEN_READ)
 		      break;
 		  }
 		  return PTP_RC_OK;
@@ -1427,13 +1401,14 @@
 		putfunc_ret =
 		  handler->putfunc(
 				   params, handler->priv, rlen - PTP_USB_BULK_HDR_LEN,
-				   usbdata.payload.data
+				   usbdata.payload.data,
+				   &written
 				   );
 		if (putfunc_ret != PTP_RC_OK)
 		  return putfunc_ret;
 
 		if (FLAG_NO_ZERO_READS(ptp_usb) &&
-		    len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket) {
+		    len+PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ) {
 
 		  LIBMTP_USB_DEBUG("Reading in extra terminating byte\n");
 
@@ -1448,8 +1423,8 @@
 					 ptp_usb->timeout);
 
 		  if (result != 1)
-		    LIBMTP_INFO("Could not read in extra byte for %d byte long file, return value 0x%04x\n", ptp_usb->inep_maxpacket, result);
-		} else if (len+PTP_USB_BULK_HDR_LEN == ptp_usb->inep_maxpacket && params->split_header_data == 0) {
+		    LIBMTP_INFO("Could not read in extra byte for PTP_USB_BULK_HS_MAX_PACKET_LEN_READ long file, return value 0x%04x\n", result);
+		} else if (len+PTP_USB_BULK_HDR_LEN == PTP_USB_BULK_HS_MAX_PACKET_LEN_READ && params->split_header_data == 0) {
 		  int zeroresult = 0, xread;
 		  unsigned char zerobyte = 0;
 
@@ -1560,14 +1535,12 @@
 	int result, xread;
 	unsigned long rlen;
 	PTPUSBEventContainer usbevent;
-	PTP_USB *ptp_usb;
+	PTP_USB *ptp_usb = (PTP_USB *)(params->data);
 
 	memset(&usbevent,0,sizeof(usbevent));
 
 	if ((params==NULL) || (event==NULL))
 		return PTP_ERROR_BADPARAM;
-	ptp_usb = (PTP_USB *)(params->data);
-
 	ret = PTP_RC_OK;
 	switch(wait) {
 	case PTP_EVENT_CHECK:
@@ -1640,109 +1613,6 @@
 	return ptp_usb_event (params, event, PTP_EVENT_CHECK);
 }
 
-static void
-ptp_usb_event_cb (struct libusb_transfer *t) {
-	struct ptp_event_cb_data *data = t->user_data;
-	PTPParams *params = data->params;
-	PTPUSBEventContainer *usbevent = (void *)t->buffer;
-	PTPContainer event = {0,};
-	uint16_t code;
-
-	switch (t->status) {
-	case LIBUSB_TRANSFER_COMPLETED:
-		if (t->actual_length < 8) {
-			libusb_glue_error (params,
-				"PTP: reading event an short read of %ld bytes occurred\n",
-				t->actual_length);
-			code = PTP_ERROR_IO;
-		} else {
-			event.Code=dtoh16(usbevent->code);
-			event.SessionID=params->session_id;
-			event.Transaction_ID=dtoh32(usbevent->trans_id);
-			event.Param1=dtoh32(usbevent->param1);
-			event.Param2=dtoh32(usbevent->param2);
-			event.Param3=dtoh32(usbevent->param3);
-			code = PTP_RC_OK;
-		}
-		break;
-	case LIBUSB_TRANSFER_TIMED_OUT:
-		code = PTP_ERROR_TIMEOUT;
-		break;
-	case LIBUSB_TRANSFER_CANCELLED:
-		code = PTP_ERROR_CANCEL;
-		break;
-	case LIBUSB_TRANSFER_STALL:
-		code = PTP_ERROR_DATA_EXPECTED;
-		break;
-	case LIBUSB_TRANSFER_ERROR:
-	case LIBUSB_TRANSFER_NO_DEVICE:
-	case LIBUSB_TRANSFER_OVERFLOW:
-	default:
-		code = PTP_ERROR_IO;
-		break;
-	}
-	if (code != PTP_RC_OK) {
-		libusb_glue_error (params,
-			"PTP: reading event an error 0x%02x occurred\n",
-			t->status);
-	}
-	data->cb(params, code, &event, data->user_data);
-	free(data);
-}
-
-uint16_t
-ptp_usb_event_async (PTPParams* params, PTPEventCbFn cb, void *user_data) {
-	PTP_USB *ptp_usb;
-	PTPUSBEventContainer *usbevent;
-	struct ptp_event_cb_data *data;
-	struct libusb_transfer *t;
-	int ret;
-
-	if (params == NULL) {
-		return PTP_ERROR_BADPARAM;
-	}
-
-        usbevent = calloc(1, sizeof(*usbevent));
-        if (usbevent == NULL) {
-		return PTP_ERROR_IO;
-        }
-
-	data = malloc(sizeof(*data));
-	if (data == NULL) {
-		free(usbevent);
-		return PTP_ERROR_IO;
-	}
-
-	t = libusb_alloc_transfer(0);
-	if (t == NULL) {
-		free(data);
-		free(usbevent);
-		return PTP_ERROR_IO;
-	}
-
-	data->cb = cb;
-	data->user_data = user_data;
-	data->params = params;
-
-	ptp_usb = (PTP_USB *)(params->data);
-	libusb_fill_interrupt_transfer(t, ptp_usb->handle, ptp_usb->intep,
-	                               (unsigned char *)usbevent, sizeof(*usbevent),
-	                               ptp_usb_event_cb, data, 0);
-	t->flags = LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER;
-
-	ret = libusb_submit_transfer(t);
-	return ret == 0 ? PTP_RC_OK : PTP_ERROR_IO;
-}
-
-/**
- * Trivial wrapper around the most generic libusb method for polling for events.
- * Can be used to drive asynchronous event detection.
- */
-int LIBMTP_Handle_Events_Timeout_Completed(struct timeval *tv, int *completed) {
-	/* Pass NULL for context as libmtp always uses the default context */
-	return libusb_handle_events_timeout_completed(NULL, tv, completed);
-}
-
 uint16_t
 ptp_usb_control_cancel_request (PTPParams *params, uint32_t transactionid) {
 	PTP_USB *ptp_usb = (PTP_USB *)(params->data);
@@ -1808,22 +1678,11 @@
    * Check if the config is set to something else than what we want
    * to use. Only set the configuration if we absolutely have to.
    * Also do not bail out if we fail.
-   *
-   * Note that Darwin will not set the configuration for vendor-specific
-   * devices so we need to go in and set it.
    */
   ret = libusb_get_active_config_descriptor(dev, &config);
   if (ret != LIBUSB_SUCCESS) {
     perror("libusb_get_active_config_descriptor(1) failed");
-    fprintf(stderr, "no active configuration, trying to set configuration\n");
-    if (libusb_set_configuration(device_handle, ptp_usb->config) != LIBUSB_SUCCESS) {
-      perror("libusb_set_configuration() failed, continuing anyway...");
-    }
-    ret = libusb_get_active_config_descriptor(dev, &config);
-    if (ret != LIBUSB_SUCCESS) {
-      perror("libusb_get_active_config_descriptor(2) failed");
-      return -1;
-    }
+    return -1;
   }
   if (config->bConfigurationValue != ptp_usb->config) {
     fprintf(stderr, "desired configuration different from current, trying to set configuration\n");
@@ -1939,7 +1798,7 @@
     perror("outep: usb_get_endpoint_status()");
   } else if (status) {
     LIBMTP_INFO("Clearing stall on OUT endpoint\n");
-    ret = libusb_clear_halt(ptp_usb->handle, ptp_usb->outep);
+    ret = libusb_clear_halt (ptp_usb->handle, ptp_usb->outep);
     if (ret != LIBUSB_SUCCESS) {
       perror("usb_clear_stall_feature()");
     }
@@ -1948,6 +1807,24 @@
   /* TODO: do we need this for INTERRUPT (ptp_usb->intep) too? */
 }
 
+static void clear_halt(PTP_USB* ptp_usb)
+{
+  int ret;
+
+  ret = libusb_clear_halt(ptp_usb->handle,ptp_usb->inep);
+  if (ret<0) {
+    perror("usb_clear_halt() on IN endpoint");
+  }
+  ret = libusb_clear_halt(ptp_usb->handle,ptp_usb->outep);
+  if (ret<0) {
+    perror("usb_clear_halt() on OUT endpoint");
+  }
+  ret = libusb_clear_halt(ptp_usb->handle,ptp_usb->intep);
+  if (ret<0) {
+    perror("usb_clear_halt() on INTERRUPT endpoint");
+  }
+}
+
 static void close_usb(PTP_USB* ptp_usb)
 {
   if (!FLAG_NO_RELEASE_INTERFACE(ptp_usb)) {
@@ -1962,6 +1839,12 @@
      * STALL is persistant or not).
      */
     clear_stall(ptp_usb);
+    // Clear halts on any endpoints
+    clear_halt(ptp_usb);
+    // Added to clear some stuff on the OUT endpoint
+    // TODO: is this good on the Mac too?
+    // HINT: some devices may need that you comment these two out too.
+    libusb_clear_halt(ptp_usb->handle, ptp_usb->outep);
     libusb_release_interface(ptp_usb->handle, (int) ptp_usb->interface);
   }
   if (FLAG_FORCE_RESET_ON_CLOSE(ptp_usb)) {
@@ -2003,11 +1886,12 @@
     struct libusb_config_descriptor *config;
 
     ret = libusb_get_config_descriptor(dev, i, &config);
-    if (ret != LIBUSB_SUCCESS)
+    if (ret != 0)
       continue;
 
     *conf = config->bConfigurationValue;
 
+    if (ret != LIBUSB_SUCCESS) continue;
     // Loop over each configurations interfaces
     for (j = 0; j < config->bNumInterfaces; j++) {
       uint8_t k, l;
@@ -2147,7 +2031,6 @@
 
   if (err) {
     libusb_free_device_list (devs, 0);
-    free (ptp_usb);
     LIBMTP_ERROR("LIBMTP PANIC: Unable to find interface & endpoints of device\n");
     return LIBMTP_ERROR_CONNECTING;
   }
@@ -2157,7 +2040,6 @@
 
   /* Attempt to initialize this device */
   if (init_ptp_usb(params, ptp_usb, ldevice) < 0) {
-    free (ptp_usb);
     LIBMTP_ERROR("LIBMTP PANIC: Unable to initialize device\n");
     libusb_free_device_list (devs, 0);
     return LIBMTP_ERROR_CONNECTING;
@@ -2176,7 +2058,6 @@
     if(init_ptp_usb(params, ptp_usb, ldevice) <0) {
       LIBMTP_ERROR("LIBMTP PANIC: Could not init USB on second attempt\n");
       libusb_free_device_list (devs, 0);
-      free (ptp_usb);
       return LIBMTP_ERROR_CONNECTING;
     }
 
@@ -2184,7 +2065,6 @@
     if ((ret = ptp_opensession(params, 1)) == PTP_ERROR_IO) {
       LIBMTP_ERROR("LIBMTP PANIC: failed to open session on second attempt\n");
       libusb_free_device_list (devs, 0);
-      free (ptp_usb);
       return LIBMTP_ERROR_CONNECTING;
     }
   }
@@ -2202,7 +2082,6 @@
 	    ret);
     libusb_release_interface(ptp_usb->handle, ptp_usb->interface);
     libusb_free_device_list (devs, 0);
-    free (ptp_usb);
     return LIBMTP_ERROR_CONNECTING;
   }
 
diff --git a/src/mtpz.c b/src/mtpz.c
index a07fd9e..0cb9d8f 100644
--- a/src/mtpz.c
+++ b/src/mtpz.c
@@ -19,8 +19,6 @@
  * Boston, MA 02111-1307, USA.
  *
  * This file provides mtp zune cryptographic setup interfaces.
- * It is also used with Windows Phone 7, but Microsoft/Nokiad seem
- * to have discontinued MTPZ on Windows Phone 8.
  *
  * DISCLAIMER:
  *
@@ -117,10 +115,9 @@
 int mtpz_loaddata()
 {
 	char *home = getenv("HOME");
-	int ret = -1;
 	if (!home)
 	{
-		LIBMTP_ERROR("Unable to determine user's home directory, MTPZ disabled.\n");
+		LIBMTP_INFO("Error: Unable to determine user's home directory.\n");
 		return -1;
 	}
 
@@ -130,66 +127,63 @@
 
 	FILE *fdata = fopen(path, "r");
 	if (!fdata)
-		return ret;
+	{
+		LIBMTP_INFO("Error: Unable to open ~/.mtpz-data for reading.\n");
+		return -1;
+	}
 
 	// Should only be six characters in length, but fgets will encounter a newline and stop.
 	MTPZ_PUBLIC_EXPONENT = (unsigned char *)fgets_strip((char *)malloc(8), 8, fdata);
 	if (!MTPZ_PUBLIC_EXPONENT)
 	{
-		LIBMTP_ERROR("Unable to read MTPZ public exponent from ~/.mtpz-data, MTPZ disabled.\n");
-		goto cleanup;
+		LIBMTP_INFO("Error: Unable to read MTPZ public exponent from ~/.mtpz-data\n");
+		return -1;
 	}
 
 	// Should only be 33 characters in length, but fgets will encounter a newline and stop.
-	char *hexenckey = fgets_strip((char *)malloc(35), 35, fdata);
+	char *hexenckey = (unsigned char *)fgets_strip((char *)malloc(35), 35, fdata);
 	if (!hexenckey)
 	{
-		LIBMTP_ERROR("Unable to read MTPZ encryption key from ~/.mtpz-data, MTPZ disabled.\n");
-		goto cleanup;
+		LIBMTP_INFO("Error: Unable to read MTPZ encryption key from ~/.mtpz-data\n");
+		return -1;
 	}
-
 	MTPZ_ENCRYPTION_KEY = hex_to_bytes(hexenckey, strlen(hexenckey));
 	if (!MTPZ_ENCRYPTION_KEY)
 	{
-		LIBMTP_ERROR("Unable to read MTPZ encryption key from ~/.mtpz-data, MTPZ disabled.\n");
-		goto cleanup;
+		LIBMTP_INFO("Error: Unable to read MTPZ encryption key from ~/.mtpz-data\n");
 	}
 
 	// Should only be 256 characters in length, but fgets will encounter a newline and stop.
 	MTPZ_MODULUS = (unsigned char *)fgets_strip((char *)malloc(260), 260, fdata);
 	if (!MTPZ_MODULUS)
 	{
-		LIBMTP_ERROR("Unable to read MTPZ modulus from ~/.mtpz-data, MTPZ disabled.\n");
-		goto cleanup;
+		LIBMTP_INFO("Error: Unable to read MTPZ modulus from ~/.mtpz-data\n");
+		return -1;
 	}
 
 	// Should only be 256 characters in length, but fgets will encounter a newline and stop.
 	MTPZ_PRIVATE_KEY = (unsigned char *)fgets_strip((char *)malloc(260), 260, fdata);
 	if (!MTPZ_PRIVATE_KEY)
 	{
-		LIBMTP_ERROR("Unable to read MTPZ private key from ~/.mtpz-data, MTPZ disabled.\n");
-		goto cleanup;
+		LIBMTP_INFO("Error: Unable to read MTPZ private key from ~/.mtpz-data\n");
+		return -1;
 	}
 
 	// Should only be 1258 characters in length, but fgets will encounter the end of the file and stop.
 	char *hexcerts = fgets_strip((char *)malloc(1260), 1260, fdata);
 	if (!hexcerts)
 	{
-		LIBMTP_ERROR("Unable to read MTPZ certificates from ~/.mtpz-data, MTPZ disabled.\n");
-		goto cleanup;
+		LIBMTP_INFO("Error: Unable to read MTPZ certificates from ~/.mtpz-data\n");
+		return -1;
 	}
-
 	MTPZ_CERTIFICATES = hex_to_bytes(hexcerts, strlen(hexcerts));
 	if (!MTPZ_CERTIFICATES)
 	{
-		LIBMTP_ERROR("Unable to parse MTPZ certificates from ~/.mtpz-data, MTPZ disabled.\n");
-		goto cleanup;
+		LIBMTP_INFO("Error: Unable to parse MTPZ certificates from ~/.mtpz-data\n");
+		return -1;
 	}
-	// If all done without errors, drop the fail
-	ret = 0;
-cleanup:
-	fclose(fdata);
-	return ret;
+
+	return 0;
 }
 /* MTPZ RSA */
 
@@ -242,7 +236,7 @@
 #define MTPZ_ENCRYPTIONBYTE2(val) (((val) >>  8) & 0xFF)
 #define MTPZ_ENCRYPTIONBYTE3(val) (((val) >>  0) & 0xFF)
 
-#define MTPZ_SWAP(x) mtpz_bswap32(x)
+#define MTPZ_SWAP(x) __builtin_bswap32(x)
 
 void mtpz_encryption_cipher(unsigned char *data, unsigned int len, char encrypt);
 void mtpz_encryption_cipher_advanced(unsigned char *key, unsigned int key_len, unsigned char *data, unsigned int data_len, char encrypt);
@@ -254,25 +248,13 @@
 void mtpz_encryption_encrypt_mac(unsigned char *hash, unsigned int hash_length, unsigned char *seed, unsigned int seed_len, unsigned char *out);
 
 
-static inline uint32_t mtpz_bswap32(uint32_t x)
-{
-#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) || defined(__clang__)
-	return __builtin_bswap32(x);
-#else
-	return (x >> 24) |
-	       ((x >> 8) & 0x0000ff00) |
-	       ((x << 8) & 0x00ff0000) |
-	       (x << 24);
-#endif
-}
 
 
 /* MTPZ RSA implementation */
 mtpz_rsa_t *mtpz_rsa_init(const unsigned char *str_modulus, const unsigned char *str_privkey, const unsigned char *str_pubexp)
 {
-	mtpz_rsa_t *rsa = calloc(1, sizeof(mtpz_rsa_t));
-	if (rsa == NULL)
-		return NULL;
+	mtpz_rsa_t *rsa = (mtpz_rsa_t *)malloc(sizeof(mtpz_rsa_t));
+	memset(rsa, 0, sizeof(rsa));
 
 	gcry_mpi_t mpi_modulus, mpi_privkey, mpi_pubexp;
 
@@ -1511,134 +1493,135 @@
 	unsigned char* response = NULL;
 
 	ret = ptp_mtpz_getwmdrmpdappresponse (params, &response, &len);
-	if (ret != PTP_RC_OK)
+	if (ret == PTP_RC_OK)
+	{
+		char *reader = (char *)response;
+		int i;
+
+		if (*(reader++) != '\x02')
+		{
+			return -1;
+		}
+
+		if (*(reader++) != '\x02')
+		{
+			return -1;
+		}
+
+		// Message is always 128 bytes.
+		reader++;
+		if (*(reader++) != '\x80')
+		{
+			return -1;
+		}
+
+		char *message = (char *)malloc(128);
+		memcpy(message, reader, 128);
+		reader += 128;
+
+		// Decrypt the hash-key-message..
+		char *msg_dec = (char *)malloc(128);
+		memset(msg_dec, 0, 128);
+
+		mtpz_rsa_t *rsa = mtpz_rsa_init(MTPZ_MODULUS, MTPZ_PRIVATE_KEY, MTPZ_PUBLIC_EXPONENT);
+		if (!rsa)
+		{
+			LIBMTP_INFO ("(MTPZ) Failure - could not instantiate RSA object.\n");
+			free(message);
+			free(msg_dec);
+			return -1;
+		}
+
+		if (mtpz_rsa_decrypt(128, (unsigned char *)message, 128, (unsigned char *)msg_dec, rsa) == 0)
+		{
+			LIBMTP_INFO ("(MTPZ) Failure - could not perform RSA decryption.\n");
+
+			free(message);
+			free(msg_dec);
+			mtpz_rsa_free(rsa);
+			return -1;
+		}
+
+		mtpz_rsa_free(rsa);
+		rsa = NULL;
+
+		char *state = mtpz_hash_init_state();
+		char *hash_key = (char *)malloc(16);
+		char *v10 = mtpz_hash_custom6A5DC(state, msg_dec + 21, 107, 20);
+
+		for (i = 0; i < 20; i++)
+			msg_dec[i + 1] ^= v10[i];
+
+		char *v11 = mtpz_hash_custom6A5DC(state, msg_dec + 1, 20, 107);
+
+		for (i = 0; i < 107; i++)
+			msg_dec[i + 21] ^= v11[i];
+
+		memcpy(hash_key, msg_dec + 112, 16);
+
+		// Encrypted message is 0x340 bytes.
+		reader += 2;
+		if (*(reader++) != '\x03' || *(reader++) != '\x40')
+		{
+			return -1;
+		}
+
+		unsigned char *act_msg = (unsigned char *)malloc(832);
+		unsigned char *act_reader = act_msg;
+		memcpy(act_msg, reader, 832);
+		reader = NULL;
+
+		mtpz_encryption_cipher_advanced((unsigned char *)hash_key, 16, act_msg, 832, 0);
+
+		act_reader++;
+		unsigned int certs_length = __builtin_bswap32(*(unsigned int *)(act_reader));
+		act_reader += 4;
+		act_reader += certs_length;
+
+		unsigned int rand_length = __builtin_bswap32(*(unsigned short *)(act_reader) << 16);
+		act_reader += 2;
+		unsigned char *rand_data = (unsigned char *)malloc(rand_length);
+		memcpy(rand_data, act_reader, rand_length);
+		if (memcmp(rand_data, random, 16) != 0)
+		{
+			free(rand_data);
+			return -1;
+		}
+		free(rand_data);
+		act_reader += rand_length;
+
+		unsigned int dev_rand_length = __builtin_bswap32(*(unsigned short *)(act_reader) << 16);
+		act_reader += 2;
+		act_reader += dev_rand_length;
+
+		act_reader++;
+
+		unsigned int sig_length = __builtin_bswap32(*(unsigned short *)(act_reader) << 16);
+		act_reader += 2;
+		act_reader += sig_length;
+
+		act_reader++;
+
+		unsigned int machash_length = __builtin_bswap32(*(unsigned short *)(act_reader) << 16);
+		act_reader += 2;
+		unsigned char *machash_data = (unsigned char *)malloc(machash_length);
+		memcpy(machash_data, act_reader, machash_length);
+		act_reader += machash_length;
+
+		*calculatedHash = machash_data;
+
+		free(message);
+		free(msg_dec);
+		free(state);
+		free(v10);
+		free(v11);
+		free(act_msg);
+	}
+	else
 	{
 		LIBMTP_INFO ("(MTPZ) Failure - did not receive device's response.\n");
-		return ret;
 	}
 
-	char *reader = (char *)response;
-	int i;
-
-	if (*(reader++) != '\x02')
-	{
-		return -1;
-	}
-
-	if (*(reader++) != '\x02')
-	{
-		return -1;
-	}
-
-	// Message is always 128 bytes.
-	reader++;
-	if (*(reader++) != '\x80')
-	{
-		return -1;
-	}
-
-	char *message = (char *)malloc(128);
-	memcpy(message, reader, 128);
-	reader += 128;
-
-	// Decrypt the hash-key-message..
-	char *msg_dec = (char *)malloc(128);
-	memset(msg_dec, 0, 128);
-
-	mtpz_rsa_t *rsa = mtpz_rsa_init(MTPZ_MODULUS, MTPZ_PRIVATE_KEY, MTPZ_PUBLIC_EXPONENT);
-	if (!rsa)
-	{
-		LIBMTP_INFO ("(MTPZ) Failure - could not instantiate RSA object.\n");
-		free(message);
-		free(msg_dec);
-		return -1;
-	}
-
-	if (mtpz_rsa_decrypt(128, (unsigned char *)message, 128, (unsigned char *)msg_dec, rsa) == 0)
-	{
-		LIBMTP_INFO ("(MTPZ) Failure - could not perform RSA decryption.\n");
-
-		free(message);
-		free(msg_dec);
-		mtpz_rsa_free(rsa);
-		return -1;
-	}
-
-	mtpz_rsa_free(rsa);
-	rsa = NULL;
-
-	char *state = mtpz_hash_init_state();
-	char *hash_key = (char *)malloc(16);
-	char *v10 = mtpz_hash_custom6A5DC(state, msg_dec + 21, 107, 20);
-
-	for (i = 0; i < 20; i++)
-		msg_dec[i + 1] ^= v10[i];
-
-	char *v11 = mtpz_hash_custom6A5DC(state, msg_dec + 1, 20, 107);
-
-	for (i = 0; i < 107; i++)
-		msg_dec[i + 21] ^= v11[i];
-
-	memcpy(hash_key, msg_dec + 112, 16);
-
-	// Encrypted message is 0x340 bytes.
-	reader += 2;
-	if (*(reader++) != '\x03' || *(reader++) != '\x40')
-	{
-		return -1;
-	}
-
-	unsigned char *act_msg = (unsigned char *)malloc(832);
-	unsigned char *act_reader = act_msg;
-	memcpy(act_msg, reader, 832);
-	reader = NULL;
-
-	mtpz_encryption_cipher_advanced((unsigned char *)hash_key, 16, act_msg, 832, 0);
-
-	act_reader++;
-	unsigned int certs_length = MTPZ_SWAP(*(unsigned int *)(act_reader));
-	act_reader += 4;
-	act_reader += certs_length;
-
-	unsigned int rand_length = MTPZ_SWAP(*(unsigned short *)(act_reader) << 16);
-	act_reader += 2;
-	unsigned char *rand_data = (unsigned char *)malloc(rand_length);
-	memcpy(rand_data, act_reader, rand_length);
-	if (memcmp(rand_data, random, 16) != 0)
-	{
-		free(rand_data);
-		return -1;
-	}
-	free(rand_data);
-	act_reader += rand_length;
-
-	unsigned int dev_rand_length = MTPZ_SWAP(*(unsigned short *)(act_reader) << 16);
-	act_reader += 2;
-	act_reader += dev_rand_length;
-
-	act_reader++;
-
-	unsigned int sig_length = MTPZ_SWAP(*(unsigned short *)(act_reader) << 16);
-	act_reader += 2;
-	act_reader += sig_length;
-
-	act_reader++;
-
-	unsigned int machash_length = MTPZ_SWAP(*(unsigned short *)(act_reader) << 16);
-	act_reader += 2;
-	unsigned char *machash_data = (unsigned char *)malloc(machash_length);
-	memcpy(machash_data, act_reader, machash_length);
-	act_reader += machash_length;
-
-	*calculatedHash = machash_data;
-
-	free(message);
-	free(msg_dec);
-	free(state);
-	free(v10);
-	free(v11);
-	free(act_msg);
-
 	return ret;
 }
 
@@ -1653,8 +1636,8 @@
 	mtpz_encryption_encrypt_mac(hash, 16, (unsigned char *)(&macCount), 4, mch);
 
 	ret = ptp_mtpz_wmdrmpd_enabletrustedfilesoperations(params,
-		MTPZ_SWAP(hashparams[0]), MTPZ_SWAP(hashparams[1]),
-		MTPZ_SWAP(hashparams[2]), MTPZ_SWAP(hashparams[3]));
+		__builtin_bswap32(hashparams[0]), __builtin_bswap32(hashparams[1]),
+		__builtin_bswap32(hashparams[2]), __builtin_bswap32(hashparams[3]));
 	return ret;
 };
 
diff --git a/src/music-players.h b/src/music-players.h
index c753e36..5b3c5a8 100644
--- a/src/music-players.h
+++ b/src/music-players.h
@@ -3,10 +3,9 @@
  * List of music players as USB ids.
  *
  * Copyright (C) 2005-2007 Richard A. Low <richard@wentnet.com>
- * Copyright (C) 2005-2013 Linus Walleij <triad@df.lth.se>
- * Copyright (C) 2006-2007,2015 Marcus Meissner <marcus@jet.franken.de>
+ * Copyright (C) 2005-2012 Linus Walleij <triad@df.lth.se>
+ * Copyright (C) 2006-2007 Marcus Meissner
  * Copyright (C) 2007 Ted Bullock
- * Copyright (C) 2012 Sony Mobile Communications AB
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -47,61 +46,82 @@
    * and properties.
    */
   { "Creative", 0x041e, "ZEN Vision", 0x411f,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "Portable Media Center", 0x4123,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "ZEN Xtra (MTP mode)", 0x4128,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Dell", 0x041e, "DJ (2nd generation)", 0x412f,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "ZEN Micro (MTP mode)", 0x4130,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "ZEN Touch (MTP mode)", 0x4131,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Dell", 0x041e, "Dell Pocket DJ (MTP mode)", 0x4132,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
-  { "Creative", 0x041e, "ZEN MicroPhoto (alternate version)", 0x4133,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
+ { "Creative", 0x041e, "ZEN MicroPhoto (alternate version)", 0x4133,
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "ZEN Sleek (MTP mode)", 0x4137,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "ZEN MicroPhoto", 0x413c,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "ZEN Sleek Photo", 0x413d,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "ZEN Vision:M", 0x413e,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Reported by marazm@o2.pl
   { "Creative", 0x041e, "ZEN V", 0x4150,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Reported by danielw@iinet.net.au
   // This version of the Vision:M needs the no release interface flag,
   // unclear whether the other version above need it too or not.
   { "Creative", 0x041e, "ZEN Vision:M (DVP-HD0004)", 0x4151,
       DEVICE_FLAG_NO_RELEASE_INTERFACE |
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Reported by Darel on the XNJB forums
   { "Creative", 0x041e, "ZEN V Plus", 0x4152,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   { "Creative", 0x041e, "ZEN Vision W", 0x4153,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Don't add 0x4155: this is a Zen Stone device which is not MTP
   // Reported by Paul Kurczaba <paul@kurczaba.com>
   { "Creative", 0x041e, "ZEN", 0x4157,
       DEVICE_FLAG_IGNORE_HEADER_ERRORS |
       DEVICE_FLAG_BROKEN_SET_SAMPLE_DIMENSIONS |
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Reported by Ringofan <mcroman@users.sourceforge.net>
   { "Creative", 0x041e, "ZEN V 2GB", 0x4158,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Reported by j norment <stormzen@gmail.com>
   { "Creative", 0x041e, "ZEN Mozaic", 0x4161,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Reported by Aaron F. Gonzalez <sub_tex@users.sourceforge.net>
   { "Creative", 0x041e, "ZEN X-Fi", 0x4162,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Reported by farmerstimuli <farmerstimuli@users.sourceforge.net>
   { "Creative", 0x041e, "ZEN X-Fi 3", 0x4169,
-      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_GET_OBJECT_PROPVAL },
   // Reported by Todor Gyumyushev <yodor1@users.sourceforge.net>
   { "ZiiLABS", 0x041e, "Zii EGG", 0x6000,
       DEVICE_FLAG_UNLOAD_DRIVER |
@@ -273,13 +293,6 @@
       DEVICE_FLAG_UNIQUE_FILENAMES |
       DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
   // The "YP-R2" (0x04e8/0x512d) is NOT MTP, it is UMS only.
-  // Guessing on device flags for the MTP mode...
- { "Samsung", 0x04e8, "YP-R2", 0x512e,
-     DEVICE_FLAG_UNLOAD_DRIVER |
-     DEVICE_FLAG_OGG_IS_UNKNOWN |
-     DEVICE_FLAG_UNIQUE_FILENAMES |
-     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
-     DEVICE_FLAG_PLAYLIST_SPL_V1 },
   // From Manuel Carro
   // Copied from Q2
  { "Samsung", 0x04e8, "YP-Q3", 0x5130,
@@ -295,7 +308,6 @@
      DEVICE_FLAG_OGG_IS_UNKNOWN |
      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
      DEVICE_FLAG_PLAYLIST_SPL_V1 },
-  // YP-F3 is NOT MTP - USB mass storage
   // From a rouge .INF file
   // this device ID seems to have been recycled for:
   // the Samsung SGH-A707 Cingular cellphone
@@ -347,7 +359,7 @@
    *
    * 0x685b - UMS
    * 0x685c - MTP + ADB
-   * 0x685e - UMS + CDC (not MTP)
+   * 0x685e - UMS + CDC
    * 0x6860 - MTP mode (default)
    * 0x6863 - USB CDC RNDIS (not MTP)
    * 0x6865 - PTP mode (not MTP)
@@ -362,7 +374,6 @@
    * Galaxy S2
    * Galaxy S3
    * Galaxy Note
-   * Gakaxy Xcover
    * Galaxy Y
    *
    * - It seems that some PTP commands are broken.
@@ -381,18 +392,22 @@
       DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
       DEVICE_FLAG_UNLOAD_DRIVER |
       DEVICE_FLAG_LONG_TIMEOUT |
-      DEVICE_FLAG_PROPLIST_OVERRIDES_OI	|
-      DEVICE_FLAG_OGG_IS_UNKNOWN |
-      DEVICE_FLAG_FLAC_IS_UNKNOWN },
+      DEVICE_FLAG_PROPLIST_OVERRIDES_OI	},
+  // Reported by David Goodenough <dfgdga@users.sourceforge.net>
+  // Guessing on flags.
+  { "Samsung", 0x04e8, "Galaxy Y", 0x685e,
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
+      DEVICE_FLAG_UNLOAD_DRIVER |
+      DEVICE_FLAG_LONG_TIMEOUT |
+      DEVICE_FLAG_PROPLIST_OVERRIDES_OI	},
   { "Samsung", 0x04e8,
       "Galaxy models (MTP)", 0x6860,
       DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL |
       DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
       DEVICE_FLAG_UNLOAD_DRIVER |
       DEVICE_FLAG_LONG_TIMEOUT |
-      DEVICE_FLAG_PROPLIST_OVERRIDES_OI |
-      DEVICE_FLAG_OGG_IS_UNKNOWN |
-      DEVICE_FLAG_FLAC_IS_UNKNOWN },
+      DEVICE_FLAG_PROPLIST_OVERRIDES_OI	},
   // From: Erik Berglund <erikjber@users.sourceforge.net>
   // Logs indicate this needs DEVICE_FLAG_NO_ZERO_READS
   // No Samsung platlists on this device.
@@ -403,9 +418,7 @@
   { "Samsung", 0x04e8, "Galaxy models Kies mode", 0x6877,
       DEVICE_FLAG_UNLOAD_DRIVER |
       DEVICE_FLAG_LONG_TIMEOUT |
-      DEVICE_FLAG_PROPLIST_OVERRIDES_OI	|
-      DEVICE_FLAG_OGG_IS_UNKNOWN |
-      DEVICE_FLAG_FLAC_IS_UNKNOWN },
+      DEVICE_FLAG_PROPLIST_OVERRIDES_OI	},
   // From: John Gorkos <ab0oo@users.sourceforge.net> and
   // Akos Maroy <darkeye@users.sourceforge.net>
   { "Samsung", 0x04e8, "Vibrant SGH-T959/Captivate/Media player mode", 0x68a9,
@@ -425,6 +438,7 @@
    */
   { "Microsoft/Intel", 0x045e, "Bandon Portable Media Center", 0x00c9,
       DEVICE_FLAG_NONE },
+  // Reported by anonymous sourceforge user
   // HTC Mozart is using the PID, as is Nokia Lumia 800
   // May need MTPZ to work
   { "Microsoft", 0x045e, "Windows Phone", 0x04ec, DEVICE_FLAG_NONE },
@@ -435,14 +449,12 @@
   { "Microsoft", 0x045e, "Windows MTP Simulator", 0x0622, DEVICE_FLAG_NONE },
   // Reported by Edward Hutchins (used for Zune HDs)
   { "Microsoft", 0x045e, "Zune HD", 0x063e, DEVICE_FLAG_NONE },
+  // Reported by anonymous sourceforge user
   { "Microsoft", 0x045e, "Kin 1", 0x0640, DEVICE_FLAG_NONE },
+  // Reported by anonymous sourceforge user
   { "Microsoft/Sharp/nVidia", 0x045e, "Kin TwoM", 0x0641, DEVICE_FLAG_NONE },
   // Reported by Farooq Zaman (used for all Zunes)
   { "Microsoft", 0x045e, "Zune", 0x0710, DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/feature-requests/155/ */
-  { "Microsoft", 0x045e, "Lumia 950 XL Dual SIM (RM-1116)", 0x0a00, DEVICE_FLAG_NONE },
-  // Reported by Olegs Jeremejevs
-  { "Microsoft/HTC", 0x045e, "HTC 8S", 0xf0ca, DEVICE_FLAG_NONE },
 
   /*
    * JVC
@@ -451,11 +463,6 @@
   { "JVC", 0x04f1, "Alneo XA-HD500", 0x6105, DEVICE_FLAG_NONE },
 
   /*
-   * Jolla
-   */
-  { "Jolla", 0x2931, "Jolla", 0x0a07, DEVICE_FLAG_NONE },
-
-  /*
    * Philips
    */
   { "Philips", 0x0471, "HDD6320/00 or HDD6330/17", 0x014b, DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
@@ -479,14 +486,10 @@
   { "Philips", 0x0471, "GoGear SA6014/SA6015/SA6024/SA6025/SA6044/SA6045", 0x084e, DEVICE_FLAG_UNLOAD_DRIVER },
   // From anonymous Sourceforge user SA5145/02
   { "Philips", 0x0471, "GoGear SA5145", 0x0857, DEVICE_FLAG_UNLOAD_DRIVER },
-  /* https://sourceforge.net/p/libmtp/bugs/1260/ */
-  { "Philips", 0x0471, "i908", 0x190b, DEVICE_FLAG_UNLOAD_DRIVER },
   // From a
   { "Philips", 0x0471, "GoGear SA6125/SA6145/SA6185", 0x2002, DEVICE_FLAG_UNLOAD_DRIVER },
   // From anonymous Sourceforge user, not verified to be MTP!
   { "Philips", 0x0471, "GoGear SA3345", 0x2004, DEVICE_FLAG_UNLOAD_DRIVER },
-  /* https://sourceforge.net/p/libmtp/support-requests/163/ */
-  { "Philips", 0x0471, "W6610", 0x2008, DEVICE_FLAG_UNLOAD_DRIVER },
   // From Roberto Vidmar <rvidmar@libero.it>
   { "Philips", 0x0471, "SA5285", 0x2022, DEVICE_FLAG_UNLOAD_DRIVER },
   // From Elie De Brauwer <elie@de-brauwer.be>
@@ -513,119 +516,32 @@
   // From Anonymous SourceForge User
   { "Philips", 0x0471, "GoGear Vibe/02", 0x20e5,
       DEVICE_FLAG_UNLOAD_DRIVER },
-  // Reported by Philip Rhoades
-  { "Philips", 0x0471, "GoGear Ariaz/97", 0x2138,
-      DEVICE_FLAG_UNLOAD_DRIVER },
-  /* https://sourceforge.net/p/libmtp/bugs/1186/ */
-  { "Philips", 0x0471, "PI3900B2/58 ", 0x2190,
-      DEVICE_FLAG_UNLOAD_DRIVER },
   // from XNJB user
   { "Philips", 0x0471, "PSA235", 0x7e01, DEVICE_FLAG_NONE },
 
   /*
    * Acer
-   * Reporters:
-   * Franck VDL <franckv@users.sourceforge.net>
-   * Matthias Arndt <simonsunnyboy@users.sourceforge.net>
-   * Arvin Schnell <arvins@users.sourceforge.net>
-   * Philippe Marzouk <philm@users.sourceforge.net>
-   * nE0sIghT <ne0sight@users.sourceforge.net>
-   * Maxime de Roucy <maxime1986@users.sourceforge.net>
    */
-  { "Acer", 0x0502, "Iconia TAB A500 (ID1)", 0x3325,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A500 (ID2)", 0x3341,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A501 (ID1)", 0x3344,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A501 (ID2)", 0x3345,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A100 (ID1)", 0x3348,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A100 (ID2)", 0x3349,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A101 (ID1)", 0x334a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A700", 0x3378,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A200 (ID1)", 0x337c,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A200 (ID2)", 0x337d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A510 (ID1)", 0x3389,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A510 (ID2)", 0x338a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "S500 CloudMobile", 0x33aa,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "E350 Liquid Gallant Duo (ID1)", 0x33c3,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "E350 Liquid Gallant Duo (ID2)", 0x33c4,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A210", 0x33cb,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia TAB A110", 0x33d8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Liquid Z120 MT65xx Android Phone", 0x3473,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1029/ */
-  { "Acer", 0x0502, "Liquid E2", 0x3514,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia A1-810", 0x353c,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Liquid Z130 MT65xx Android Phone", 0x355f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1206/ */
-  { "Acer", 0x0502, "Iconia A3-A11", 0x3586,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1103/ */
-  { "Acer", 0x0502, "Liquid E3", 0x35a8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1147/ */
-  { "Acer", 0x0502, "Z150", 0x35e4,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1184/ */
-  { "Acer", 0x0502, "Liquid X1", 0x3609,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1298/ */
-  { "Acer", 0x0502, "Z160", 0x361d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "Iconia A1-840FHD", 0x362d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1251/ */
-  { "Acer", 0x0502, "E39", 0x3643,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1369/ */
-  { "Acer", 0x0502, "liquid e700", 0x3644,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acer", 0x0502, "One 7", 0x3657,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/183/ */
-  { "Acer", 0x0502, "Z200", 0x3683,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1579/ */
-  { "Acer", 0x0502, "A1-841", 0x365e,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1341/ */
-  { "Acer", 0x0502, "Liquid S56", 0x3725,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/188/ */
-  { "Acer", 0x0502, "Liquid Z220", 0x3750,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1478/ */
-  { "Acer", 0x0502, "Liquid Z330", 0x3750,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1552/ */
-  { "Acer", 0x0502, "Liquid Z630", 0x37ef,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1469/ */
-  { "Acer", 0x0502, "Z530", 0x3822,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1534/ */
-  { "Acer", 0x0502, "Z530 16GB", 0x3823,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* Reported by Jocelyn Mayer <l_indien@magic.fr> */
-  { "Acer", 0x0502, "Iconia One 10", 0x3841,
+  // Reported by anonymous sourceforge user
+  { "Acer", 0x0502, "Iconia TAB A500 (ID1)", 0x3325, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by: Franck VDL <franckv@users.sourceforge.net>
+  { "Acer", 0x0502, "Iconia TAB A500 (ID2)", 0x3341, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by: Matthias Arndt <simonsunnyboy@users.sourceforge.net>
+  { "Acer", 0x0502, "Iconia TAB A501", 0x3344, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by: anonymous sourceforge user
+  { "Acer", 0x0502, "Iconia TAB A100 (ID1)", 0x3348, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by: Arvin Schnell <arvins@users.sourceforge.net>
+  { "Acer", 0x0502, "Iconia TAB A100 (ID2)", 0x3349, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by Philippe Marzouk <philm@users.sourceforge.net>
+  { "Acer", 0x0502, "Iconia TAB A700", 0x3378, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous sourceforge user
+  { "Acer", 0x0502, "Iconia TAB A200 (ID1)", 0x337c, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous sourceforge user
+  { "Acer", 0x0502, "Iconia TAB A200 (ID2)", 0x337d, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by nE0sIghT <ne0sight@users.sourceforge.net>
+  { "Acer", 0x0502, "Iconia TAB A510", 0x338a, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by Maxime de Roucy <maxime1986@users.sourceforge.net>
+  { "Acer", 0x0502, "E350 Liquid Gallant Duo", 0x33c3,
       DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
@@ -748,10 +664,10 @@
   { "iRiver", 0x1006, "H300 Series MTP", 0x3004,
     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_NO_ZERO_READS |
     DEVICE_FLAG_IRIVER_OGG_ALZHEIMER },
-  { "iRiver", 0x1006, "Portable Media Center 1", 0x4002,
+  { "iRiver", 0x1006, "Portable Media Center", 0x4002,
     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_NO_ZERO_READS |
     DEVICE_FLAG_IRIVER_OGG_ALZHEIMER },
-  { "iRiver", 0x1006, "Portable Media Center 2", 0x4003,
+  { "iRiver", 0x1006, "Portable Media Center", 0x4003,
     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_NO_ZERO_READS |
     DEVICE_FLAG_IRIVER_OGG_ALZHEIMER },
   // From [st]anislav <iamstanislav@gmail.com>
@@ -775,10 +691,10 @@
   { "iRiver", 0x4102, "U10", 0x1116,
     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_NO_ZERO_READS |
     DEVICE_FLAG_IRIVER_OGG_ALZHEIMER },
-  { "iRiver", 0x4102, "T10b", 0x1117,
+  { "iRiver", 0x4102, "T10a", 0x1117,
     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_NO_ZERO_READS |
     DEVICE_FLAG_IRIVER_OGG_ALZHEIMER },
-  { "iRiver", 0x4102, "T20b", 0x1118,
+  { "iRiver", 0x4102, "T20", 0x1118,
     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_NO_ZERO_READS |
     DEVICE_FLAG_IRIVER_OGG_ALZHEIMER },
   { "iRiver", 0x4102, "T30", 0x1119,
@@ -826,11 +742,7 @@
   { "iRiver", 0x4102, "E50", 0x1151,
     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_NO_ZERO_READS |
     DEVICE_FLAG_OGG_IS_UNKNOWN },
-  // Reported by anonymous SourceForge user, guessing on flags
-  { "iRiver", 0x4102, "E150", 0x1152,
-    DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST | DEVICE_FLAG_NO_ZERO_READS |
-    DEVICE_FLAG_OGG_IS_UNKNOWN },
-  // Reported by Jakub Matraszek <jakub.matraszek@gmail.com>
+   // Reported by Jakub Matraszek <jakub.matraszek@gmail.com>
   { "iRiver", 0x4102, "T5", 0x1153,
     DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
     DEVICE_FLAG_NO_ZERO_READS | DEVICE_FLAG_OGG_IS_UNKNOWN },
@@ -856,15 +768,9 @@
   /*
    * Dell
    */
-  { "Dell Inc", 0x413c, "DJ Itty", 0x4500,
-      DEVICE_FLAG_NONE },
+  { "Dell, Inc", 0x413c, "DJ Itty", 0x4500, DEVICE_FLAG_NONE },
   /* Reported by: JR */
-  { "Dell Inc", 0x413c, "Dell Streak 7", 0xb10b,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Dell Inc", 0x413c, "Dell Venue 7 inch", 0xb11a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Dell Inc", 0x413c, "Dell Venue 7 inch (2nd ID)", 0xb11b,
-      DEVICE_FLAGS_ANDROID_BUGS },
+  { "Dell, Inc", 0x413c, "Dell Streak 7", 0xb10b, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
    * Toshiba
@@ -920,9 +826,6 @@
   // Reported by Andree Jacobson <nmcandree@users.sourceforge.net>
   { "Toshiba", 0x0930, "Excite AT300", 0x0963,
       DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1557/ */
-  { "Toshiba", 0x0930, "Excite AT200", 0x0960,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by Nigel Cunningham <nigel@tuxonice.net>
   // Guessing on Android bugs
   { "Toshiba", 0x0930, "Thrive AT100/AT105", 0x7100,
@@ -933,92 +836,67 @@
    * These devices have some dual-mode interfaces which will really
    * respect the driver unloading, so DEVICE_FLAG_UNLOAD_DRIVER
    * really work on these devices!
-   *
-   * Devices reported by:
-   * Archos
-   * Alexander Haertig <AlexanderHaertig@gmx.de>
-   * Jan Binder
-   * gudul1@users.sourceforge.net
-   * Etienne Chauchot <chauchot.etienne@free.fr>
-   * Kay McCormick <kaym@modsystems.com>
-   * Joe Rabinoff
-   * Jim Krehl <jimmuhk@users.sourceforge.net>
-   * Adrien Guichard <tmor@users.sourceforge.net>
-   * Clément <clemvangelis@users.sourceforge.net>
-   * Thackert <hackertenator@users.sourceforge.net>
-   * Till <Till@users.sourceforge.net>
-   * Sebastien ROHAUT
    */
+  // Reported by Alexander Haertig <AlexanderHaertig@gmx.de>
   { "Archos", 0x0e79, "Gmini XS100", 0x1207, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Added by Jan Binder
   { "Archos", 0x0e79, "XS202 (MTP mode)", 0x1208, DEVICE_FLAG_NONE },
+  // Reported by gudul1@users.sourceforge.net
   { "Archos", 0x0e79, "104 (MTP mode)", 0x120a, DEVICE_FLAG_NONE },
+  // Reported by Archos
   { "Archos", 0x0e79, "204 (MTP mode)", 0x120c, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by anonymous Sourceforge user.
   { "Archos", 0x0e79, "404 (MTP mode)", 0x1301, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Archos
   { "Archos", 0x0e79, "404CAM (MTP mode)", 0x1303, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Etienne Chauchot <chauchot.etienne@free.fr>
   { "Archos", 0x0e79, "504 (MTP mode)", 0x1307, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Archos
   { "Archos", 0x0e79, "604 (MTP mode)", 0x1309, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "604WIFI (MTP mode)", 0x130b, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Kay McCormick <kaym@modsystems.com>
   { "Archos", 0x0e79, "704 mobile dvr", 0x130d, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Archos
   { "Archos", 0x0e79, "704TV (MTP mode)", 0x130f, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "405 (MTP mode)", 0x1311, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Joe Rabinoff
   { "Archos", 0x0e79, "605 (MTP mode)", 0x1313, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Archos
   { "Archos", 0x0e79, "605F (MTP mode)", 0x1315, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "705 (MTP mode)", 0x1319, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "TV+ (MTP mode)", 0x131b, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "105 (MTP mode)", 0x131d, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "405HDD (MTP mode)", 0x1321, DEVICE_FLAG_UNLOAD_DRIVER },
-  { "Archos", 0x0e79, "5 (MTP mode 1)", 0x1331, DEVICE_FLAG_UNLOAD_DRIVER },
-  { "Archos", 0x0e79, "5 (MTP mode 2)", 0x1333, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Jim Krehl <jimmuhk@users.sourceforge.net>
+  { "Archos", 0x0e79, "5 (MTP mode)", 0x1331, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Adrien Guichard <tmor@users.sourceforge.net>
+  { "Archos", 0x0e79, "5 (MTP mode)", 0x1333, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Archos
   { "Archos", 0x0e79, "7 (MTP mode)", 0x1335, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "SPOD (MTP mode)", 0x1341, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "5S IT (MTP mode)", 0x1351, DEVICE_FLAG_UNLOAD_DRIVER },
   { "Archos", 0x0e79, "5H IT (MTP mode)", 0x1357, DEVICE_FLAG_UNLOAD_DRIVER },
-  { "Archos", 0x0e79, "48 (MTP mode)", 0x1421, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "Arnova Childpad", 0x1458, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "Arnova 8c G3", 0x145e, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "Arnova 10bG3 Tablet", 0x146b, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "97 Xenon", 0x149a, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "97 Titanium", 0x14ad, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "80 Titanium", 0x14bf, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "101 Titanium", 0x14b9, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/91/ */
-  { "Archos", 0x0e79, "70b Titanium", 0x14ef, DEVICE_FLAGS_ANDROID_BUGS },
+  { "Archos", 0x0e79, "Arnova Childpad", 0x1458, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by anonymous Sourceforge user
   { "Archos", 0x0e79, "8o G9 (MTP mode)", 0x1508, DEVICE_FLAG_UNLOAD_DRIVER },
-  { "Archos", 0x0e79, "8o G9 Turbo (MTP mode)", 0x1509, DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Clément <clemvangelis@users.sourceforge.net>
+  { "Archos", 0x0e79, "8o G9 Turbo (MTP mode)", 0x1509,
+      DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Thackert <hackertenator@users.sourceforge.net>
   { "Archos", 0x0e79, "80G9", 0x1518, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "101 G9 (ID1)", 0x1528, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "101 G9 (ID2)", 0x1529, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "101 G9 Turbo 250 HD", 0x1538, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by Till <Till@users.sourceforge.net>
+  { "Archos", 0x0e79, "101 G9", 0x1528, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous sourceforge user
+  { "Archos", 0x0e79, "101 G9 (v2)", 0x1529, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous sourceforge user
+  { "Archos", 0x0e79, "101 G9 Turbo 250 HD", 0x1538,
+      DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous sourceforge user
   { "Archos", 0x0e79, "101 G9 Turbo", 0x1539, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "101 XS", 0x1548, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "70it2 (ID 1)", 0x1568, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "70it2 (ID 2)", 0x1569, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "70 Cobalt", 0x15ba, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "50c", 0x2008, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "C40", 0x31ab, DEVICE_FLAGS_ANDROID_BUGS },
-  /* via libmtp-discuss Tonton <to.tonton@gmail.com> */
-  { "Archos", 0x0e79, "Helium 45B", 0x31d8, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1393/ */
-  { "Archos", 0x0e79, "Phone", 0x31e1, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1325/ */
-  { "Archos", 0x0e79, "45 Neon", 0x31f3, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1352/ */
-  { "Archos", 0x0e79, "50 Diamond", 0x3229, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "101 G4", 0x4002, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos (for Tesco)", 0x0e79, "Hudl (ID1)", 0x5008, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos (for Tesco)", 0x0e79, "Hudl (ID2)", 0x5009, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1404/ */
-  { "Archos", 0x0e79, "AC40DTI", 0x5217, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1573/ */
-  { "Archos", 0x0e79, "101 xenon lite", 0x528c, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Archos", 0x0e79, "101 xenon lite (ADB)", 0x528d, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1581/ */
-  { "Archos", 0x0e79, "40 Helium phone", 0x52c2, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1587/ */
-  { "Archos", 0x0e79, "50d neon ", 0x5371, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous sourceforge user
+  { "Archos", 0x0e79, "70it2 (mode 1)", 0x1568, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by Sebastien ROHAUT
+  { "Archos", 0x0e79, "70it2 (mode 2)", 0x1569, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
    * Dunlop (OEM of EGOMAN ltd?) reported by Nanomad
@@ -1049,6 +927,19 @@
   { "Sirius", 0x18f6, "Stiletto 2", 0x0110, DEVICE_FLAG_NONE },
 
   /*
+   * Canon
+   * These are actually cameras, but they have a Microsoft device descriptor
+   * and reports themselves as supporting the MTP extension.
+   */
+  { "Canon", 0x04a9, "Ixus Digital 700 (PTP/MTP mode)", 0x30f2,
+     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+  { "Canon", 0x04a9, "PowerShot A640 (PTP/MTP mode)", 0x3139,
+     DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
+  // From Peter <pjeremy@users.sourceforge.net>
+  { "Canon", 0x04a9, "PowerShot SX20IS (PTP/MTP mode)", 0x31e4,
+     DEVICE_FLAG_NONE },
+
+  /*
    * Nokia
    * Please verify the low device IDs here, I suspect these might be for
    * things like USB storage or modem mode actually, whereas the higher
@@ -1129,8 +1020,6 @@
   { "Nokia", 0x0421, "E72", 0x0221, DEVICE_FLAG_NONE },
   // From: Anonymous SourceForge user
   { "Nokia", 0x0421, "5530", 0x0229, DEVICE_FLAG_NONE },
-  /* Grzegorz Woźniak <wozniakg@gmail.com> */
-  { "Nokia", 0x0421, "E6", 0x032f, DEVICE_FLAG_NONE },
   // From: Anonymous SourceForge user
   { "Nokia", 0x0421, "N97 mini", 0x026b, DEVICE_FLAG_NONE },
   // From: Anonymous SourceForge user
@@ -1185,62 +1074,12 @@
       DEVICE_FLAG_UNLOAD_DRIVER },
   // From: Maxin B. John <maxin.john@gmail.com>
   { "Nokia", 0x0421, "N9", 0x051a, DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1308/ */
-  { "Nokia", 0x0421, "N300", 0x0524, DEVICE_FLAG_NONE },
-  { "Nokia", 0x0421, "C5-00", 0x0592, DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1457/ */
-  { "Nokia", 0x0421, "C5-00 (ID2)", 0x0595, DEVICE_FLAG_NONE },
-  { "Nokia", 0x0421, "808 PureView", 0x05d3, DEVICE_FLAG_NONE },
-  // Reported by Sampo Savola
-  // Covers Lumia 920, 820 and probably any WP8 device.
-  { "Nokia", 0x0421, "Lumia WP8", 0x0661, DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1176/ */
-  { "Nokia", 0x0421, "Lumia 301", 0x0666, DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/support-requests/146/ */
-  { "Nokia", 0x0421, "XL", 0x06e8, DEVICE_FLAG_UNLOAD_DRIVER },
-  /* https://sourceforge.net/p/libmtp/patches/69/
-   * https://sourceforge.net/p/libmtp/bugs/1285/
-   * ID is the same for various Lumia version.
-   */
-  { "Nokia", 0x0421, "Lumia (RM-975)", 0x06fc, DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1453/ */
-  { "Nokia", 0x0421, "X2 Dual Sim", 0x0708, DEVICE_FLAG_NONE },
-
-
-  /*
-   * Qualcomm
-   * This vendor ID seems to be used a bit by others.
-   */
-
   // Reported by Richard Wall <richard@the-moon.net>
-  { "Qualcomm (for Nokia)", 0x05c6, "5530 Xpressmusic", 0x0229,
-      DEVICE_FLAG_NONE },
+  { "Nokia", 0x05c6, "5530 Xpressmusic", 0x0229, DEVICE_FLAG_NONE },
+  // Reported by anonymous SourceForge user
   // One thing stated by reporter (Nokia model) another by the detect log...
-  { "Qualcomm (for Nokia/Verizon)", 0x05c6, "6205 Balboa/Verizon Music Phone",
-      0x3196, DEVICE_FLAG_NONE },
-  { "Qualcomm (for Gigabyte)", 0x05c6, "GSmart G1342",
-      0x8800, DEVICE_FLAG_NONE },
-  { "Qualcomm (for Smartfren)", 0x05c6, "Andromax U",
-      0x9025, DEVICE_FLAG_NONE },
-  // New Android phone of the OnePlus brand : the One model
-  { "Qualcomm (for OnePlus)", 0x05c6, "One (MTP)",
-      0x6764, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Qualcomm (for OnePlus)", 0x05c6, "One (MTP+ADB)",
-      0x6765, DEVICE_FLAGS_ANDROID_BUGS },
+  { "Nokia/Verizon", 0x05c6, "6205 Balboa/Verizon Music Phone", 0x3196, DEVICE_FLAG_NONE },
 
-  /* https://sourceforge.net/p/libmtp/bugs/1377/ */
-  { "Qualcomm (for Xolo)", 0x901b, "Xolo Black (MTP)",
-      0x9039, DEVICE_FLAGS_ANDROID_BUGS },
-
-  { "Qualcomm (for PhiComm)", 0x05c6, "C230w (MTP)",
-      0x9039, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1513/ */
-  { "Qualcomm (for OnePlus)", 0x05c6, "One Plus 2 (A2003) (MTP)",
-      0xf003, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1284/ */
-  { "Qualcomm (for Highscreen)", 0x05c6, "Omega Prime S",
-      0xf003, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
    * Vendor ID 0x13d1 is some offshoring company in China,
@@ -1269,18 +1108,9 @@
   { "Thomson / RCA", 0x069b, "Lyra HC308A", 0x3035, DEVICE_FLAG_NONE },
 
   /*
-   * Fujitsu devices
+   * NTT DoCoMo
    */
-  { "Fujitsu, Ltd", 0x04c5, "F903iX HIGH-SPEED", 0x1140, DEVICE_FLAG_NONE },
-  // Reported by Thomas Bretthauer
-  { "Fujitsu, Ltd", 0x04c5, "STYLISTIC M532", 0x133b,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/137/ */
-  { "Fujitsu, Ltd", 0x04c5, "F02-E", 0x1378,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1495/ */
-  { "Fujitsu, Ltd", 0x04c5, "Arrows 202F", 0x13dd,
-      DEVICE_FLAGS_ANDROID_BUGS },
+  { "FOMA", 0x04c5, "F903iX HIGH-SPEED", 0x1140, DEVICE_FLAG_NONE },
 
   /*
    * Palm device userland program named Pocket Tunes
@@ -1302,14 +1132,11 @@
   // Reported by anonymous SourceForge user.
   // This one done for Medion, whatever that is. Error reported so assume
   // the same bug flag as its ancestor above.
-  { "Medion", 0x066f, "MD8333 (ID1)", 0x8550,
+  { "Medion", 0x066f, "MD8333", 0x8550,
     DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
   // Reported by anonymous SourceForge user
-  { "Medion", 0x066f, "MD8333 (ID2)", 0x8588,
+  { "Medion", 0x066f, "MD8333", 0x8588,
     DEVICE_FLAG_UNLOAD_DRIVER | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
-  /* https://sourceforge.net/p/libmtp/bugs/1359/ */
-  { "Verizon", 0x0408, "Ellipsis 7", 0x3899,
-    DEVICE_FLAGS_ANDROID_BUGS },
   // The vendor ID is "Quanta Computer, Inc."
   // same as Olivetti Olipad 110
   // Guessing on device flags
@@ -1336,10 +1163,6 @@
   {"TrekStor", 0x1e68, "i.Beat Organix 2.0", 0x0002,
     DEVICE_FLAG_UNLOAD_DRIVER },
 
-  /* Also Thalia Toline. https://sourceforge.net/p/libmtp/bugs/1156/ */
-  {"iRiver", 0x1e68, "Tolino Tab 7", 0x1002,
-    DEVICE_FLAGS_ANDROID_BUGS },
-
   /*
    * Disney/Tevion/MyMusix
    */
@@ -1430,6 +1253,7 @@
   /*
    * LG Electronics
    */
+  // From anonymous SourceForge user
   // Uncertain if this is really the MTP mode device ID...
   { "LG Electronics Inc.", 0x043e, "T54", 0x7040,
       DEVICE_FLAG_UNLOAD_DRIVER },
@@ -1446,61 +1270,20 @@
   { "LG Electronics Inc.", 0x1004, "GR-500 Music Player", 0x611b,
       DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
       DEVICE_FLAG_ALWAYS_PROBE_DESCRIPTOR },
+  // Reported by anonymous sourceforge user
   { "LG Electronics Inc.", 0x1004, "KM900", 0x6132,
       DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
       DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by anonymous sourceforge user
   { "LG Electronics Inc.", 0x1004, "LG8575", 0x619a,
       DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
       DEVICE_FLAG_UNLOAD_DRIVER },
-  /*
-   * These two are LG Android phones:
-   * LG-F6
-   * V909 G-Slate
-   */
-  { "LG Electronics Inc.", 0x1004, "Android phone (ID1)", 0x61f1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "LG Electronics Inc.", 0x1004, "Android phone (ID2)", 0x61f9,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1007/ */
-  { "LG Electronics Inc.", 0x1004, "LG VS980", 0x621c,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "LG Electronics Inc.", 0x1004, "LG2 Optimus", 0x6225,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1386/ */
-  { "LG Electronics Inc.", 0x1004, "LG VS950", 0x622a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "LG Electronics Inc.", 0x1004, "LG VS870", 0x6239,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/992/ */
-  { "LG Electronics Inc.", 0x1004, "LG VS890", 0x623d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/190/ */
-  { "LG Electronics Inc.", 0x1004, "LG Optimus Zone 2", 0x6259,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "LG Electronics Inc.", 0x1004, "VK810", 0x6265,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "LG Electronics Inc.", 0x1004, "G3", 0x627f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1463/ */
-  { "LG Electronics Inc.", 0x1004, "810 tablet", 0x6263,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/134/ */
-  { "LG Electronics Inc.", 0x1004, "G3 (VS985)", 0x626e,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /*
-   * This VID+PID is used by a lot of LG models:
-   * E430
-   * E460
-   * E610
-   * E612
-   * E617G
-   * E970
-   * P700
-   */
-  { "LG Electronics Inc.", 0x1004, "Various E and P models", 0x631c,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1294/ */
-  { "LG Electronics Inc.", 0x1004, "LG G Flex 2", 0x633e,
+  // Reported by anonymous sourceforge user
+  { "LG Electronics Inc.", 0x1004, "V909 G-Slate", 0x61f9,
+      DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST |
+      DEVICE_FLAG_UNLOAD_DRIVER },
+  // Reported by Brian J. Murrell
+  { "LG Electronics Inc.", 0x1004, "LG-E617G/P700", 0x631c,
       DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
@@ -1510,77 +1293,76 @@
    * reported to see a pattern here.
    */
   // Reported by Alessandro Radaelli <alessandro.radaelli@aruba.it>
-  { "Sony", 0x054c, "NWZ-A815/NWZ-A818", 0x0325,
+  { "Sony", 0x054c, "Walkman NWZ-A815/NWZ-A818", 0x0325,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by anonymous Sourceforge user.
-  { "Sony", 0x054c, "NWZ-S516", 0x0326,
+  { "Sony", 0x054c, "Walkman NWZ-S516", 0x0326,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Endre Oma <endre.88.oma@gmail.com>
-  { "Sony", 0x054c, "NWZ-S615F/NWZ-S616F/NWZ-S618F", 0x0327,
+  { "Sony", 0x054c, "Walkman NWZ-S615F/NWZ-S616F/NWZ-S618F", 0x0327,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Jean-Marc Bourguet <jm@bourguet.org>
-  { "Sony", 0x054c, "NWZ-S716F", 0x035a,
+  { "Sony", 0x054c, "Walkman NWZ-S716F", 0x035a,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Anon SF User / Anthon van der Neut <avanderneut@avid.com>
-  { "Sony", 0x054c, "NWZ-A826/NWZ-A828/NWZ-A829", 0x035b,
+  { "Sony", 0x054c, "Walkman NWZ-A826/NWZ-A828/NWZ-A829", 0x035b,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Niek Klaverstijn <niekez@users.sourceforge.net>
-  { "Sony", 0x054c, "NWZ-A726/NWZ-A728/NWZ-A768", 0x035c,
+  { "Sony", 0x054c, "Walkman NWZ-A726/NWZ-A728/NWZ-A768", 0x035c,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Mehdi AMINI <mehdi.amini - at - ulp.u-strasbg.fr>
-  { "Sony", 0x054c, "NWZ-B135", 0x036e,
+  { "Sony", 0x054c, "Walkman NWZ-B135", 0x036e,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by <tiagoboldt@users.sourceforge.net>
-  { "Sony", 0x054c, "NWZ-E436F", 0x0385,
+  { "Sony", 0x054c, "Walkman NWZ-E436F", 0x0385,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Michael Wilkinson
-  { "Sony", 0x054c, "NWZ-W202", 0x0388,
+  { "Sony", 0x054c, "Walkman NWZ-W202", 0x0388,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Ondrej Sury <ondrej@sury.org>
-  { "Sony", 0x054c, "NWZ-S739F", 0x038c,
+  { "Sony", 0x054c, "Walkman NWZ-S739F", 0x038c,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Marco Filipe Nunes Soares Abrantes Pereira <marcopereira@ua.pt>
-  { "Sony", 0x054c, "NWZ-S638F", 0x038e,
+  { "Sony", 0x054c, "Walkman NWZ-S638F", 0x038e,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Elliot <orwells@users.sourceforge.net>
-  { "Sony", 0x054c, "NWZ-X1050B/NWZ-X1060B",
+  { "Sony", 0x054c, "Walkman NWZ-X1050B/NWZ-X1060B",
     0x0397, DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Silvio J. Gutierrez <silviogutierrez@users.sourceforge.net>
-  { "Sony", 0x054c, "NWZ-X1051/NWZ-X1061", 0x0398,
+  { "Sony", 0x054c, "Walkman NWZ-X1051/NWZ-X1061", 0x0398,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Gregory Boddin <gregory@siwhine.net>
-  { "Sony", 0x054c, "NWZ-B142F", 0x03d8,
+  { "Sony", 0x054c, "Walkman NWZ-B142F", 0x03d8,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Rick Warner <rick@reptileroom.net>
-  { "Sony", 0x054c, "NWZ-E344/E345", 0x03fc,
+  { "Sony", 0x054c, "Walkman NWZ-E344", 0x03fc,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Jonathan Stowe <gellyfish@users.sourceforge.net>
-  { "Sony", 0x054c, "NWZ-E445", 0x03fd,
+  { "Sony", 0x054c, "Walkman NWZ-E445", 0x03fd,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Anonymous SourceForge user
-  { "Sony", 0x054c, "NWZ-S545", 0x03fe,
+  { "Sony", 0x054c, "Walkman NWZ-S545", 0x03fe,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
-  { "Sony", 0x054c, "NWZ-A845", 0x0404,
+  { "Sony", 0x054c, "Walkman NWZ-A845", 0x0404,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by anonymous SourceForge user
-  { "Sony", 0x054c, "NWZ-W252B", 0x04bb,
+  { "Sony", 0x054c, "Walkman NWZ-W252B", 0x04bb,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Suspect this device has strong DRM features
   // See https://answers.launchpad.net/ubuntu/+source/libmtp/+question/149587
-  { "Sony", 0x054c, "NWZ-B153F", 0x04be,
+  { "Sony", 0x054c, "Walkman NWZ-B153F", 0x04be,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
-  { "Sony", 0x054c, "NWZ-E354", 0x04cb,
+  { "Sony", 0x054c, "Walkman NWZ-E354", 0x04cb,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Toni Burgarello
-  { "Sony", 0x054c, "NWZ-S754", 0x04cc,
+  { "Sony", 0x054c, "Walkman NWZ-S754", 0x04cc,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
-  // Reported by Hideki Yamane <henrich@debian.org>
-  { "Sony", 0x054c, "Sony Tablet P1", 0x04d1,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by dmiceman
   { "Sony", 0x054c, "NWZ-B163F", 0x059a,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
-  { "Sony", 0x054c, "NWZ-E464", 0x05a6,
+  // Reported by anonymous Sourceforge user
+  // guessing on device flags...
+  { "Sony", 0x054c, "Walkman NWZ-E464", 0x05a6,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
   // Reported by Jan Rheinlaender <jrheinlaender@users.sourceforge.net>
   { "Sony", 0x054c, "NWZ-S765", 0x05a8,
@@ -1591,11 +1373,7 @@
   // Reported by ghalambaz <ghalambaz@users.sourceforge.net>
   { "Sony", 0x054c, "Sony Tablet S1", 0x05b4,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "Sony", 0x054c, "NWZ-B173F", 0x0689,
-      DEVICE_FLAGS_SONY_NWZ_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1540/ */
-  { "Sony", 0x054c, "NWZ-E474", 0x06a9,
-      DEVICE_FLAGS_SONY_NWZ_BUGS },
+  // Reported by Anonymous SourceForge user
   { "Sony", 0x054c, "DCR-SR75", 0x1294,
       DEVICE_FLAGS_SONY_NWZ_BUGS },
 
@@ -1685,11 +1463,10 @@
    * 0x6nnn = UMS + ADB
    * 0x7nnn = MTP + CDC
    * 0x8nnn = MTP + CDC + ADB
-   * 0xannn = MTP + UMS (MTP for eMMC and UMS for external SD card)
-   * 0xbnnn = MTP + UMS + ADB
+   * 0xannn = MTP + UMS + ?
    * 0xennn = UMS only
    *
-   * The SonyEricsson and SONY devices have (at least) two deployed MTP
+   * The SonyEricsson and SONY devices have (at least)two deployed MTP
    * stacks: Aricent and Android. These have different bug flags, and
    * sometimes the same device has firmware upgrades moving it from
    * the Aricent to Android MTP stack without changing the device
@@ -1699,7 +1476,6 @@
    * That is why DEVICE_FLAG_NONE is used for these devices.
    *
    * Devices reported by:
-   * Sony Mobile Communications (via Toby Collett)
    * Jonas Salling
    * Eamonn Webster <eweb@users.sourceforge.net>
    * Alejandro DC <Alejandro_DC@users.sourceforge.ne>
@@ -1714,458 +1490,114 @@
    * Jean-François  B. <changi67@users.sourceforge.net>
    * Eduard Bloch <blade@debian.org>
    * Ah Hong <hongster@users.sourceforge.net>
-   * Eowyn Carter
    */
-  { "SonyEricsson", 0x0fce,  "c1605 Xperia Dual E MTP", 0x0146,
+  { "SonyEricsson", 0x0fce, "LT15i (Xperia arc S)", 0x014f,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "LT15i Xperia arc S MTP", 0x014f,
+  { "SonyEricsson", 0x0fce, "MT11i Xperia Neo", 0x0156,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "MT11i Xperia Neo MTP", 0x0156,
+  { "SonyEricsson", 0x0fce, "MK16i Xperia", 0x015a,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "IS12S Xperia Acro MTP", 0x0157,
+  { "SonyEricsson", 0x0fce, "ST18a Xperia Ray", 0x0161,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "MK16i Xperia MTP", 0x015a,
+  { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro", 0x0166,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "R800/R88i Xperia Play MTP", 0x015d,
+  { "SonyEricsson", 0x0fce, "ST15i Xperia Mini", 0x0167,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "ST18a Xperia Ray MTP", 0x0161,
+  { "SonyEricsson", 0x0fce, "ST17i Xperia Active", 0x0168,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro MTP", 0x0166,
-      DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "ST15i Xperia Mini MTP", 0x0167,
-      DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "ST17i Xperia Active MTP", 0x0168,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT26i Xperia S MTP", 0x0169,
+  { "SONY", 0x0fce, "LT26i Xperia S", 0x0169,
       DEVICE_FLAG_NO_ZERO_READS },
-  { "SONY", 0x0fce, "WT19i Live Walkman MTP", 0x016d,
+  { "SONY", 0x0fce, "WT19i Live Walkman", 0x016d,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST21i Xperia Tipo MTP", 0x0170,
+  { "SONY", 0x0fce, "ST21i Xperia Tipo", 0x0170,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST15i Xperia U MTP", 0x0171,
+  { "SONY", 0x0fce, "ST15i Xperia U", 0x0171,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT22i Xperia P MTP", 0x0172,
+  { "SONY", 0x0fce, "LT22i Xperia P", 0x0172,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "MT27i Xperia Sola MTP", 0x0173,
+  { "SONY", 0x0fce, "LT26w Xperia Acro S", 0x0176,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT26w Xperia Acro HD IS12S MTP", 0x0175,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT26w Xperia Acro HD SO-03D MTP", 0x0176,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT28at Xperia Ion MTP", 0x0177,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT29i Xperia GX MTP", 0x0178,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST27i/ST27a Xperia go MTP", 0x017e,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST23i Xperia Miro MTP", 0x0180,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "SO-05D Xperia SX MTP", 0x0181,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT30p Xperia T MTP", 0x0182,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT25i Xperia V MTP", 0x0186,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia J MTP", 0x0188,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia ZL MTP", 0x0189,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia E MTP", 0x018c,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Tablet Z MTP 1", 0x018d,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia L MTP", 0x0192,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z MTP", 0x0193,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Tablet Z MTP 2", 0x0194,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia SP MTP", 0x0195,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z Ultra MTP (ID2)", 0x0196,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia ZR MTP", 0x0197,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia A MTP", 0x0198,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia M MTP", 0x019b,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z Ultra MTP (ID3)", 0x019c,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z1 MTP", 0x019e,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia C MTP", 0x01a3,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z1 Compact D5503", 0x01a7,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia M2 MTP", 0x01aa,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia M2 Dual MTP", 0x01ab,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z2 MTP", 0x01af,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3v MTP", 0x01b0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z2 Tablet MTP", 0x01b1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia E1 MTP", 0x01b5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z Ultra MTP", 0x01b6,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia M2 Aqua MTP", 0x01b8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z3 MTP", 0x01ba,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3 Compact MTP", 0x01bb,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia E3 MTP", 0x01bc,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3 Tablet MTP", 0x01c0,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria M4 Aqua Dual MTP", 0x01c4,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "E2115 MTP", 0x01c5,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z3+ MTP", 0x01c9,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria E4g MTP", 0x01cb,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "C4 Dual MTP", 0x01d2,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria M5 MTP", 0x01d6,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z5 MTP", 0x01d9,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z5 Compact MTP", 0x01da,
-      DEVICE_FLAG_NONE },
-
 
   /*
    * MTP+UMS personalities of MTP devices (see above)
    */
-  { "SonyEricsson", 0x0fce, "IS12S Xperia Acro MTP+CDROM", 0x4157,
+  { "SonyEricsson", 0x0fce, "ST17i Xperia Active (MTP+UMS mode)", 0x4168,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "ST17i Xperia Active MTP+CDROM", 0x4168,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT26i Xperia S MTP+CDROM", 0x4169,
+  { "SONY", 0x0fce, "LT26i Xperia S (MTP+UMS mode)", 0x4169,
       DEVICE_FLAG_NO_ZERO_READS },
-  { "SONY", 0x0fce, "ST21i Xperia Tipo MTP+CDROM", 0x4170,
+  { "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+UMS mode)", 0x4170,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST25i Xperia U MTP+CDROM", 0x4171,
+  { "SONY", 0x0fce, "ST25i Xperia U (MTP+UMS mode)", 0x4171,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT22i Xperia P MTP+CDROM", 0x4172,
+  { "SONY", 0x0fce, "LT22i Xperia P (MTP+UMS mode)", 0x4172,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "MT27i Xperia Sola MTP+CDROM", 0x4173,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT26w Xperia Acro HD IS12S MTP+CDROM", 0x4175,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT26w Xperia Acro HD SO-03D MTP+CDROM", 0x4176,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT28at Xperia Ion MTP+CDROM", 0x4177,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT29i Xperia GX MTP+CDROM", 0x4178,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST27i/ST27a Xperia go MTP+CDROM", 0x417e,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST23i Xperia Miro MTP+CDROM", 0x4180,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "SO-05D Xperia SX MTP+CDROM", 0x4181,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT30p Xperia T MTP+CDROM", 0x4182,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT25i Xperia V MTP+CDROM", 0x4186,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia J MTP+CDROM", 0x4188,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia ZL MTP+CDROM", 0x4189,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia E MTP+CDROM", 0x418c,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Tablet Z MTP+CDROM 1", 0x418d,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia L MTP+CDROM", 0x4192,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z MTP+CDROM", 0x4193,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Tablet Z MTP+CDROM 2", 0x4194,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia SP MTP+CDROM", 0x4195,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia M MTP+CDROM", 0x419b,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z Ultra MTP+CDROM (ID3)", 0x419c,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z1 MTP+CDROM", 0x419e,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia C MTP+CDROM", 0x41a3,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z1 Compact D5503 MTP+CDROM", 0x41a7,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia M2 MTP+CDROM", 0x41aa,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia M2 Dual MTP+CDROM", 0x41ab,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z2 MTP+CDROM", 0x41af,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3v MTP+CDROM", 0x41b0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z2 Tablet MTP+CDROM", 0x41b1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia E1 MTP+CDROM", 0x41b5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z Ultra MTP+CDROM", 0x41b6,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia M2 Aqua MTP+CDROM", 0x41b8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z3 MTP+CDROM", 0x41ba,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3 Compact MTP+CDROM", 0x41bb,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia E3 MTP+CDROM", 0x41bc,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3 Tablet MTP+CDROM", 0x41c0,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria M4 Aqua Dual MTP+CDROM", 0x41c4,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "E2115 MTP+CDROM", 0x41c5,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z3+ MTP+CDROM", 0x41c9,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria E4g MTP+CDROM", 0x41cb,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "C4 Dual MTP+CDROM", 0x41d2,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria M5 MTP+CDROM", 0x41d6,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z5 MTP+CDROM", 0x41d9,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z5 Compact MTP+CDROM", 0x41da,
+  { "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+UMS mode)", 0x4176,
       DEVICE_FLAG_NONE },
 
   /*
    * MTP+ADB personalities of MTP devices (see above)
    */
-  { "SonyEricsson", 0x0fce,  "c1605 Xperia Dual E MTP+ADB", 0x5146,
+  { "SonyEricsson", 0x0fce, "LT15i Xperia Arc (MTP+ADB mode)", 0x514f,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "LT15i Xperia Arc MTP+ADB", 0x514f,
+  { "SonyEricsson", 0x0fce, "MT11i Xperia Neo (MTP+ADB mode)", 0x5156,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "MT11i Xperia Neo MTP+ADB", 0x5156,
+  { "SonyEricsson", 0x0fce, "ST17i Xperia Active (MTP+ADB mode)", 0x5168,
       DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "IS12S Xperia Acro MTP+ADB", 0x5157,
-      DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "MK16i Xperia MTP+ADB", 0x515a,
-      DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "R800/R88i Xperia Play MTP+ADB", 0x515d,
-      DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "ST18i Xperia Ray MTP+ADB", 0x5161,
-      DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro MTP+ADB", 0x5166,
-      DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "ST15i Xperia Mini MTP+ADB", 0x5167,
-      DEVICE_FLAG_NONE },
-  { "SonyEricsson", 0x0fce, "ST17i Xperia Active MTP+ADB", 0x5168,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT26i Xperia S MTP+ADB", 0x5169,
+  { "SONY", 0x0fce, "LT26i Xperia S (MTP+ADB mode)", 0x5169,
       DEVICE_FLAG_NO_ZERO_READS },
-  { "SonyEricsson", 0x0fce, "WT19i Live Walkman MTP+ADB", 0x516d,
+  { "SonyEricsson", 0x0fce, "MK16i Xperia (MTP+ADB mode)", 0x515a,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST21i Xperia Tipo MTP+ADB", 0x5170,
+  { "SonyEricsson", 0x0fce, "ST18i Xperia Ray (MTP+ADB mode)", 0x5161,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST25i Xperia U MTP+ADB", 0x5171,
+  { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+ADB mode)", 0x5166,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT22i Xperia P MTP+ADB", 0x5172,
+  { "SonyEricsson", 0x0fce, "ST15i Xperia Mini (MTP+ADB mode)", 0x5167,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "MT27i Xperia Sola MTP+ADB", 0x5173,
+  { "SonyEricsson", 0x0fce, "SK17i Xperia Mini Pro (MTP+ADB mode)", 0x516d,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "IS12S Xperia Acro HD MTP+ADB", 0x5175,
+  { "SONY", 0x0fce, "ST21i Xperia Tipo (MTP+ADB mode)", 0x5170,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "SO-03D Xperia Acro HD MTP+ADB", 0x5176,
+  { "SONY", 0x0fce, "ST25i Xperia U (MTP+ADB mode)", 0x5171,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT28at Xperia Ion MTP+ADB", 0x5177,
+  { "SONY", 0x0fce, "LT22i Xperia P (MTP+ADB mode)", 0x5172,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT29i Xperia GX MTP+ADB", 0x5178,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST27i/ST27a Xperia go MTP+ADB", 0x517e,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST23i Xperia Miro MTP+ADB", 0x5180,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "SO-05D Xperia SX MTP+ADB", 0x5181,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT30p Xperia T MTP+ADB", 0x5182,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT25i Xperia V MTP+ADB", 0x5186,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia J MTP+ADB", 0x5188,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia ZL MTP+ADB", 0x5189,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia E MTP+ADB", 0x518c,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Tablet Z MTP+ADB 1", 0x518d,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia L MTP+ADB", 0x5192,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z MTP+ADB", 0x5193,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Tablet Z MTP+ADB 2", 0x5194,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia SP MTP+ADB", 0x5195,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z Ultra MTP+ADB (ID2)", 0x5196,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia ZR MTP+ADB", 0x5197,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia A MTP+ADB", 0x5198,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia M MTP+ADB", 0x519b,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z Ultra MTP+ADB (ID3)", 0x519c,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z1 MTP+ADB", 0x519e,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia C MTP+ADB", 0x51a3,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z1 Compact MTP+ADB", 0x51a7,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia M2 MTP+ADB", 0x51aa,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia M2 Dual MTP+ADB", 0x51ab,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z2 MTP+ADB", 0x51af,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3v MTP+ADB", 0x51b0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z2 Tablet MTP+ADB", 0x51b1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia E1 MTP+ADB", 0x51b5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z Ultra MTP+ADB", 0x51b6,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia M2 Aqua MTP+ADB", 0x51b8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SONY", 0x0fce, "Xperia Z3 MTP+ADB", 0x51ba,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3 Compact MTP+ADB", 0x51bb,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia E3 MTP+ADB", 0x51bc,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "Xperia Z3 Tablet MTP+ADB", 0x41c0,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria M4 Aqua Dual MTP+ADB", 0x51c4,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "E2115 MTP+ADB", 0x51c5,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z3+ MTP+ADB", 0x51c9,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce,  "XPeria E4g MTP+ADB", 0x51cb,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "C4 Dual MTP+ADB", 0x51d2,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria M5 MTP+ADB", 0x51d6,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z5 MTP+ADB", 0x51d9,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "XPeria Z5 Compact MTP+ADB", 0x51da,
+  { "SONY", 0x0fce, "LT26w Xperia Acro S (MTP+ADB mode)", 0x5176,
       DEVICE_FLAG_NONE },
 
   /*
-   * MTP+UMS modes
-   * This mode is for using MTP on the internal storage (eMMC)
-   * and using UMS (Mass Storage Device Class) on the external
-   * SD card
+   * MTP+UMS+? modes
+   * No reports on other personalities on these devices.
    */
-  { "SONY", 0x0fce, "MT27i Xperia Sola MTP+UMS", 0xa173,
+  { "SONY", 0x0fce, "MT27i Xperia Sola (MTP+UMS+? mode)", 0xa173,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "IS12S Xperia Acro HD MTP+UMS", 0xa175,
+  { "SONY", 0x0fce, "ST27i Xperia Go (MTP+UMS+? mode)", 0xa17e,
       DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "SO-03D Xperia Acro HD MTP+UMS", 0xa176,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT28at Xperia Ion MTP+UMS", 0xa177,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST27i/ST27a Xperia go MTP+UMS", 0xa17e,
-      DEVICE_FLAG_NONE },
-
-  /*
-   * MTP+UMS+ADB modes
-   * Like the above, but also ADB
-   */
-  { "SONY", 0x0fce, "MT27i Xperia Sola MTP+UMS+ADB", 0xb173,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "IS12S Xperia Acro MTP+UMS+ADB", 0xb175,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "SO-03D Xperia Acro MTP+UMS+ADB", 0xb176,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "LT28at Xperia Ion MTP+UMS+ADB", 0xb177,
-      DEVICE_FLAG_NONE },
-  { "SONY", 0x0fce, "ST27i/ST27a Xperia go MTP+UMS+ADB", 0xb17e,
-      DEVICE_FLAG_NONE },
-
 
   /*
    * Motorola
    * Assume DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST on all of these.
    */
-  /* https://sourceforge.net/p/libmtp/feature-requests/136/ */
-  { "Motorola", 0x22b8, "XT1524 (MTP)", 0x002e,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by David Boyd <tiggrdave@users.sourceforge.net>
   { "Motorola", 0x22b8, "V3m/V750 verizon", 0x2a65,
       DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST |
       DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
-  { "Motorola", 0x22b8, "Atrix/Razr HD (MTP)", 0x2e32,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Atrix/Razr HD (MTP+ADB)", 0x2e33,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "RAZR M XT907 (MTP)", 0x2e50,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "RAZR M XT907 (MTP+ADB)", 0x2e51,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1539/ */
-  { "Motorola", 0x22b8, "Droid Turbo 2 (XT1585)", 0x2e61,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Moto X (XT1053)", 0x2e62,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Moto X (XT1058)", 0x2e63,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1323/ */
-  { "Motorola", 0x22b8, "Moto X (XT1080)", 0x2e66,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Droid Maxx (XT1080)", 0x2e67,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Droid Ultra", 0x2e68,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Moto G (ID1)", 0x2e76,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Moto G (ID2)", 0x2e82,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1030/, PTP Id */
-  { "Motorola", 0x22b8, "Moto G (XT1032)", 0x2e84,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1477/ */
-  { "Motorola", 0x22b8, "Moto Maxx (XT1225)", 0x2ea4,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by Jader Rodrigues Simoes <jadersimoes@users.sourceforge.net>
-  { "Motorola", 0x22b8, "Xoom 2 Media Edition (ID3)", 0x41cf,
+  { "Motorola", 0x22b8, "Xoom 2 Media Edition (ID2)", 0x41cf,
       DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by Steven Roemen <sdroemen@users.sourceforge.net>
   { "Motorola", 0x22b8, "Droid X/MB525 (Defy)", 0x41d6,
       DEVICE_FLAG_NONE },
-  { "Motorola", 0x22b8, "DROID2 (ID1)", 0x41da,
-      DEVICE_FLAG_NONE },
+  // Reported by anonymous user
   { "Motorola", 0x22b8, "Milestone / Verizon Droid", 0x41dc,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "DROID2 (ID2)", 0x42a7,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Xoom 2 Media Edition (ID2)", 0x4306,
+  // Reported by anonymous user
+  { "Motorola", 0x22b8, "DROID2", 0x42a7,
       DEVICE_FLAGS_ANDROID_BUGS },
   { "Motorola", 0x22b8, "Xoom 2 Media Edition", 0x4311,
       DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by  B,H,Kissinger <mrkissinger@users.sourceforge.net>
   { "Motorola", 0x22b8, "XT912/XT928", 0x4362,
       DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1104/ , PTP id. */
-  { "Motorola", 0x22b8, "DROID4 (PTP)", 0x4373,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by Lundgren <alundgren@users.sourceforge.net>
   { "Motorola", 0x22b8, "DROID4", 0x437f,
       DEVICE_FLAGS_ANDROID_BUGS },
@@ -2181,18 +1613,6 @@
   // Reported by anonymous user
   { "Motorola", 0x22b8, "RAZR2 V8/U9/Z6", 0x6415,
       DEVICE_FLAG_BROKEN_SET_OBJECT_PROPLIST },
-  // Reported by Rodrigo Angelo Rafael
-  // Razr D1, D3
-  { "Motorola", 0x22b8, "Razr D1/D3/i (MTP)", 0x64b5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Razr D1/D3/i (MTP+?)", 0x64b6,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/697/ */
-  { "Motorola", 0x22b8, "Atrix XT687 (MTP)", 0x64cf,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  // Reported by Brian Dolbec <dol-sen@users.sourceforge.net>
-  { "Motorola", 0x22b8, "Atrix MB860 (MTP)", 0x7088,
-      DEVICE_FLAGS_ANDROID_BUGS },
   /*
    * Motorola Xoom (Wingray) variants
    *
@@ -2219,22 +1639,9 @@
       DEVICE_FLAGS_ANDROID_BUGS },
   { "Motorola", 0x22b8, "Xoom (MTP+ADB)", 0x70a9,
       DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous Sourceforge user
   // "carried by C Spire and other CDMA US carriers"
-  { "Motorola", 0x22b8, "Milestone X2", 0x70ca,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "XT890/907/Razr (MTP)", 0x710d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "XT890/907/Razr (MTP+ADB)", 0x710e,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1183/ */
-  { "Motorola", 0x22b8, "Droid Turbo (XT1254)", 0x2ea5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Motorola", 0x22b8, "Droid Turbo Verizon", 0x2ea8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /*
-   * XT890/907/Razr
-   * 710f is USB mass storage
-   */
+  { "Motorola", 0x22b8, "Milestone X2", 0x70ca, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
    * Google
@@ -2242,19 +1649,12 @@
    * road to produce an Android tablet it seems... The Vendor ID
    * was originally used for Nexus phones
    */
-  { "Google Inc (for Allwinner)", 0x18d1, "A31 SoC", 0x0006,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Google Inc (for Ainol Novo)", 0x18d1, "Fire/Flame", 0x0007,
-      DEVICE_FLAGS_ANDROID_BUGS },
   { "Google Inc (for Sony)", 0x18d1, "S1", 0x05b3,
       DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by anonymous Sourceforge user
   { "Google Inc (for Barnes & Noble)", 0x18d1, "Nook Color", 0x2d02,
       DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by anonymous Sourceforge user
-  { "Google Inc (for Asus)", 0x18d1, "TF201 Transformer", 0x4d00,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  // Reported by anonymous Sourceforge user
   { "Google Inc (for Asus)", 0x18d1, "TF101 Transformer", 0x4e0f,
       DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by Chris Smith <tcgsmythe@users.sourceforge.net>
@@ -2263,20 +1663,6 @@
   // Reported by Michael Hess <mhess126@gmail.com>
   { "Google Inc (for Asus)", 0x18d1, "Nexus 7 (MTP+ADB)", 0x4e42,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "Google Inc (for LG Electronics/Samsung)", 0x18d1,
-      "Nexus 4/5/7/10 (MTP)", 0x4ee1,
-      (DEVICE_FLAGS_ANDROID_BUGS | DEVICE_FLAG_PROPLIST_OVERRIDES_OI) & ~DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST },
-  { "Google Inc (for LG Electronics/Samsung)", 0x18d1,
-      "Nexus 4/5/7/10 (MTP+ADB)", 0x4ee2,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1255/ */
-  { "Google", 0x18d1, "Nexus 5 (MTP)", 0x4ee5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1444/ */
-  { "Google", 0x18d1, "Pixel C (MTP)", 0x5202,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Google", 0x18d1, "Pixel C (MTP+ADB)", 0x5203,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // WiFi-only version of Xoom
   // See: http://bugzilla.gnome.org/show_bug.cgi?id=647506
   { "Google Inc (for Motorola)", 0x18d1, "Xoom (MZ604)", 0x70a8,
@@ -2288,8 +1674,6 @@
   // Another OEM for Medion
   { "Google Inc (for Medion)", 0x18d1, "MD99000 (P9514)", 0xb00a,
       DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1563/ */
-  { "Meizu", 0x18d1, "Pro 5 Ubuntu Phone", 0xd001, DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by Frederik Himpe <fhimpe@telenet.be>
   { "Google Inc (for LG Electronics)", 0x18d1, "P990/Optimus (Cyanogen)",
       0xd109, DEVICE_FLAGS_ANDROID_BUGS },
@@ -2319,9 +1703,9 @@
    */
   // Both reported by an anonymous SourceForge user
   // This is the 30 GiB model
-  { "Haier", 0x1302, "Ibiza Rhapsody 1", 0x1016, DEVICE_FLAG_NONE },
+  { "Haier", 0x1302, "Ibiza Rhapsody", 0x1016, DEVICE_FLAG_NONE },
   // This is the 4/8 GiB model
-  { "Haier", 0x1302, "Ibiza Rhapsody 2", 0x1017, DEVICE_FLAG_NONE },
+  { "Haier", 0x1302, "Ibiza Rhapsody", 0x1017, DEVICE_FLAG_NONE },
 
   /*
    * Panasonic
@@ -2368,10 +1752,6 @@
   { "RIM", 0x0fca, "BlackBerry Storm/9650", 0x8007, DEVICE_FLAG_UNLOAD_DRIVER |
       DEVICE_FLAG_SWITCH_MODE_BLACKBERRY | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
 
-  /* https://sourceforge.net/p/libmtp/bugs/1551/ */
-  { "RIM", 0x0fca, "BlackBerry Priv", 0x8031, DEVICE_FLAG_UNLOAD_DRIVER |
-      DEVICE_FLAG_SWITCH_MODE_BLACKBERRY | DEVICE_FLAG_BROKEN_MTPGETOBJPROPLIST_ALL },
-
   /*
    * Nextar
    */
@@ -2382,16 +1762,9 @@
    */
   { "Coby", 0x1e74, "COBY MP705", 0x6512, DEVICE_FLAG_NONE },
 
-#if 0
   /*
    * Apple devices, which are not MTP natively but can be made to speak MTP
    * using PwnTunes (http://www.pwntunes.net/)
-   * CURRENTLY COMMENTED OUT:
-   * These will make the UDEV rules flag these as MTP devices even if
-   * PwnTunes is NOT installed. That is unacceptable, so a better solution
-   * that actually inspects if the device has PwnTunes/MTP support needs
-   * to be found, see:
-   * https://sourceforge.net/p/libmtp/bugs/759/
    */
   { "Apple", 0x05ac, "iPhone", 0x1290, DEVICE_FLAG_NONE },
   { "Apple", 0x05ac, "iPod Touch 1st Gen", 0x1291, DEVICE_FLAG_NONE },
@@ -2403,7 +1776,6 @@
   { "Apple", 0x05ac, "0x1298", 0x1298, DEVICE_FLAG_NONE },
   { "Apple", 0x05ac, "iPod Touch 3rd Gen", 0x1299, DEVICE_FLAG_NONE },
   { "Apple", 0x05ac, "iPad", 0x129a, DEVICE_FLAG_NONE },
-#endif
 
   // Reported by anonymous SourceForge user, also reported as
   // Pantech Crux, claming to be:
@@ -2417,171 +1789,35 @@
 
   /*
    * Asus
-   * Pattern of PIDs on Android devices seem to be:
-   * n+0 = MTP
-   * n+1 = MTP+ADB
-   * n+2 = ?
-   * n+3 = ?
-   * n+4 = PTP
    */
   // Reported by Glen Overby
-  { "Asus", 0x0b05, "TF300 Transformer (MTP)", 0x4c80,
+  { "Asus", 0x0b05, "TF300 Transformer", 0x4c80,
       DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by jaile <jaile@users.sourceforge.net>
-  { "Asus", 0x0b05, "TF300 Transformer (MTP+ADB)", 0x4c81,
+  { "Asus", 0x0b05, "TF300 Transformer (USB debug mode)", 0x4c81,
       DEVICE_FLAGS_ANDROID_BUGS },
   // Repored by Florian Apolloner <f-apolloner@users.sourceforge.net>
-  { "Asus", 0x0b05, "TF700 Transformer (MTP)", 0x4c90,
+  { "Asus", 0x0b05, "TF700 Transformer", 0x4c90,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "TF700 Transformer (MTP+ADB)", 0x4c91,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "TF701T Transformer Pad (MTP)", 0x4ca0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "TF701T Transformer Pad (MTP+ADB)", 0x4ca1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/135/ */
-  { "Asus", 0x0b05, "ME302KL MeMo Pad FHD10 (MTP)", 0x4cc0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "ME302KL MeMo Pad FHD10 (MTP+ADB)", 0x4cc1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "ME301T MeMo Pad Smart 10 (MTP)", 0x4cd0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "ME301T MeMo Pad Smart 10 (MTP+ADB)", 0x4cd1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Asus Fonepad Note 6 (MTP)", 0x4ce0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Asus Fonepad Note 6 (MTP+ADB)", 0x4ce1,
-      DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous Sourceforge user
   { "Asus", 0x0b05, "TF201 Transformer Prime (keyboard dock)", 0x4d00,
       DEVICE_FLAGS_ANDROID_BUGS },
   { "Asus", 0x0b05, "TF201 Transformer Prime (tablet only)", 0x4d01,
       DEVICE_FLAGS_ANDROID_BUGS },
-  // 4d04 is the PTP mode, don't add it
-  { "Asus", 0x0b05, "SL101 (MTP)", 0x4e00,
+  { "Asus", 0x0b05, "TFXXX Transformer Prime (unknown version)", 0x4d04,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "SL101 (MTP+ADB)", 0x4e01,
+  // Reported by anonymous Sourceforge user
+  { "Asus", 0x0b05, "TF101 Eeepad Slider", 0x4e01,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "TF101 Eeepad Transformer (MTP)", 0x4e0f,
+  { "Asus", 0x0b05, "TF101 Eeepad Transformer", 0x4e0f,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "TF101 Eeepad Transformer (MTP+ADB)", 0x4e1f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Fonepad", 0x514f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "PadFone (MTP)", 0x5200,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "PadFone (MTP+ADB)", 0x5201,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "ME302C MemoPad (MTP+?)", 0x520f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "PadFone 2 (MTP)", 0x5210,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "PadFone 2 (MTP+ADB)", 0x5211,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "PadFone 2 (PTP)", 0x5214,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "ME302C MemoPad (MTP)", 0x521f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1066/ */
-  { "Asus", 0x0b05, "PadFone Infinity (2nd ID) (MTP)", 0x5220,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "PadFone Infinity (2nd ID) (MTP+ADB)", 0x5221,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "PadFone Infinity (MTP)", 0x5230,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "PadFone Infinity (MTP+ADB)", 0x5231,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Memo ME172V (MTP)", 0x5400,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1072/ */
-  { "Asus", 0x0b05, "Fonepad 7 LTE ME372CL (MTP)", 0x540f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Memo ME173X (MTP)", 0x5410,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Memo ME173X (MTP+ADB)", 0x5411,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1072/ */
-  { "Asus", 0x0b05, "Fonepad 7 LTE ME372CL (MTP+ADB)", 0x541f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Memo K00F (MTP)", 0x5460,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Memo Pad 8 (MTP)", 0x5466,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "Memo K00F (MTP+ADB)", 0x5468,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/158/ */
-  { "Asus", 0x0b05, "ZenFone 5 (MTP)", 0x5480,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1279/ */
-  { "Asus", 0x0b05, "ZenFone 5 (MTP+ADB)", 0x5481,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1236/ */
-  { "Asus", 0x0b05, "ZenFone 6 (MTP)", 0x5490,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "ZenFone 6 (MTP+ADB)", 0x5491,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1239/ */
-  { "Asus", 0x0b05, "K010 (MTP)", 0x5500,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1196/ */
-  { "Asus", 0x0b05, "MemoPad 7 (MTP+ADB)", 0x5506,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1069/ */
-  { "Asus", 0x0b05, "K00E (MTP+ADB)", 0x550f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1244/ */
-  { "Asus", 0x0b05, "MemoPad 8 ME181 CX (MTP)", 0x5561,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1406/ */
-  { "Asus", 0x0b05, "Zenfone 2 (MTP)", 0x5600,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1364/ */
-  { "Asus", 0x0b05, "Z00AD (MTP)", 0x5601,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "TX201LA (MTP)", 0x561f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1271/ */
-  { "Asus", 0x0b05, "ZenFone 4 (MTP)", 0x580f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1179/ */
-  { "Asus", 0x0b05, "ZenFone 4 A400CG (MTP)", 0x581f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1548/ */
-  { "Asus", 0x0b05, "ASUS FonePad 8 FE380CG (MTP)", 0x590f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1258/ */
-  { "Asus", 0x0b05, "A450CG (MTP)", 0x5a0f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1546/ */
-  { "Asus", 0x0b05, "ZenPad 80 (MTP)", 0x5e0f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1350/ */
-  { "Asus", 0x0b05, "Zenfone 2 ZE550ML (MTP)", 0x5f02,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1364/ */
-  { "Asus", 0x0b05, "Zenfone 2 ZE551ML (MTP)", 0x5f03,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1232/ */
-  { "Asus", 0x0b05, "MemoPad 7 (ME572CL)", 0x7772,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1351/ */
-  { "Asus", 0x0b05, "Fonepad 7 (FE375CXG)", 0x7773,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Asus", 0x0b05, "ZenFone 5 A500KL (MTP)", 0x7780,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1247/ */
-  { "Asus", 0x0b05, "ZenFone 5 A500KL (MTP+ADB)", 0x7781,
+  { "Asus", 0x0b05, "TF101 Eeepad Transformer (debug mode)", 0x4e1f,
       DEVICE_FLAGS_ANDROID_BUGS },
 
 
   /*
    * Lenovo
    */
-  /* https://sourceforge.net/p/libmtp/support-requests/178/ */
-  { "Lenovo", 0x17ef, "P70-A", 0x0c02,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1415/ */
-  { "Lenovo", 0x17ef, "P70", 0x2008,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by Richard Körber <shredzone@users.sourceforge.net>
   { "Lenovo", 0x17ef, "K1", 0x740a,
       DEVICE_FLAGS_ANDROID_BUGS },
@@ -2589,143 +1825,23 @@
   // Adding Android default bug flags since it appears to be an Android
   { "Lenovo", 0x17ef, "ThinkPad Tablet", 0x741c,
       DEVICE_FLAGS_ANDROID_BUGS },
-  // Medion is using Lenovos manufacturer ID it seems.
-  // Reported by Thomas Goss <thomas.goss@linux.com>
-  { "Medion", 0x17ef, "Lifetab P9516", 0x7483,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by: XChesser <XChesser@users.sourceforge.net>
   { "Lenovo", 0x17ef, "P700", 0x7497,
       DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1185/ */
-  { "Lenovo", 0x17ef, "A820", 0x7498,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1190/ */
-  { "Lenovo", 0x17ef, "P780", 0x74a6,
-      DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by: anonymous sourceforge user
   { "Lenovo", 0x17ef, "Lifetab S9512", 0x74cc,
       DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/170/ */
-  { "Lenovo", 0x17ef, "S660", 0x74f8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  // Reported by Brian J. Murrell
-  { "Lenovo", 0x17ef, "IdeaTab A2109A", 0x7542,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/166/ */
-  { "Lenovo", 0x17ef, "IdeaTab S2210a", 0x757d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1529/ */
-  { "Lenovo", 0x17ef, "K900 (ID2)", 0x75b3,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1123/ */
-  { "Lenovo", 0x17ef, "K900 (ID1)", 0x75b5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  // Reported by rvelev@mail.bg
-  { "Lenovo", 0x17ef, "IdeaPad A3000 (ID1)", 0x75bc,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Lenovo", 0x17ef, "IdeaPad A3000 (ID2)", 0x75be,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Lenovo", 0x17ef, "Toga Tablet B6000-F", 0x76f2,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1122/ */
-  { "Lenovo", 0x17ef, "S930", 0x7718,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1250/ */
-  { "Lenovo", 0x17ef, "A5500-F", 0x772b,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1556/ */
-  { "Lenovo", 0x17ef, "A3500-FL", 0x7738,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Lenovo", 0x17ef, "LifeTab E733X", 0x775a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Lenovo", 0x17ef, "IdeaTab S5000", 0x76e8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1155/ */
-  { "Lenovo", 0x17ef, "Yoga Tablet 10 B8000-H", 0x76ff,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /*  https://sourceforge.net/p/libmtp/bugs/1391/ */
-  { "Lenovo", 0x17ef, "A7600-F", 0x7731,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1291/ */
-  { "Lenovo", 0x17ef, "A3500-F", 0x7737,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/186/ */
-  { "Lenovo", 0x17ef, "Yoga Tablet 2 - 1050F", 0x77a4,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/168/ */
-  { "Lenovo", 0x17ef, "Yoga Tablet 2 Pro", 0x77b1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/219/ */
-  { "Lenovo", 0x17ef, "Tab S8-50F", 0x77d8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/125/ */
-  { "Lenovo", 0x17ef, "Vibe Z2", 0x77ea,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1360/ */
-  { "Lenovo", 0x17ef, "K3 Note", 0x7883,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1488/ */
-  { "Lenovo", 0x17ef, "A10-70F", 0x789a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1497/ */
-  { "Lenovo", 0x17ef, "A10-70L", 0x789b,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1480/ */
-  { "Medion", 0x17ef, "P8312 Tablet", 0x78ae,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/201/ */
-  { "Lenovo", 0x17ef, "Lifetab S1034X", 0x78b0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1572/ */
-  { "Lenovo", 0x17ef, "PHAB Plus", 0x78d1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1562/ */
-  { "Lenovo", 0x17ef, "Vibe K4 Note", 0x78f6,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/213/ */
-  { "Lenovo", 0x17ef, "Vibe P1 Pro", 0x78fc,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1531/ */
-  { "Lenovo", 0x17ef, "Vibe X", 0x7902,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1465/ */
-  { "Lenovo", 0x17ef, "A1000 Smartphone", 0x7928,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1465/ */
-  { "Lenovo", 0x17ef, "A1000 Smartphone ADB", 0x7929,
-      DEVICE_FLAGS_ANDROID_BUGS },
+
 
   /*
    * Huawei
-   * IDs used by Honor U8860,U8815,U9200,P2
    */
-  { "Huawei", 0x12d1, "MTP device (ID1)", 0x1051,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Huawei", 0x12d1, "MTP device (ID2)", 0x1052,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1507/ */
-  { "Huawei", 0x12d1, "Honor 7", 0x1074,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1381/ */
-  { "Huawei", 0x12d1, "H60-L11", 0x1079,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1550/ */
-  { "Huawei", 0x12d1, "H60-L12", 0x107a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/173/ */
-  { "Huawei", 0x12d1, "P9 Plus", 0x107e,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1361/ */
-  { "Huawei", 0x12d1, "Ascend P8 ", 0x1082,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1418/ */
-  { "Huawei", 0x12d1, "Honor 3C ", 0x2012,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Huawei", 0x12d1, "Mediapad (mode 0)", 0x360f,
-      DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous SourceForge user
+  { "Huawei", 0x12d1, "Honor U8860", 0x1051, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous SourceForge user
+  { "Huawei", 0x12d1, "Mediapad (mode 0)", 0x360f, DEVICE_FLAGS_ANDROID_BUGS },
   // Reported by Bearsh <bearsh@users.sourceforge.net>
-  { "Huawei", 0x12d1, "Mediapad (mode 1)", 0x361f,
-      DEVICE_FLAGS_ANDROID_BUGS },
+  { "Huawei", 0x12d1, "Mediapad (mode 1)", 0x361f, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
    * ZTE
@@ -2733,688 +1849,52 @@
    */
   { "ZTE", 0x19d2, "V55 ID 1", 0x0244, DEVICE_FLAGS_ANDROID_BUGS },
   { "ZTE", 0x19d2, "V55 ID 2", 0x0245, DEVICE_FLAGS_ANDROID_BUGS },
-  { "ZTE", 0x19d2, "V790/Blade 3", 0x0306, DEVICE_FLAGS_ANDROID_BUGS },
-  { "ZTE", 0x19d2, "V880E", 0x0307, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/672/ */
-  { "ZTE", 0x19d2, "Grand X In", 0x0343, DEVICE_FLAGS_ANDROID_BUGS },
-  { "ZTE", 0x19d2, "V985", 0x0383, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1328/ */
-  { "ZTE", 0x19d2, "V5", 0xffce, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
    * HTC (High Tech Computer Corp)
-   * Reporters:
-   * Steven Eastland <grassmonk@users.sourceforge.net>
-   * Kevin Cheng <kache@users.sf.net>
    */
-  /* https://sourceforge.net/p/libmtp/support-requests/181/ */
-  { "HTC", 0x0bb4, "One M9 (1st ID)", 0x040b,
+  { "HTC", 0x0bb4, "Zopo ZP100 (ID1)", 0x0c02,
       DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1398/ */
-  { "HTC", 0x0bb4, "Spreadtrum SH57MYZ03342 (MTP)", 0x05e3,
+  // Reported by Steven Eastland <grassmonk@users.sourceforge.net>
+  { "HTC", 0x0bb4, "EVO 4G LTE", 0x0c93,
       DEVICE_FLAGS_ANDROID_BUGS },
-  /* reported by Mikkel Oscar Lyderik <mikkeloscar@gmail.com> */
-  { "HTC", 0x0bb4, "HTC Desire 510 (MTP+ADB)", 0x05fd,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1221/ */
-  { "HTC", 0x0bb4, "One M8 Google Play Edition (MTP+ADB)", 0x060b,
-      DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1500/ */
-  { "HTC", 0x0bb4, "One Mini 2 (MTP)", 0x0629,
-      DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1508/ */
-  { "HTC", 0x0bb4, "One M9 (2nd ID)", 0x065c,
-      DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1543/ */
-  { "HTC", 0x0bb4, "Desire 626s (MTP)", 0x0668,
-      DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/support-requests/200/ */
-  { "HTC", 0x0bb4, "HTC Desire 520", 0x0670,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/153/ */
-  { "HTC", 0x0bb4, "HTC6515LVW/One Remix", 0x07d8,
-      DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/support-requests/141/ */
-  { "HTC", 0x0bb4, "HTC One (HTC6500LVW)", 0x07ae,
-      DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/support-requests/128/ */
-  { "HTC", 0x0bb4, "HTC One M8 (HTC6525LVW)", 0x07ca,
-      DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1161/ */
-  { "HTC", 0x0bb4, "HTC One M8 (Verizon) (HTC6525LVW)", 0x07cb,
-      DEVICE_FLAG_NONE },
-  /* https://sourceforge.net/p/libmtp/bugs/1133/ */
-  { "HTC", 0x0bb4, "HTC One Remix (HTC6515LVW)", 0x07d9,
-      DEVICE_FLAG_NONE },
-  // Reported by Markus Heberling
-  { "HTC", 0x0bb4, "Windows Phone 8X ID1", 0x0ba1,
-      DEVICE_FLAG_NONE },
-  { "HTC", 0x0bb4, "Windows Phone 8X ID2", 0x0ba2,
-      DEVICE_FLAG_NONE },
-
-#if 1
-  /* after some review I commented it back in. There was apparently
-   * only one or two devices misbehaving (having this ID in mass storage mode),
-   * but more seem to use it regulary as MTP devices. Marcus 20150401 */
-  /*
-   * This had to be commented out - the same VID+PID is used also for
-   * other modes than MTP, so we need to let mtp-probe do its job on this
-   * device instead of adding it to the database.
-   * used by various devices, like Fairphone, Elephone P5000, etc
-   * https://sourceforge.net/p/libmtp/bugs/1290/
-   */
-  { "HTC", 0x0bb4, "Android Device ID1 (Zopo, HD2, Bird...)", 0x0c02,
-      DEVICE_FLAGS_ANDROID_BUGS },
-#endif
-  { "HTC", 0x0bb4, "EVO 4G LTE/One V (ID1)", 0x0c93,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "EVO 4G LTE/One V (ID2)", 0x0ca8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One S (ID1)", 0x0cec,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "One Mini (ID1)", 0x0dcd,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One 802w (ID1)", 0x0dd2,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC Desire X", 0x0dd5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One (ID1)", 0x0dda,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC Butterfly X290d", 0x0de4,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One (MTP+UMS+ADB)", 0x0dea,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC Evo 4G LTE (ID1)", 0x0df5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One S (ID2)", 0x0df8,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One S (ID3)", 0x0df9,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One X (ID1)", 0x0dfa,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One X (ID2)", 0x0dfb,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One X (ID3)", 0x0dfc,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One X (ID4)", 0x0dfd,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC Butterfly (ID1)", 0x0dfe,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "Droid DNA (MTP+UMS+ADB)", 0x0dff,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC Droid Incredible 4G LTE (MTP)", 0x0e31,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC Droid Incredible 4G LTE (MTP+ADB)", 0x0e32,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "Droid DNA (MTP+UMS)", 0x0ebd,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1182/ */
-  { "HTC", 0x0bb4, "Desire 310 (MTP)", 0x0ec6,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1481/ */
-  { "HTC", 0x0bb4, "Desire 310 (2nd id) (MTP)", 0x0ec7,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1420/ */
-  { "HTC", 0x0bb4, "Desire 816G (MTP)", 0x0edb,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One (MTP+ADB+CDC)", 0x0f5f,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One (MTP+CDC)", 0x0f60,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One (MTP+ADB)", 0x0f63,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One (MTP)", 0x0f64,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One (MTP+ADB+?)", 0x0f87,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One (ID3)", 0x0f91,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One M8 (MTP)", 0x0f25,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One M8 (MTP+ADB)", 0x061a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One M8 (MTP+UMS)", 0x0fb5,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "HTC One M8 (MTP+ADB+UMS)", 0x0fb4,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-#if 1
-  /* after some review I commented it back in. There was apparently
-   * only one or two devices misbehaving (having this ID in mass storage mode),
-   * but more seem to use it regulary as MTP devices. Marcus 20150401 */
-  /*
-   * This had to be commented out - the same VID+PID is used also for
-   * other modes than MTP, so we need to let mtp-probe do its job on this
-   * device instead of adding it to the database.
-   *
-   * Apparently also used by a clone called Jiayu G2S
-   * with the MTK6577T chipset
-   * http://www.ejiayu.com/en/Product-19.html
-   * Wiko Cink Peax 2
-   */
-  { "HTC", 0x0bb4, "Android Device ID2 (Zopo, HD2...)", 0x2008,
-      DEVICE_FLAGS_ANDROID_BUGS },
-#endif
-  /* https://sourceforge.net/p/libmtp/bugs/1198/ */
-  { "HTC", 0x0bb4, "Motorola Razr D1", 0x2012,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1440/ */
-  { "HTC", 0x0bb4, "Motorola P98 4G", 0x201d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1508/ */
-  { "HTC", 0x0bb4, "One M9 (3rd ID)", 0x4ee1,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/217/ */
-  { "HTC", 0x0bb4, "One M9 (4th ID)", 0x4ee2,
+  // Reported by Steven Eastland <grassmonk@users.sourceforge.net>
+  { "HTC", 0x0bb4, "EVO 4G LTE (second ID)", 0x0ca8,
       DEVICE_FLAGS_ANDROID_BUGS },
   // These identify themselves as "cm_tenderloin", fun...
   // Done by HTC for HP I guess.
-  { "HTC (for Hewlett-Packard)", 0x0bb4, "HP Touchpad (MTP)", 0x685c,
+  { "Hewlett-Packard", 0x0bb4, "HP Touchpad", 0x685c,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC (for Hewlett-Packard)", 0x0bb4, "HP Touchpad (MTP+ADB)", 0x6860,
+  { "Hewlett-Packard", 0x0bb4, "HP Touchpad (debug mode)",
+      0x6860, DEVICE_FLAGS_ANDROID_BUGS },
+  // Reported by anonymous SourceForge user
+  { "HTC", 0x0bb4, "Zopo ZP100 (ID2)", 0x2008,
       DEVICE_FLAGS_ANDROID_BUGS },
-  { "HTC", 0x0bb4, "Windows Phone 8s ID1", 0xf0ca,
-      DEVICE_FLAG_NONE },
 
   /*
    * NEC
    */
   { "NEC", 0x0409, "FOMA N01A", 0x0242, DEVICE_FLAG_NONE },
-  { "NEC", 0x0409, "Casio C811", 0x0326, DEVICE_FLAG_NONE },
-  { "NEC", 0x0409, "Casio CA-201L", 0x0432, DEVICE_FLAG_NONE },
 
   /*
    * nVidia
    */
   // Found on Internet forum
-  { "nVidia", 0x0955, "CM9-Adam", 0x70a9,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  // Various pads such as Nabi2, Notion Ink Adam, Viewsonic G-Tablet
-  { "nVidia", 0x0955, "Various tablets (ID1)", 0x7100,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "nVidia", 0x0955, "Various tablets (ID2)", 0x7102,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1582/ */
-  { "nVidia", 0x0955, "Jetson TX1", 0x7721,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "nVidia", 0x0955, "Shield (ID1)", 0xb400,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1447/ */
-  { "nVidia", 0x0955, "Shield (Tegra4)", 0xb401,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1087/ */
-  { "nVidia", 0x0955, "Tegra Note", 0xcf02,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* benpro82@gmail.com */
-  { "nVidia", 0x0955, "Shield (ID2)", 0xcf07,
-      DEVICE_FLAGS_ANDROID_BUGS },
+  { "nVidia", 0x0955, "CM9-Adam", 0x70a9, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
    * Vizio
-   * Reported by:
-   * Michael Gurski <gurski@users.sourceforge.net>
    */
-  /* https://sourceforge.net/p/libmtp/support-requests/221/ */
-  { "Nokia", 0x0489, "N1", 0x1ab0,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1567/ */
-  { "InFocus", 0x0489, "M808", 0xc00b,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/138/ */
-  { "InFocus", 0x0489, "M810", 0xc025,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Vizio", 0x0489, "Unknown 1", 0xc026,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Vizio", 0x0489, "VTAB1008", 0xe040,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Vizio (for Lenovo)", 0x0489, "LIFETAB S9714", 0xe111,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
+  // Reported by Michael Gurski <gurski@users.sourceforge.net>
+  { "Vizio", 0x0489, "VTAB1008", 0xe040, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
-   * Amazon
+   * Viewpia, bq...
+   * Seems like some multi-branded OEM product.
    */
-  { "Amazon", 0x1949, "Kindle Fire 2G (ID1)", 0x0005,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Amazon", 0x1949, "Kindle Fire (ID1)", 0x0007,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Amazon", 0x1949, "Kindle Fire (ID2)", 0x0008,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Amazon", 0x1949, "Kindle Fire (ID3)", 0x000a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1026/ */
-  { "Amazon", 0x1949, "Kindle Fire (ID6)", 0x000b,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Amazon", 0x1949, "Kindle Fire (ID4)", 0x000c,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1015/ */
-  { "Amazon", 0x1949, "Kindle Fire (ID7)", 0x000d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Amazon", 0x1949, "Kindle Fire (ID5)", 0x0012,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1353/ */
-  { "Amazon", 0x1949, "Kindle Fire HD6", 0x00f2,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1460/ */
-  { "Amazon", 0x1949, "Kindle Fire 8", 0x0211,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/158/ */
-  { "Amazon", 0x1949, "Kindle Fire 8 HD", 0x0212,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1448/ */
-  { "Amazon", 0x1949, "Kindle Fire 7", 0x0221,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1491/ */
-  { "Amazon", 0x1949, "Kindle Fire 5", 0x0222,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Amazon", 0x1949, "Fire Phone", 0x0800,
-      DEVICE_FLAGS_ANDROID_BUGS },
+  { "Various", 0x2207, "Viewpia DR/bq Kepler", 0x0001, DEVICE_FLAGS_ANDROID_BUGS },
 
   /*
-   * Barnes&Noble
-   */
-  { "Barnes&Noble", 0x2080, "Nook HD+", 0x0005,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Barnes&Noble", 0x2080, "Nook HD", 0x0006,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1504/ */
-  { "Barnes&Noble", 0x2080, "Nook Glowlight+", 0x000a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Viewpia, bq, YiFang
-   * Seems like some multi-branded OEM product line.
-   */
-  { "Various", 0x2207, "Viewpia DR/bq Kepler", 0x0001,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "YiFang", 0x2207, "BQ Tesla", 0x0006,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1354/ */
-  { "Various", 0x2207, "Viewpia DR/bq Kepler Debugging", 0x0011,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Kobo
-   */
-  /* https://sourceforge.net/p/libmtp/bugs/1208/ */
-  { "Kobo", 0x2237, "Arc 7 HD", 0xb108,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  // Reported by George Talusan
-  { "Kobo", 0x2237, "Arc (ID1)", 0xd108,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Kobo", 0x2237, "Arc (ID2)", 0xd109,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Hisense
-   */
-  // Reported by Anonymous SourceForge users
-  { "Hisense", 0x109b, "E860 (ID1)", 0x9106, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Hisense", 0x109b, "E860 (ID2)", 0x9109, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Intel
-   * Also sold rebranded as Orange products
-   */
-  { "Intel", 0x8087, "Xolo 900/AZ210A", 0x09fb, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1256/ */
-  { "Intel", 0x8087, "Noblex T7A21", 0x0a16, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1252/ */
-  { "Intel", 0x8087, "Foxconn iView i700", 0x0a15, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1237/ */
-  { "Intel", 0x8087, "Telcast Air 3G", 0x0a5e, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1338/ */
-  { "Intel", 0x8087, "Chuwi vi8", 0x0a5f, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Xiaomi
-   */
-  /* https://sourceforge.net/p/libmtp/bugs/1269/ */
-  { "Xiaomi", 0x2717, "Mi-3w (MTP)", 0x0360,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Xiaomi", 0x2717, "Mi-3 (MTP)", 0x0368,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1149/ */
-  { "Xiaomi", 0x2717, "MiPad (MTP)", 0x0660,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1489/ */
-  { "Xiaomi", 0x2717, "MiPad (MTP+ADB)", 0x0668,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Xiaomi", 0x2717, "Hongmi (MTP+ADB)", 0x1240,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1095/ */
-  { "Xiaomi", 0x2717, "Hongmi (MTP)", 0x1248,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1295/ */
-  { "Redmi", 0x2717, "1S (MTP)", 0x1260,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1164/ */
-  { "Redmi", 0x2717, "HM 1S (MTP)", 0x1268,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/discussion/535190/ */
-  { "Xiaomi", 0x2717, "HM NOTE 1LTEW MIUI (MTP)", 0x1368,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Xiaomi", 0x2717, "Mi-2 (MTP+ADB)", 0x9039,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Xiaomi", 0x2717, "Mi-2 (MTP)", 0xf003,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1397/ */
-  { "Xiaomi", 0x2717, "Mi-2s (id2) (MTP)", 0xff40,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1339/ */
-  { "Xiaomi", 0x2717, "Mi-2s (MTP)", 0xff48,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1402/ */
-  { "Xiaomi", 0x2717, "Redmi 2 (MTP)", 0xff60,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1445/ */
-  { "Xiaomi", 0x2717, "Redmi 2 2014811 (MTP)", 0xff68,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * XO Learning Tablet
-   * Also Trio Stealth G2 tablet it seems
-   */
-  { "Acromag Inc.", 0x16d5, "XO Learning Tablet (MTP+ADB)", 0x8005,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Acromag Inc.", 0x16d5, "XO Learning Tablet (MTP)", 0x8006,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * SHARP Corporation
-   */
-  { "SHARP Corporation", 0x0489, "SH930W", 0xc025,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SHARP Corporation", 0x04dd, "SBM203SH", 0x9661,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "SHARP Corporation", 0x04dd, "SH-06E", 0x96ca,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * T & A Mobile phones Alcatel and TCT
-   */
-  { "Alcatel", 0x1bbb, "One Touch 997D (MTP+ADB)", 0x0c02,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Alcatel", 0x1bbb, "One Touch 997D (MTP)", 0x2008,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Alcatel/TCT", 0x1bbb, "6010D/TCL S950", 0x0167,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Alcatel", 0x1bbb, "6030a", 0x0168,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Alcatel/Bouygues", 0x1bbb, "BS472", 0x904d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1304/ */
-  { "Alcatel", 0x1bbb, "OneTouch 5042D (MTP)", 0xa00e,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/189/ */
-  { "Alcatel", 0x1bbb, "OneTouch Idol 3 small (MTP)", 0xaf2a,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1401/ */
-  { "Alcatel", 0x1bbb, "OneTouch Idol 3 (MTP)", 0xaf2b,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/114/ */
-  { "Alcatel", 0x1bbb, "OneTouch 6034R", 0xf003,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Kyocera
-   */
-  { "Kyocera", 0x0482, "Rise", 0x0571, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1492/ */
-  { "Kyocera", 0x0482, "Event", 0x0591, DEVICE_FLAGS_ANDROID_BUGS  & ~DEVICE_FLAG_FORCE_RESET_ON_CLOSE },
-  /* https://sourceforge.net/p/libmtp/feature-requests/134/ */
-  { "Kyocera", 0x0482, "Torque Model E6715", 0x0059a, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/164/ */
-  { "Kyocera", 0x0482, "Hydro Elite C6750", 0x073c, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/discussion/535190/thread/6270f5ce/ */
-  { "Kyocera", 0x0482, "KYL22", 0x0810, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1518/ */
-  { "Kyocera", 0x0482, "302KC", 0x09fc, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1345/ */
-  { "Kyocera", 0x0482, "DuraForce", 0x0979, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1476/ */
-  { "Kyocera", 0x0482, "KC-S701", 0x09cb, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * HiSense
-   */
-  { "HiSense", 0x109b, "Sero 7 Pro", 0x9105,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Hewlett-Packard
-   */
-  { "Hewlett-Packard", 0x03f0, "Slate 7 4600", 0x5c1d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "Hewlett-Packard", 0x03f0, "Slate 7 2800", 0x5d1d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1366/ */
-  { "Hewlett-Packard", 0x03f0, "Slate 10 HD", 0x7e1d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * MediaTek Inc.
-   */
-  { "MediaTek Inc", 0x0e8d, "MT5xx and MT6xx SoCs", 0x0050,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1553/ */
-  { "Bravis", 0x0e8d, "A401 Neo", 0x0c03,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1422/ */
-  { "MediaTek Inc", 0x0e8d, "MT65xx", 0x2008,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1467/ */
-  { "elephone", 0x0e8d, "p6000", 0x2008,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/79/ */
-  { "MediaTek Inc", 0x0e8d, "Elephone P8000", 0x201d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Jolla
-   */
-  { "Jolla", 0x2931, "Sailfish (ID1)", 0x0a01,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* In update 4 the order of devices was changed for
-     better OS X / Windows suport and another device-id
-     got assigned for the MTP */
-  { "Jolla", 0x2931, "Sailfish (ID2)", 0x0a05,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* In a later version, the ID changed again. */
-  { "Jolla", 0x2931, "Sailfish (ID3)", 0x0a07,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * TCL? Alcatel?
-   */
-  { "TCL", 0x0451, "Alcatel one touch 986+", 0xd108,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Garmin
-   */
-  { "Garmin", 0x091e, "Monterra", 0x2585,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Wacom
-   */
-  { "Wacom", 0x0531, "Cintiq Companion Hybrid (MTP+ADB)", 0x2001,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * Kurio
-   */
-  { "Kurio", 0x1f3a, "7S", 0x1006,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1521/ */
-  { "iRulu", 0x1f3a, "X1s", 0x1007,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1245/ */
-  { "DigiLand", 0x1f3a, "DL701Q", 0x0c02,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * bq
-   * https://sourceforge.net/p/libmtp/feature-requests/128/
-   */
-  { "bq", 0x2a47, "Krillin (MTP)", 0x2008,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/163/ */
-  { "bq", 0x2a47, "Aquaris M10 (MTP)", 0x200d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1558/ */
-  { "bq", 0x2a47, "Avila Cooler (MTP)", 0x201d,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  { "bq", 0x2a47, "Krillin (MTP+ADB)", 0x0c02,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1311/ */
-  { "bq", 0x2a47, "Aquarius E5-4G", 0x7f10,
-      DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1541/ */
-  { "bq", 0x2a47, "Aquarius M5.5", 0x901b,
-      DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1292/ */
-  { "Prestigio", 0x29e4, "5505 DUO ", 0x1103, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1243/ */
-  { "Prestigio", 0x29e4, "5504 DUO ", 0x1203, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/141/ */
-  { "Prestigio", 0x29e4, "3405 DUO ", 0x3201, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/148/ */
-  { "Prestigio", 0x29e4, "Multipad Color 7.0", 0xb003, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1283/ */
-  { "Megafon", 0x201e, "MFLogin3T", 0x42ab, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/208/ */
-  { "Haier", 0x201e, "CT715", 0xa0c1, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1287/ */
-  { "Gensis", 0x040d, "GT-7305 ", 0x885c, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/support-requests/182/ */
-  { "Oppo", 0x22d9, "Find 5", 0x2764, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1207/ */
-  { "Oppo", 0x22d9, "Find 7 (ID 1)", 0x2765, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1277/ */
-  { "Oppo", 0x22d9, "X9006", 0x2773, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/129/ */
-  { "Oppo", 0x22d9, "Find 7 (ID 2)", 0x2774, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1273/ */
-  { "Gigabyte", 0x0414, "RCT6773W22 (MTP+ADB)", 0x0c02, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Gigabyte", 0x0414, "RCT6773W22 (MTP)", 0x2008, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1264/ */
-  { "Meizu", 0x2a45, "MX Phone (MTP)", 0x2008, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1263/ */
-  { "Meizu", 0x2a45, "MX Phone (MTP+ADB)", 0x0c02, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1201/ */
-  { "Caterpillar", 0x04b7, "Cat S50", 0x88a9, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1525/ */
-  { "Caterpillar", 0x04b7, "Cat S50 (2nd ID)", 0x88aa, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/682/ */
-  { "Pegatron", 0x1d4d, "Chagall (ADB)", 0x5035, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Pegatron", 0x1d4d, "Chagall", 0x5036, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/115/ */
-  { "Pegatron", 0x1d4d, "Hudl 2", 0x504a, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/support-requests/127/ */
-  { "Yota", 0x2916, "Phone C9660", 0x9039, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1229/ */
-  { "Yota", 0x2916, "Phone 2", 0x914d, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1267/ */
-  { "Yota", 0x2916, "Phone 2 (ID2)", 0xf003, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1212/ */
-  { "Fly", 0x2970, "Evo Tech 4", 0x2008, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/feature-requests/146/ */
-  { "Wileyfox", 0x2970, "Swift", 0x2281, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/feature-requests/159/ */
-  { "Wileyfox", 0x2970, "Swift 2", 0x2282, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1554/ */
-  { "Kazam", 0x2970, "Trooper 650 4G", 0x9039, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1303/ */
-  { "Megafon", 0x1271, "Login+", 0x2012, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1127/ */
-  { "Fly", 0x2970, "iq4415 era style 3", 0x0c02, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1082/ */
-  { "Fly", 0x1782, "iq449", 0x4001, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-  * YU Yureka.
-  */
-  { "YU Yureka", 0x1ebf, "Vodafone smart turbo 4", 0x7f29, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1314/ */
-  { "BenQ", 0x1d45, "F5", 0x459d, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1362/ */
-  { "TomTom", 0x1390, "Rider 40", 0x5455, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/feature-requests/135/. guessed android. */
-  { "OUYA", 0x2836, "Videogame Console", 0x0010, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1383/ */
-  { "BLU", 0x0e8d, "Studio HD", 0x2008, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/feature-requests/161/ */
-  { "Cubot", 0x0e8d, "X17", 0x201d, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1423/ */
-  { "OnePlus", 0x2a70, "ONE A2001", 0x9011, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1450/ */
-  { "OnePlus", 0x2a70, "OnePlus 2 A2005", 0xf003, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1436/ */
-  { "Parrot", 0x19cf, "Bebop Drone", 0x5038, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*
-   * GoPro Action Cams.
-   */
-  { "GoPro" , 0x2672, "HERO3+ Black", 0x0011, DEVICE_FLAG_NONE },
-  { "GoPro" , 0x2672, "HERO", 0x000c, DEVICE_FLAG_NONE },  
-  { "GoPro" , 0x2672, "HERO4 Silver", 0x000d, DEVICE_FLAG_NONE },
-  { "Gopro" , 0x2672, "HERO4 Black", 0x000e, DEVICE_FLAG_NONE },
-  { "GoPro" , 0x2672, "HERO4 Session", 0x000f, DEVICE_FLAG_NONE },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1490/ */
-  { "Marshall" , 0x2ad9, "London", 0x000b, DEVICE_FLAG_NONE },
-
-  /* https://sourceforge.net/p/libmtp/support-requests/202/ */
-  { "Fairphone" , 0x2ae5, "Fairphone 2", 0xf003, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/214/ */
-  { "Fairphone" , 0x2ae5, "Fairphone 2 OS", 0x9039, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /*  https://sourceforge.net/p/libmtp/bugs/1512/ */
-  { "Allview" , 0x271d, "Energy P5", 0x4016, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1575/ */
-  { "Blu" , 0x271d, "Studio Energy 2", 0x4016, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1545/ */
-  { "Zuk" , 0x2b4c, "Z1", 0x1004, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1574/ */
-  { "Letv" , 0x2b0e, "X5001s", 0x1700, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/210/ */
-  { "Letv" , 0x2b0e, "1s", 0x1704, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/support-requests/220/ */
-  { "Letv" , 0x2b0e, "X800 (ID1)", 0x182c, DEVICE_FLAGS_ANDROID_BUGS },
-  { "Letv" , 0x2b0e, "X800 (ID2)", 0x1830, DEVICE_FLAGS_ANDROID_BUGS },
-
-  /* https://sourceforge.net/p/libmtp/bugs/1570/ */
-  { "Recon Instruments" , 0x2523, "Jet", 0xd209, DEVICE_FLAGS_ANDROID_BUGS },
-  /* https://sourceforge.net/p/libmtp/bugs/1571/ */
-  { "Recon Instruments" , 0x2523, "Snow2 HUD", 0xd109, DEVICE_FLAGS_ANDROID_BUGS },
-  /*
    * Other strange stuff.
    */
   { "Isabella", 0x0b20, "Her Prototype", 0xddee, DEVICE_FLAG_NONE }
diff --git a/src/playlist-spl.c b/src/playlist-spl.c
index 5a6a3b0..2942b4c 100644
--- a/src/playlist-spl.c
+++ b/src/playlist-spl.c
@@ -615,7 +615,6 @@
     if(f != NULL) {
       append_text_t(&c, f);
       LIBMTP_PLST_DEBUG("track %d = %s (%u)\n", i+1, f, tracks[i]);
-      free(f);
     }
     else
       LIBMTP_ERROR("failed to find filepath for track=%d\n", tracks[i]);
diff --git a/src/ptp-pack.c b/src/ptp-pack.c
index ea6bfc9..5bf90e0 100644
--- a/src/ptp-pack.c
+++ b/src/ptp-pack.c
@@ -1,7 +1,7 @@
 /* ptp-pack.c
  *
  * Copyright (C) 2001-2004 Mariusz Woloszyn <emsi@ipartners.pl>
- * Copyright (C) 2003-2014 Marcus Meissner <marcus@jet.franken.de>
+ * Copyright (C) 2003-2012 Marcus Meissner <marcus@jet.franken.de>
  * Copyright (C) 2006-2008 Linus Walleij <triad@df.lth.se>
  * Copyright (C) 2007 Tero Saarni <tero.saarni@gmail.com>
  * Copyright (C) 2009 Axel Waggershauser <awagger@web.de>
@@ -18,19 +18,13 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA  02110-1301  USA
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
  */
 
 /* currently this file is included into ptp.c */
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#ifndef UINT_MAX
-# define UINT_MAX 0xFFFFFFFF
-#endif
-#if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
+#ifdef HAVE_ICONV
 #include <iconv.h>
 #endif
 
@@ -152,7 +146,7 @@
 	dest = loclstr;
 	destlen = sizeof(loclstr)-1;
 	nconv = (size_t)-1;
-#if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
+#ifdef HAVE_ICONV
 	if (params->cd_ucs2_to_locale != (iconv_t)-1)
 		nconv = iconv(params->cd_ucs2_to_locale, &src, &srclen, &dest, &destlen);
 #endif
@@ -193,7 +187,7 @@
 
 	/* Cannot exceed 255 (PTP_MAXSTRLEN) since it is a single byte, duh ... */
 	memset(ucs2strp, 0, sizeof(ucs2str));  /* XXX: necessary? */
-#if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
+#ifdef HAVE_ICONV
 	if (params->cd_locale_to_ucs2 != (iconv_t)-1) {
 		size_t nconv;
 		size_t convmax = PTP_MAXSTRLEN * 2; /* Includes the terminator */
@@ -206,8 +200,7 @@
 	} else
 #endif
 	{
-		unsigned int i;
-
+		int i;
 		for (i=0;i<convlen;i++) {
 			ucs2str[i] = string[i];
 		}
@@ -258,31 +251,16 @@
 }
 
 static inline uint32_t
-ptp_unpack_uint32_t_array(PTPParams *params, unsigned char* data, unsigned int offset, unsigned int datalen, uint32_t **array)
+ptp_unpack_uint32_t_array(PTPParams *params, unsigned char* data, uint16_t offset, uint32_t **array)
 {
 	uint32_t n, i=0;
 
-	if (offset >= datalen)
-		return 0;
-
-	if (offset + sizeof(uint32_t) > datalen)
-		return 0;
-
-	*array = NULL;
 	n=dtoh32a(&data[offset]);
-	if (n >= UINT_MAX/sizeof(uint32_t))
-		return 0;
-	if (!n)
-		return 0;
-
-	if (offset + sizeof(uint32_t)*(n+1) > datalen) {
-		ptp_debug (params ,"array runs over datalen bufferend (%d vs %d)", offset + sizeof(uint32_t)*(n+1) , datalen);
-		return 0;
-	}
-
 	*array = malloc (n*sizeof(uint32_t));
-	for (i=0;i<n;i++)
+	while (n>i) {
 		(*array)[i]=dtoh32a(&data[offset+(sizeof(uint32_t)*(i+1))]);
+		i++;
+	}
 	return n;
 }
 
@@ -299,25 +277,16 @@
 }
 
 static inline uint32_t
-ptp_unpack_uint16_t_array(PTPParams *params, unsigned char* data, unsigned int offset, unsigned int datalen, uint16_t **array)
+ptp_unpack_uint16_t_array(PTPParams *params, unsigned char* data, uint16_t offset, uint16_t **array)
 {
 	uint32_t n, i=0;
 
-	*array = NULL;
 	n=dtoh32a(&data[offset]);
-	if (n >= UINT_MAX/sizeof(uint16_t))
-		return 0;
-	if (!n)
-		return 0;
-	if (offset + sizeof(uint32_t) > datalen)
-		return 0;
-	if (offset + sizeof(uint32_t)+sizeof(uint16_t)*n > datalen) {
-		ptp_debug (params ,"array runs over datalen bufferend (%d vs %d)", offset + sizeof(uint32_t)+n*sizeof(uint16_t) , datalen);
-		return 0;
-	}
 	*array = malloc (n*sizeof(uint16_t));
-	for (i=0;i<n;i++)
+	while (n>i) {
 		(*array)[i]=dtoh16a(&data[offset+(sizeof(uint16_t)*(i+2))]);
+		i++;
+	}
 	return n;
 }
 
@@ -351,28 +320,23 @@
 		dtoh16a(&data[PTP_di_FunctionalMode+totallen]);
 	di->OperationsSupported_len = ptp_unpack_uint16_t_array(params, data,
 		PTP_di_OperationsSupported+totallen,
-		datalen,
 		&di->OperationsSupported);
 	totallen=totallen+di->OperationsSupported_len*sizeof(uint16_t)+sizeof(uint32_t);
 	di->EventsSupported_len = ptp_unpack_uint16_t_array(params, data,
 		PTP_di_OperationsSupported+totallen,
-		datalen,
 		&di->EventsSupported);
 	totallen=totallen+di->EventsSupported_len*sizeof(uint16_t)+sizeof(uint32_t);
 	di->DevicePropertiesSupported_len =
 		ptp_unpack_uint16_t_array(params, data,
 		PTP_di_OperationsSupported+totallen,
-		datalen,
 		&di->DevicePropertiesSupported);
 	totallen=totallen+di->DevicePropertiesSupported_len*sizeof(uint16_t)+sizeof(uint32_t);
 	di->CaptureFormats_len = ptp_unpack_uint16_t_array(params, data,
 		PTP_di_OperationsSupported+totallen,
-		datalen,
 		&di->CaptureFormats);
 	totallen=totallen+di->CaptureFormats_len*sizeof(uint16_t)+sizeof(uint32_t);
 	di->ImageFormats_len = ptp_unpack_uint16_t_array(params, data,
 		PTP_di_OperationsSupported+totallen,
-		datalen,
 		&di->ImageFormats);
 	totallen=totallen+di->ImageFormats_len*sizeof(uint16_t)+sizeof(uint32_t);
 	di->Manufacturer = ptp_unpack_string(params, data,
@@ -392,44 +356,44 @@
 		&len);
 }
 
-inline static void
+static void inline
 ptp_free_DI (PTPDeviceInfo *di) {
-	free (di->SerialNumber);
-	free (di->DeviceVersion);
-	free (di->Model);
-	free (di->Manufacturer);
-	free (di->ImageFormats);
-	free (di->CaptureFormats);
-	free (di->VendorExtensionDesc);
-	free (di->OperationsSupported);
-	free (di->EventsSupported);
-	free (di->DevicePropertiesSupported);
+	if (di->SerialNumber) free (di->SerialNumber);
+	if (di->DeviceVersion) free (di->DeviceVersion);
+	if (di->Model) free (di->Model);
+	if (di->Manufacturer) free (di->Manufacturer);
+	if (di->ImageFormats) free (di->ImageFormats);
+	if (di->CaptureFormats) free (di->CaptureFormats);
+	if (di->VendorExtensionDesc) free (di->VendorExtensionDesc);
+	if (di->OperationsSupported) free (di->OperationsSupported);
+	if (di->EventsSupported) free (di->EventsSupported);
+	if (di->DevicePropertiesSupported) free (di->DevicePropertiesSupported);
 }
 
 /* EOS Device Info unpack */
 static inline void
 ptp_unpack_EOS_DI (PTPParams *params, unsigned char* data, PTPCanonEOSDeviceInfo *di, unsigned int datalen)
 {
-	unsigned int totallen = 4;
+	int totallen = 4;
 
 	memset (di,0, sizeof(*di));
 	if (datalen < 8) return;
 
 	/* uint32_t struct len - ignore */
 	di->EventsSupported_len = ptp_unpack_uint32_t_array(params, data,
-		totallen, datalen, &di->EventsSupported);
+		totallen, &di->EventsSupported);
 	if (!di->EventsSupported) return;
 	totallen += di->EventsSupported_len*sizeof(uint32_t)+4;
 	if (totallen >= datalen) return;
 
 	di->DevicePropertiesSupported_len = ptp_unpack_uint32_t_array(params, data,
-		totallen, datalen, &di->DevicePropertiesSupported);
+		totallen, &di->DevicePropertiesSupported);
 	if (!di->DevicePropertiesSupported) return;
 	totallen += di->DevicePropertiesSupported_len*sizeof(uint32_t)+4;
 	if (totallen >= datalen) return;
 
 	di->unk_len = ptp_unpack_uint32_t_array(params, data,
-		totallen, datalen, &di->unk);
+		totallen, &di->unk);
 	if (!di->unk) return;
 	totallen += di->unk_len*sizeof(uint32_t)+4;
 	return;
@@ -451,7 +415,7 @@
 ptp_unpack_OH (PTPParams *params, unsigned char* data, PTPObjectHandles *oh, unsigned int len)
 {
 	if (len) {
-		oh->n = ptp_unpack_uint32_t_array(params, data, PTP_oh, len, &oh->Handler);
+		oh->n = ptp_unpack_uint32_t_array(params, data, PTP_oh, &oh->Handler);
 	} else {
 		oh->n = 0;
 		oh->Handler = NULL;
@@ -465,12 +429,13 @@
 static inline void
 ptp_unpack_SIDs (PTPParams *params, unsigned char* data, PTPStorageIDs *sids, unsigned int len)
 {
-	if (!data || !len) {
+        if (!data && !len) {
 		sids->n = 0;
 		sids->Storage = NULL;
 		return;
         }
-	sids->n = ptp_unpack_uint32_t_array(params, data, PTP_sids, len, &sids->Storage);
+	sids->n = ptp_unpack_uint32_t_array(params, data, PTP_sids,
+	&sids->Storage);
 }
 
 /* StorageInfo pack/unpack */
@@ -488,15 +453,12 @@
 {
 	uint8_t storagedescriptionlen;
 
-	if (len < 26) return;
 	si->StorageType=dtoh16a(&data[PTP_si_StorageType]);
 	si->FilesystemType=dtoh16a(&data[PTP_si_FilesystemType]);
 	si->AccessCapability=dtoh16a(&data[PTP_si_AccessCapability]);
 	si->MaxCapability=dtoh64a(&data[PTP_si_MaxCapability]);
 	si->FreeSpaceInBytes=dtoh64a(&data[PTP_si_FreeSpaceInBytes]);
 	si->FreeSpaceInImages=dtoh32a(&data[PTP_si_FreeSpaceInImages]);
-
-	/* FIXME: check more lengths here */
 	si->StorageDescription=ptp_unpack_string(params, data,
 		PTP_si_StorageDescription, &storagedescriptionlen);
 	si->VolumeLabel=ptp_unpack_string(params, data,
@@ -642,12 +604,6 @@
 	uint8_t capturedatelen;
 	char *capture_date;
 
-	if (len < PTP_oi_SequenceNumber)
-		return;
-
-	oi->Filename = oi->Keywords = NULL;
-
-	/* FIXME: also handle length with all the strings at the end */
 	oi->StorageID=dtoh32a(&data[PTP_oi_StorageID]);
 	oi->ObjectFormat=dtoh16a(&data[PTP_oi_ObjectFormat]);
 	oi->ProtectionStatus=dtoh16a(&data[PTP_oi_ProtectionStatus]);
@@ -697,14 +653,12 @@
 }
 
 #define RARR(val,member,func)	{			\
-	unsigned int n,j;				\
+	int n,j;					\
 	if (total - *offset < sizeof(uint32_t))		\
 		return 0;				\
 	n = dtoh32a (&data[*offset]);			\
 	*offset += sizeof(uint32_t);			\
 							\
-	if (n >= UINT_MAX/sizeof(val->a.v[0]))		\
-		return 0;				\
 	val->a.count = n;				\
 	val->a.v = malloc(sizeof(val->a.v[0])*n);	\
 	if (!val->a.v) return 0;			\
@@ -712,9 +666,9 @@
 		CTVAL(val->a.v[j].member, func);	\
 }
 
-static inline unsigned int
+static inline int
 ptp_unpack_DPV (
-	PTPParams *params, unsigned char* data, unsigned int *offset, unsigned int total,
+	PTPParams *params, unsigned char* data, int *offset, int total,
 	PTPPropertyValue* value, uint16_t datatype
 ) {
 	switch (datatype) {
@@ -796,6 +750,7 @@
 }
 
 /* Device Property pack/unpack */
+
 #define PTP_dpd_DevicePropertyCode	0
 #define PTP_dpd_DataType		2
 #define PTP_dpd_GetSet			4
@@ -804,7 +759,7 @@
 static inline int
 ptp_unpack_DPD (PTPParams *params, unsigned char* data, PTPDevicePropDesc *dpd, unsigned int dpdlen)
 {
-	unsigned int offset = 0, ret;
+	int offset=0, ret;
 
 	memset (dpd, 0, sizeof(*dpd));
 	dpd->DevicePropertyCode=dtoh16a(&data[PTP_dpd_DevicePropertyCode]);
@@ -874,163 +829,7 @@
 	return 0;
 }
 
-/* Device Property pack/unpack */
-#define PTP_dpd_Sony_DevicePropertyCode	0
-#define PTP_dpd_Sony_DataType		2
-#define PTP_dpd_Sony_GetSet		4
-#define PTP_dpd_Sony_Unknown		5
-#define PTP_dpd_Sony_FactoryDefaultValue	6
-
-static inline int
-ptp_unpack_Sony_DPD (PTPParams *params, unsigned char* data, PTPDevicePropDesc *dpd, unsigned int dpdlen, unsigned int *poffset)
-{
-	unsigned int ret;
-#if 0
-	unsigned int unk1, unk2;
-#endif
-
-	memset (dpd, 0, sizeof(*dpd));
-	dpd->DevicePropertyCode=dtoh16a(&data[PTP_dpd_Sony_DevicePropertyCode]);
-	dpd->DataType=dtoh16a(&data[PTP_dpd_Sony_DataType]);
-
-#if 0
-	/* get set ? */
-	unk1 = dtoh8a(&data[PTP_dpd_Sony_GetSet]);
-	unk2 = dtoh8a(&data[PTP_dpd_Sony_Unknown]);
-	ptp_debug (params, "prop 0x%04x, datatype 0x%04x, unk1 %d unk2 %d", dpd->DevicePropertyCode, dpd->DataType, unk1, unk2);
-#endif
-	dpd->GetSet=1;
-
-	dpd->FormFlag=PTP_DPFF_None;
-
-	*poffset = PTP_dpd_Sony_FactoryDefaultValue;
-	ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FactoryDefaultValue, dpd->DataType);
-	if (!ret) goto outofmemory;
-	if ((dpd->DataType == PTP_DTC_STR) && (*poffset == dpdlen))
-		return 1;
-	ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->CurrentValue, dpd->DataType);
-	if (!ret) goto outofmemory;
-
-	/* if offset==0 then Data Type format is not supported by this
-	   code or the Data Type is a string (with two empty strings as
-	   values). In both cases Form Flag should be set to 0x00 and FORM is
-	   not present. */
-
-	if (*poffset==PTP_dpd_Sony_FactoryDefaultValue)
-		return 1;
-
-	dpd->FormFlag=dtoh8a(&data[*poffset]);
-	*poffset+=sizeof(uint8_t);
-
-	switch (dpd->FormFlag) {
-	case PTP_DPFF_Range:
-		ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FORM.Range.MinimumValue, dpd->DataType);
-		if (!ret) goto outofmemory;
-		ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FORM.Range.MaximumValue, dpd->DataType);
-		if (!ret) goto outofmemory;
-		ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FORM.Range.StepSize, dpd->DataType);
-		if (!ret) goto outofmemory;
-		break;
-	case PTP_DPFF_Enumeration: {
-		int i;
-#define N	dpd->FORM.Enum.NumberOfValues
-		N = dtoh16a(&data[*poffset]);
-		*poffset+=sizeof(uint16_t);
-		dpd->FORM.Enum.SupportedValue = malloc(N*sizeof(dpd->FORM.Enum.SupportedValue[0]));
-		if (!dpd->FORM.Enum.SupportedValue)
-			goto outofmemory;
-
-		memset (dpd->FORM.Enum.SupportedValue,0 , N*sizeof(dpd->FORM.Enum.SupportedValue[0]));
-		for (i=0;i<N;i++) {
-			ret = ptp_unpack_DPV (params, data, poffset, dpdlen, &dpd->FORM.Enum.SupportedValue[i], dpd->DataType);
-
-			/* Slightly different handling here. The HP PhotoSmart 120
-			 * specifies an enumeration with N in wrong endian
-			 * 00 01 instead of 01 00, so we count the enum just until the
-			 * the end of the packet.
-			 */
-			if (!ret) {
-				if (!i)
-					goto outofmemory;
-				dpd->FORM.Enum.NumberOfValues = i;
-				break;
-			}
-		}
-		}
-	}
-#undef N
-	return 1;
-outofmemory:
-	ptp_free_devicepropdesc(dpd);
-	return 0;
-}
-
-static inline void
-duplicate_PropertyValue (const PTPPropertyValue *src, PTPPropertyValue *dst, uint16_t type) {
-	if (type == PTP_DTC_STR) {
-		if (src->str)
-			dst->str = strdup(src->str);
-		else
-			dst->str = NULL;
-		return;
-	}
-
-	if (type & PTP_DTC_ARRAY_MASK) {
-		unsigned int i;
-
-		dst->a.count = src->a.count;
-		dst->a.v = malloc (sizeof(src->a.v[0])*src->a.count);
-		for (i=0;i<src->a.count;i++)
-			duplicate_PropertyValue (&src->a.v[i], &dst->a.v[i], type & ~PTP_DTC_ARRAY_MASK);
-		return;
-	}
-	switch (type & ~PTP_DTC_ARRAY_MASK) {
-	case PTP_DTC_INT8:	dst->i8 = src->i8; break;
-	case PTP_DTC_UINT8:	dst->u8 = src->u8; break;
-	case PTP_DTC_INT16:	dst->i16 = src->i16; break;
-	case PTP_DTC_UINT16:	dst->u16 = src->u16; break;
-	case PTP_DTC_INT32:	dst->i32 = src->i32; break;
-	case PTP_DTC_UINT32:	dst->u32 = src->u32; break;
-	case PTP_DTC_UINT64:	dst->u64 = src->u64; break;
-	case PTP_DTC_INT64:	dst->i64 = src->i64; break;
-#if 0
-	case PTP_DTC_INT128:	dst->i128 = src->i128; break;
-	case PTP_DTC_UINT128:	dst->u128 = src->u128; break;
-#endif
-	default:		break;
-	}
-	return;
-}
-
-static inline void
-duplicate_DevicePropDesc(const PTPDevicePropDesc *src, PTPDevicePropDesc *dst) {
-	int i;
-
-	dst->DevicePropertyCode	= src->DevicePropertyCode;
-	dst->DataType		= src->DataType;
-	dst->GetSet		= src->GetSet;
-	
-	duplicate_PropertyValue (&src->FactoryDefaultValue, &dst->FactoryDefaultValue, src->DataType);
-	duplicate_PropertyValue (&src->CurrentValue, &dst->CurrentValue, src->DataType);
-
-	dst->FormFlag		= src->FormFlag;
-	switch (src->FormFlag) {
-	case PTP_DPFF_Range:
-		duplicate_PropertyValue (&src->FORM.Range.MinimumValue, &dst->FORM.Range.MinimumValue, src->DataType);
-		duplicate_PropertyValue (&src->FORM.Range.MaximumValue, &dst->FORM.Range.MaximumValue, src->DataType);
-		duplicate_PropertyValue (&src->FORM.Range.StepSize,     &dst->FORM.Range.StepSize,     src->DataType);
-		break;
-	case PTP_DPFF_Enumeration:
-		dst->FORM.Enum.NumberOfValues = src->FORM.Enum.NumberOfValues;
-		dst->FORM.Enum.SupportedValue = malloc (sizeof(dst->FORM.Enum.SupportedValue[0])*src->FORM.Enum.NumberOfValues);
-		for (i = 0; i<src->FORM.Enum.NumberOfValues ; i++)
-			duplicate_PropertyValue (&src->FORM.Enum.SupportedValue[i], &dst->FORM.Enum.SupportedValue[i], src->DataType);
-		break;
-	case PTP_DPFF_None:
-		break;
-	}
-}
-
+/* (MTP) Object Property pack/unpack */
 #define PTP_opd_ObjectPropertyCode	0
 #define PTP_opd_DataType		2
 #define PTP_opd_GetSet			4
@@ -1039,7 +838,7 @@
 static inline int
 ptp_unpack_OPD (PTPParams *params, unsigned char* data, PTPObjectPropDesc *opd, unsigned int opdlen)
 {
-	unsigned int offset=0, ret;
+	int offset=0, ret;
 
 	memset (opd, 0, sizeof(*opd));
 	opd->ObjectPropertyCode=dtoh16a(&data[PTP_opd_ObjectPropertyCode]);
@@ -1066,7 +865,7 @@
 		if (!ret) goto outofmemory;
 		break;
 	case PTP_OPFF_Enumeration: {
-		unsigned int i;
+		int i;
 #define N	opd->FORM.Enum.NumberOfValues
 		N = dtoh16a(&data[offset]);
 		offset+=sizeof(uint16_t);
@@ -1105,7 +904,7 @@
 {
 	unsigned char* dpv=NULL;
 	uint32_t size=0;
-	unsigned int i;
+	int	i;
 
 	switch (datatype) {
 	case PTP_DTC_INT8:
@@ -1286,7 +1085,7 @@
 { 
 	uint32_t prop_count = dtoh32a(data);
 	MTPProperties *props = NULL;
-	unsigned int offset = 0, i;
+	int offset = 0, i;
 
 	if (prop_count == 0) {
 		*pprops = NULL;
@@ -1344,18 +1143,13 @@
 static inline void
 ptp_unpack_EC (PTPParams *params, unsigned char* data, PTPContainer *ec, unsigned int len)
 {
-	unsigned int	length;
+	int	length;
 	int	type;
 
 	if (data==NULL)
 		return;
 	memset(ec,0,sizeof(*ec));
-
 	length=dtoh32a(&data[PTP_ec_Length]);
-	if (length > len) {
-		ptp_debug (params, "length %d in container, but data only %d bytes?!", length, len);
-		return;
-	}
 	type = dtoh16a(&data[PTP_ec_Type]);
 
 	ec->Code=dtoh16a(&data[PTP_ec_Code]);
@@ -1446,8 +1240,7 @@
 0014  72 0c 74 92  OID
 0018  01 00 02 00  StorageID
 001c  01 38 00 00  OFC
-0020  00 00 00 00 ??
-0024  21 00 00 00  flags (4 bytes? 1 byte?)
+0020  00 00 00 00 00 00 00 00  ? 
 0028  19 d5 21 00  Size
 002c  00 00 74 92  ?
 0030  70 0c 74 92  OID
@@ -1460,7 +1253,7 @@
 #define PTP_cefe_ObjectHandle		0
 #define PTP_cefe_StorageID		4
 #define PTP_cefe_ObjectFormatCode	8
-#define PTP_cefe_Flags			16
+#define PTP_cefe_Flags			12
 #define PTP_cefe_ObjectSize		20
 #define PTP_cefe_Filename		32
 #define PTP_cefe_Time			48
@@ -1579,98 +1372,12 @@
 	return s;
 }
 
-/* 00: 32 bit size
- * 04: 16 bit subsize
- * 08: 16 bit version (?)
- * 0c: 16 bit focus_points_in_struct
- * 10: 16 bit focus_points_in_use
- * 14: variable arrays:
- * 	16 bit sizex, 16 bit sizey
- * 	16 bit othersizex, 16 bit othersizey
- * 	16 bit array height[focus_points_in_struct]
- * 	16 bit array width[focus_points_in_struct]
- * 	16 bit array offsetheight[focus_points_in_struct] middle is 0
- * 	16 bit array offsetwidth[focus_points_in_struct] middle is ?
- * bitfield of selected focus points, starting with 0 [size focus_points_in_struct in bits]
- * unknown stuff , likely which are active
- * 16 bit 0xffff
- *
- * size=NxN,size2=NxN,points={NxNxNxN,NxNxNxN,...},selected={0,1,2}
- */
-static inline char*
-ptp_unpack_EOS_FocusInfoEx (PTPParams* params, unsigned char** data )
-{
-	uint32_t size 			= dtoh32a( *data );
-	uint32_t halfsize		= dtoh16a( (*data) + 4);
-	uint32_t version		= dtoh16a( (*data) + 6);
-	uint32_t focus_points_in_struct	= dtoh16a( (*data) + 8);
-	uint32_t focus_points_in_use	= dtoh16a( (*data) + 10);
-	uint32_t sizeX			= dtoh16a( (*data) + 12);
-	uint32_t sizeY			= dtoh16a( (*data) + 14);
-	uint32_t size2X			= dtoh16a( (*data) + 16);
-	uint32_t size2Y			= dtoh16a( (*data) + 18);
-	uint32_t i;
-	uint32_t maxlen;
-	char	*str, *p;
-
-	/* every focuspoint gets 4 (16 bit number and a x) and a ,*/
-	/* inital things around lets say 100 chars at most. 
-	 * FIXME: check selected when we decode it */
-	maxlen = focus_points_in_use*6*4 + focus_points_in_use + 100;
-	if (halfsize != size-4) {
-		ptp_error(params, "halfsize %d is not expected %d", halfsize, size-4);
-		return "bad size";
-	}
-	if (20 + focus_points_in_struct*8 + (focus_points_in_struct+7)/8 > size) {
-		ptp_error(params, "size %d is too large for fp in struct %d", focus_points_in_struct*8 + 20 + (focus_points_in_struct+7)/8, size);
-		return "bad size 2";
-	}
-#if 0
-	ptp_debug(params,"d1d3 content:");
-	for (i=0;i<size;i+=2)
-		ptp_debug(params,"%d: %02x %02x", i, (*data)[i], (*data)[i+1]);
-#endif
-	ptp_debug(params,"d1d3 version", version);
-	ptp_debug(params,"d1d3 focus points in struct %d, in use %d", focus_points_in_struct, focus_points_in_use);
-
-	str = (char*)malloc( maxlen );
-	if (!str)
-		return NULL;
-	p = str;
-
-	p += sprintf(p,"eosversion=%d,size=%dx%d,size2=%dx%d,points={", version, sizeX, sizeY, size2X, size2Y);
-	for (i=0;i<focus_points_in_use;i++) {
-		int16_t x = dtoh16a((*data) + focus_points_in_struct*4 + 20 + 2*i);
-		int16_t y = dtoh16a((*data) + focus_points_in_struct*6 + 20 + 2*i);
-		int16_t w = dtoh16a((*data) + focus_points_in_struct*2 + 20 + 2*i);
-		int16_t h = dtoh16a((*data) + focus_points_in_struct*0 + 20 + 2*i);
-
-		p += sprintf(p,"{%d,%d,%d,%d}",x,y,w,h);
-
-		if (i<focus_points_in_use-1)
-			p += sprintf(p,",");
-	}
-	p += sprintf(p,"},select={");
-	for (i=0;i<focus_points_in_use;i++) {
-		if ((1<<(i%7)) & ((*data)[focus_points_in_struct*8+20+i/8]))
-			p+=sprintf(p,"%d,", i);
-	}
-
-	p += sprintf(p,"},unknown={");
-	for (i=focus_points_in_struct*8+(focus_points_in_struct+7)/8+20;i<size;i++) {
-		p+=sprintf(p,"%02x", (*data)[i]);
-	}
-	p += sprintf(p,"}");
-	return str;
-}
-
-
 static inline char*
 ptp_unpack_EOS_CustomFuncEx (PTPParams* params, unsigned char** data )
 {
 	uint32_t s = dtoh32a( *data );
 	uint32_t n = s/4, i;
-	char* str = (char*)malloc( s*2+s/4+1 ); /* n is size in uint32, maximum %x len is 8 chars and \0*/
+	char* str = (char*)malloc( s ); // n is size in uint32, average len(itoa(i)) < 4 -> alloc n chars
 	if (!str)
 		return str;
 	char* p = str;
@@ -1693,7 +1400,7 @@
 	for (i=0; i<n; i++)
 	{
 		v = strtoul(str, &str, 16);
-		str++; /* skip the ',' delimiter */
+		str++; // skip the ',' delimiter
 		htod32a(data + i*4, v);
 	}
 
@@ -1726,38 +1433,11 @@
 #define PTP_ece_OA_Parent	0x20
 #define PTP_ece_OA_Name		0x28
 
-static PTPDevicePropDesc*
-_lookup_or_allocate_canon_prop(PTPParams *params, uint16_t proptype)
-{
-	unsigned int j;
-
-	for (j=0;j<params->nrofcanon_props;j++)
-		if (params->canon_props[j].proptype == proptype)
-			break;
-	if (j<params->nrofcanon_props)
-		return &params->canon_props[j].dpd;
-
-	if (j)
-		params->canon_props = realloc(params->canon_props, sizeof(params->canon_props[0])*(j+1));
-	else
-		params->canon_props = malloc(sizeof(params->canon_props[0]));
-	params->canon_props[j].proptype = proptype;
-	params->canon_props[j].size = 0;
-	params->canon_props[j].data = NULL;
-	memset (&params->canon_props[j].dpd,0,sizeof(params->canon_props[j].dpd));
-	params->canon_props[j].dpd.GetSet = 1;
-	params->canon_props[j].dpd.FormFlag = PTP_DPFF_None;
-	params->nrofcanon_props = j+1;
-	return &params->canon_props[j].dpd;
-}
-
-
 static inline int
-ptp_unpack_CANON_changes (PTPParams *params, unsigned char* data, int datasize, PTPCanon_changes_entry **pce)
+ptp_unpack_CANON_changes (PTPParams *params, unsigned char* data, int datasize, PTPCanon_changes_entry **ce)
 {
 	int	i = 0, entries = 0;
 	unsigned char	*curdata = data;
-	PTPCanon_changes_entry *ce;
 
 	if (data==NULL)
 		return 0;
@@ -1765,56 +1445,49 @@
 		uint32_t	size = dtoh32a(&curdata[PTP_ece_Size]);
 		uint32_t	type = dtoh32a(&curdata[PTP_ece_Type]);
 
+		curdata += size;
 		if ((size == 8) && (type == 0))
 			break;
-		if (type == PTP_EC_CANON_EOS_OLCInfoChanged) {
-			unsigned int j;
-
-			for (j=0;j<31;j++)
-				if (dtoh32a(curdata+12) & (1<<j))
-					entries++;
-		}
-		curdata += size;
 		entries++;
 	}
-	ce = malloc (sizeof(PTPCanon_changes_entry)*(entries+1));
-	if (!ce) return 0;
+	*ce = malloc (sizeof(PTPCanon_changes_entry)*(entries+1));
+	if (!*ce) return 0;
 
 	curdata = data;
 	while (curdata - data < datasize) {
 		uint32_t	size = dtoh32a(&curdata[PTP_ece_Size]);
 		uint32_t	type = dtoh32a(&curdata[PTP_ece_Type]);
 
-		ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-		ce[i].u.info = NULL;
+		(*ce)[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
+		(*ce)[i].u.info = NULL;
 		switch (type) {
 		case  PTP_EC_CANON_EOS_ObjectAddedEx:
-			ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_OBJECTINFO;
-			ce[i].u.object.oid    		= dtoh32a(&curdata[PTP_ece_OA_ObjectID]);
-			ce[i].u.object.oi.StorageID 		= dtoh32a(&curdata[PTP_ece_OA_StorageID]);
-			ce[i].u.object.oi.ParentObject	= dtoh32a(&curdata[PTP_ece_OA_Parent]);
-			ce[i].u.object.oi.ObjectFormat 	= dtoh16a(&curdata[PTP_ece_OA_OFC]);
-			ce[i].u.object.oi.ObjectCompressedSize= dtoh32a(&curdata[PTP_ece_OA_Size]);
-			ce[i].u.object.oi.Filename 		= strdup(((char*)&curdata[PTP_ece_OA_Name]));
-			ptp_debug (params, "event %d: objectinfo added oid %08lx, parent %08lx, ofc %04x, size %d, filename %s", i, ce[i].u.object.oid, ce[i].u.object.oi.ParentObject, ce[i].u.object.oi.ObjectFormat, ce[i].u.object.oi.ObjectCompressedSize, ce[i].u.object.oi.Filename);
+			(*ce)[i].type = PTP_CANON_EOS_CHANGES_TYPE_OBJECTINFO;
+			(*ce)[i].u.object.oid    		= dtoh32a(&curdata[PTP_ece_OA_ObjectID]);
+			(*ce)[i].u.object.oi.StorageID 		= dtoh32a(&curdata[PTP_ece_OA_StorageID]);
+			(*ce)[i].u.object.oi.ParentObject	= dtoh32a(&curdata[PTP_ece_OA_Parent]);
+			(*ce)[i].u.object.oi.ObjectFormat 	= dtoh16a(&curdata[PTP_ece_OA_OFC]);
+			(*ce)[i].u.object.oi.ObjectCompressedSize= dtoh32a(&curdata[PTP_ece_OA_Size]);
+			(*ce)[i].u.object.oi.Filename 		= strdup(((char*)&curdata[PTP_ece_OA_Name]));
+			ptp_debug (params, "event %d: objectinfo added oid %08lx, parent %08lx, ofc %04x, size %d, filename %s", i, (*ce)[i].u.object.oid, (*ce)[i].u.object.oi.ParentObject, (*ce)[i].u.object.oi.ObjectFormat, (*ce)[i].u.object.oi.ObjectCompressedSize, (*ce)[i].u.object.oi.Filename);
 			break;
 		case  PTP_EC_CANON_EOS_RequestObjectTransfer:
-			ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_OBJECTTRANSFER;
-			ce[i].u.object.oid    		= dtoh32a(&curdata[PTP_ece_OI_ObjectID]);
-			ce[i].u.object.oi.StorageID 		= 0; /* use as marker */
-			ce[i].u.object.oi.ObjectFormat 	= dtoh16a(&curdata[PTP_ece_OI_OFC]);
-			ce[i].u.object.oi.ParentObject	= 0; /* check, but use as marker */
-			ce[i].u.object.oi.ObjectCompressedSize = dtoh32a(&curdata[PTP_ece_OI_Size]);
-			ce[i].u.object.oi.Filename 		= strdup(((char*)&curdata[PTP_ece_OI_Name]));
+			(*ce)[i].type = PTP_CANON_EOS_CHANGES_TYPE_OBJECTTRANSFER;
+			(*ce)[i].u.object.oid    		= dtoh32a(&curdata[PTP_ece_OI_ObjectID]);
+			(*ce)[i].u.object.oi.StorageID 		= 0; /* use as marker */
+			(*ce)[i].u.object.oi.ObjectFormat 	= dtoh16a(&curdata[PTP_ece_OI_OFC]);
+			(*ce)[i].u.object.oi.ParentObject	= 0; /* check, but use as marker */
+			(*ce)[i].u.object.oi.ObjectCompressedSize = dtoh32a(&curdata[PTP_ece_OI_Size]);
+			(*ce)[i].u.object.oi.Filename 		= strdup(((char*)&curdata[PTP_ece_OI_Name]));
 
-			ptp_debug (params, "event %d: request object transfer oid %08lx, ofc %04x, size %d, filename %p", i, ce[i].u.object.oid, ce[i].u.object.oi.ObjectFormat, ce[i].u.object.oi.ObjectCompressedSize, ce[i].u.object.oi.Filename);
+			ptp_debug (params, "event %d: request object transfer oid %08lx, ofc %04x, size %d, filename %s", i, (*ce)[i].u.object.oid, (*ce)[i].u.object.oi.ObjectFormat, (*ce)[i].u.object.oi.ObjectCompressedSize, (*ce)[i].u.object.oi.Filename);
 			break;
 		case  PTP_EC_CANON_EOS_AvailListChanged: {	/* property desc */
 			uint32_t	proptype = dtoh32a(&curdata[PTP_ece_Prop_Subtype]);
 			uint32_t	propxtype = dtoh32a(&curdata[PTP_ece_Prop_Desc_Type]);
 			uint32_t	propxcnt = dtoh32a(&curdata[PTP_ece_Prop_Desc_Count]);
 			unsigned char	*xdata = &curdata[PTP_ece_Prop_Desc_Data];
-			unsigned int	j;
+			int		j;
 			PTPDevicePropDesc	*dpd;
 
 			ptp_debug (params, "event %d: EOS prop %04x desc record, datasize %d, propxtype %d", i, proptype, size-PTP_ece_Prop_Desc_Data, propxtype);
@@ -1838,14 +1511,12 @@
 			}
 			if (! propxcnt)
 				break;
-			if (propxcnt >= 2<<16) /* buggy or exploit */
-				break;
 
 			ptp_debug (params, "event %d: propxtype is %x, prop is 0x%04x, data type is 0x%04x, propxcnt is %d.",
 				   i, propxtype, proptype, dpd->DataType, propxcnt);
 			dpd->FormFlag = PTP_DPFF_Enumeration;
 			dpd->FORM.Enum.NumberOfValues = propxcnt;
-			free (dpd->FORM.Enum.SupportedValue);
+			if (dpd->FORM.Enum.SupportedValue) free (dpd->FORM.Enum.SupportedValue);
 			dpd->FORM.Enum.SupportedValue = malloc (sizeof (PTPPropertyValue)*propxcnt);
 
 			switch (proptype) {
@@ -1856,7 +1527,7 @@
 				/* special handling of ImageFormat properties */
 				for (j=0;j<propxcnt;j++) {
 					dpd->FORM.Enum.SupportedValue[j].u16 =
-							ptp_unpack_EOS_ImageFormat( params, &xdata );
+							dtoh16( ptp_unpack_EOS_ImageFormat( params, &xdata ) );
 					ptp_debug (params, "event %d: suppval[%d] of %x is 0x%x.", i, j, proptype, dpd->FORM.Enum.SupportedValue[j].u16);
 				}
 				break;
@@ -1887,7 +1558,7 @@
 		}
 		case PTP_EC_CANON_EOS_PropValueChanged:
 			if (size >= 0xc) {	/* property info */
-				unsigned int j;
+				int j;
 				uint32_t	proptype = dtoh32a(&curdata[PTP_ece_Prop_Subtype]);
 				unsigned char	*xdata = &curdata[PTP_ece_Prop_Val_Data];
 				PTPDevicePropDesc	*dpd;
@@ -1907,6 +1578,7 @@
 						params->canon_props = realloc(params->canon_props, sizeof(params->canon_props[0])*(j+1));
 					else
 						params->canon_props = malloc(sizeof(params->canon_props[0]));
+					params->canon_props[j].type = type;
 					params->canon_props[j].proptype = proptype;
 					params->canon_props[j].size = size;
 					params->canon_props[j].data = malloc(size-PTP_ece_Prop_Val_Data);
@@ -1918,8 +1590,8 @@
 				}
 				dpd = &params->canon_props[j].dpd;
 
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY;
-				ce[i].u.propid = proptype;
+				(*ce)[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY;
+				(*ce)[i].u.propid = proptype;
 
 				/* fix GetSet value */
 				switch (proptype) {
@@ -1960,8 +1632,6 @@
 				/* set DataType */
 				switch (proptype) {
 				case PTP_DPC_CANON_EOS_CameraTime:
-				case PTP_DPC_CANON_EOS_UTCTime:
-				case PTP_DPC_CANON_EOS_Summertime: /* basical the DST flag */
 				case PTP_DPC_CANON_EOS_AvailableShots:
 				case PTP_DPC_CANON_EOS_CaptureDestination:
 				case PTP_DPC_CANON_EOS_WhiteBalanceXA:
@@ -1972,8 +1642,6 @@
 				case PTP_DPC_CANON_EOS_ModelID:
 				case PTP_DPC_CANON_EOS_LensID:
 				case PTP_DPC_CANON_EOS_StroboFiring:
-				case PTP_DPC_CANON_EOS_AFSelectFocusArea:
-				case PTP_DPC_CANON_EOS_ContinousAFMode:
 					dpd->DataType = PTP_DTC_UINT32;
 					break;
 				/* enumeration for AEM is never provided, but is available to set */
@@ -1996,14 +1664,12 @@
 				case PTP_DPC_CANON_EOS_QuickReviewTime:
 				case PTP_DPC_CANON_EOS_EVFMode:
 				case PTP_DPC_CANON_EOS_EVFOutputDevice:
-				case PTP_DPC_CANON_EOS_AutoPowerOff:
-				case PTP_DPC_CANON_EOS_EVFRecordStatus:
 					dpd->DataType = PTP_DTC_UINT16;
 					break;
 				case PTP_DPC_CANON_EOS_PictureStyle:
 				case PTP_DPC_CANON_EOS_WhiteBalance:
 				case PTP_DPC_CANON_EOS_MeteringMode:
-				case PTP_DPC_CANON_EOS_ExpCompensation:
+				case PTP_DPC_CANON_EOS_ExpCompensation: /* actually int8 if you calculate */
 					dpd->DataType = PTP_DTC_UINT8;
 					break;
 				case PTP_DPC_CANON_EOS_Owner:
@@ -2018,6 +1684,7 @@
 					dpd->DataType = PTP_DTC_INT16;
 					break;
 				/* unknown props, listed from dump.... all 16 bit, but vals might be smaller */
+				case 0xd114:
 				case PTP_DPC_CANON_EOS_DPOFVersion:
 					dpd->DataType = PTP_DTC_UINT16;
 					ptp_debug (params, "event %d: Unknown EOS property %04x, datasize is %d, using uint16", i ,proptype, size-PTP_ece_Prop_Val_Data);
@@ -2054,19 +1721,18 @@
 				case PTP_DPC_CANON_EOS_EVFWBMode:
 				case PTP_DPC_CANON_EOS_EVFClickWBCoeffs:
 				case PTP_DPC_CANON_EOS_EVFColorTemp:
+				case PTP_DPC_CANON_EOS_EVFRecordStatus:
 				case PTP_DPC_CANON_EOS_ExposureSimMode:
 				case PTP_DPC_CANON_EOS_LvAfSystem:
 				case PTP_DPC_CANON_EOS_MovSize:
 				case PTP_DPC_CANON_EOS_DepthOfField:
 				case PTP_DPC_CANON_EOS_LvViewTypeSelect:
-				case PTP_DPC_CANON_EOS_AloMode:
-				case PTP_DPC_CANON_EOS_Brightness:
 					dpd->DataType = PTP_DTC_UINT32;
 					ptp_debug (params, "event %d: Unknown EOS property %04x, datasize is %d, using uint32", i ,proptype, size-PTP_ece_Prop_Val_Data);
 					if ((size-PTP_ece_Prop_Val_Data) % sizeof(uint32_t) != 0)
 						ptp_debug (params, "event %d: Warning: datasize modulo sizeof(uint32) is not 0: ", i, (size-PTP_ece_Prop_Val_Data) % sizeof(uint32_t) );
 					for (j=0;j<(size-PTP_ece_Prop_Val_Data)/sizeof(uint32_t);j++)
-						ptp_debug (params, "    %d: 0x%8x", j, dtoh32a(xdata+j*4));
+						ptp_debug (params, "    %d: 0x%8x", j, ((uint32_t*)xdata)[j]);
 					break;
 				/* ImageFormat properties have to be ignored here, see special handling below */
 				case PTP_DPC_CANON_EOS_ImageFormat:
@@ -2074,7 +1740,6 @@
 				case PTP_DPC_CANON_EOS_ImageFormatSD:
 				case PTP_DPC_CANON_EOS_ImageFormatExtHD:
 				case PTP_DPC_CANON_EOS_CustomFuncEx:
-				case PTP_DPC_CANON_EOS_FocusInfoEx:
 					break;
 				default:
 					ptp_debug (params, "event %d: Unknown EOS property %04x, datasize is %d", i ,proptype, size-PTP_ece_Prop_Val_Data);
@@ -2088,11 +1753,6 @@
 					dpd->CurrentValue.u32		= dtoh32a(xdata);
 					ptp_debug (params ,"event %d: currentvalue of %x is %x", i, proptype, dpd->CurrentValue.u32);
 					break;
-				case PTP_DTC_INT16:
-					dpd->FactoryDefaultValue.i16	= dtoh16a(xdata);
-					dpd->CurrentValue.i16		= dtoh16a(xdata);
-					ptp_debug (params,"event %d: currentvalue of %x is %d", i, proptype, dpd->CurrentValue.i16);
-					break;
 				case PTP_DTC_UINT16:
 					dpd->FactoryDefaultValue.u16	= dtoh16a(xdata);
 					dpd->CurrentValue.u16		= dtoh16a(xdata);
@@ -2103,21 +1763,16 @@
 					dpd->CurrentValue.u8		= dtoh8a(xdata);
 					ptp_debug (params,"event %d: currentvalue of %x is %x", i, proptype, dpd->CurrentValue.u8);
 					break;
-				case PTP_DTC_INT8:
-					dpd->FactoryDefaultValue.i8	= dtoh8a(xdata);
-					dpd->CurrentValue.i8		= dtoh8a(xdata);
-					ptp_debug (params,"event %d: currentvalue of %x is %x", i, proptype, dpd->CurrentValue.i8);
-					break;
 				case PTP_DTC_STR: {
 #if 0 /* 5D MII and 400D aktually store plain ASCII in their string properties */
 					uint8_t len = 0;
 					dpd->FactoryDefaultValue.str	= ptp_unpack_string(params, data, 0, &len);
 					dpd->CurrentValue.str		= ptp_unpack_string(params, data, 0, &len);
 #else
-					free (dpd->FactoryDefaultValue.str);
+					if (dpd->FactoryDefaultValue.str) free (dpd->FactoryDefaultValue.str);
 					dpd->FactoryDefaultValue.str	= strdup( (char*)xdata );
 
-					free (dpd->CurrentValue.str);
+					if (dpd->CurrentValue.str) free (dpd->CurrentValue.str);
 					dpd->CurrentValue.str		= strdup( (char*)xdata );
 #endif
 					ptp_debug (params,"event %d: currentvalue of %x is %s", i, proptype, dpd->CurrentValue.str);
@@ -2141,233 +1796,20 @@
 					break;
 				case PTP_DPC_CANON_EOS_CustomFuncEx:
 					dpd->DataType = PTP_DTC_STR;
-					free (dpd->FactoryDefaultValue.str);
-					free (dpd->CurrentValue.str);
-					dpd->FactoryDefaultValue.str	= ptp_unpack_EOS_CustomFuncEx( params, &xdata );
+					if (dpd->FactoryDefaultValue.str) free (dpd->FactoryDefaultValue.str);
+					if (dpd->CurrentValue.str)	  free (dpd->CurrentValue.str);
+					dpd->FactoryDefaultValue.str	= ptp_unpack_EOS_CustomFuncEx( params, &data );
 					dpd->CurrentValue.str		= strdup( (char*)dpd->FactoryDefaultValue.str );
 					ptp_debug (params,"event %d: decoded custom function, currentvalue of %x is %s", i, proptype, dpd->CurrentValue.str);
 					break;
-				case PTP_DPC_CANON_EOS_FocusInfoEx:
-					dpd->DataType = PTP_DTC_STR;
-					free (dpd->FactoryDefaultValue.str);
-					free (dpd->CurrentValue.str);
-					dpd->FactoryDefaultValue.str	= ptp_unpack_EOS_FocusInfoEx( params, &xdata );
-					dpd->CurrentValue.str		= strdup( (char*)dpd->FactoryDefaultValue.str );
-					ptp_debug (params,"event %d: decoded focus info, currentvalue of %x is %s", i, proptype, dpd->CurrentValue.str);
-					break;
 				}
 
 				break;
 		}
-		/* one more information record handed to us */
-		case PTP_EC_CANON_EOS_OLCInfoChanged: {
-			uint32_t		len, curoff;
-			uint16_t		mask,proptype;
-			PTPDevicePropDesc	*dpd;
-
-			/* unclear what OLC stands for */
-			ptp_debug (params, "event %d: EOS event OLCInfoChanged (size %d)", i, size);
-			if (size >= 0x8) {	/* event info */
-				unsigned int k;
-				for (k=8;k<size;k++)
-					ptp_debug (params, "    %d: %02x", k-8, curdata[k]);
-			}
-			len = dtoh32a(curdata+8);
-			if (len != size-8) {
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ptp_debug (params, "event %d: size %d, len %d", i, size, len);
-				break;
-			}
-			mask = dtoh16a(curdata+8+4);
-			curoff = 8+4+4;
-			if (mask & CANON_EOS_OLC_BUTTON) {
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ce[i].u.info = malloc(strlen("Button 1234567"));
-				sprintf(ce[i].u.info, "Button %d",  dtoh16a(curdata+curoff));
-				i++;
-				curoff += 2;
-			}
-			
-			if (mask & CANON_EOS_OLC_SHUTTERSPEED) {
-				/* 6 bytes: 01 01 98 10 00 60 */
-				/* this seesm to be the shutter speed record */
-				proptype = PTP_DPC_CANON_EOS_ShutterSpeed;
-				dpd = _lookup_or_allocate_canon_prop(params, proptype);
-				dpd->CurrentValue.u16 = curdata[curoff+5]; /* just use last byte */
-
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY;
-				ce[i].u.propid = proptype;
-				curoff += 6;
-				i++;
-			}
-			if (mask & CANON_EOS_OLC_APERTURE) {
-				/* 5 bytes: 01 01 5b 30 30 */
-				/* this seesm to be the aperture record */
-				proptype = PTP_DPC_CANON_EOS_Aperture;
-				dpd = _lookup_or_allocate_canon_prop(params, proptype);
-				dpd->CurrentValue.u16 = curdata[curoff+4]; /* just use last byte */
-
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY;
-				ce[i].u.propid = proptype;
-				curoff += 5;
-				i++;
-			}
-			if (mask & CANON_EOS_OLC_ISO) {
-				/* 5 bytes: 01 01 00 78 */
-				/* this seesm to be the aperture record */
-				proptype = PTP_DPC_CANON_EOS_ISOSpeed;
-				dpd = _lookup_or_allocate_canon_prop(params, proptype);
-				dpd->CurrentValue.u16 = curdata[curoff+3]; /* just use last byte */
-
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_PROPERTY;
-				ce[i].u.propid = proptype;
-				curoff += 4;
-				i++;
-			}
-			if (mask & 0x0010) {
-				/* mask 0x0010: 4 bytes, 04 00 00 00 observed */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ce[i].u.info = malloc(strlen("OLCInfo event 0x0010 content 01234567")+1); 
-				sprintf(ce[i].u.info,"OLCInfo event 0x0010 content %02x%02x%02x%02x",
-					curdata[curoff],
-					curdata[curoff+1],
-					curdata[curoff+2],
-					curdata[curoff+3]
-				);
-				curoff += 4;
-				i++;
-			}
-			if (mask & 0x0020) {
-				/* mask 0x0020: 6 bytes, 00 00 00 00 00 00 observed */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ce[i].u.info = malloc(strlen("OLCInfo event 0x0020 content 0123456789ab")+1); 
-				sprintf(ce[i].u.info,"OLCInfo event 0x0020 content %02x%02x%02x%02x%02x%02x",
-					curdata[curoff],
-					curdata[curoff+1],
-					curdata[curoff+2],
-					curdata[curoff+3],
-					curdata[curoff+4],
-					curdata[curoff+5]
-				);
-				curoff += 6;
-				i++;
-			}
-			if (mask & 0x0040) {
-				int	value = (signed char)curdata[curoff+2];
-				/* mask 0x0040: 7 bytes, 01 01 00 00 00 00 00 observed */
-				/* exposure indicator */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ce[i].u.info = malloc(strlen("OLCInfo exposure indicator 012345678901234567890123456789abcd")+1); 
-				sprintf(ce[i].u.info,"OLCInfo exposure indicator %d,%d,%d.%d (%02x%02x%02x%02x)",
-					curdata[curoff],
-					curdata[curoff+1],
-					value/10,abs(value)%10,
-					curdata[curoff+3],
-					curdata[curoff+4],
-					curdata[curoff+5],
-					curdata[curoff+6]
-				);
-				curoff += 7;
-				i++;
-			}
-			if (mask & 0x0080) {
-				/* mask 0x0080: 4 bytes, 00 00 00 00 observed */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ce[i].u.info = malloc(strlen("OLCInfo event 0x0080 content 01234567")+1); 
-				sprintf(ce[i].u.info,"OLCInfo event 0x0080 content %02x%02x%02x%02x",
-					curdata[curoff],
-					curdata[curoff+1],
-					curdata[curoff+2],
-					curdata[curoff+3]
-				);
-				curoff += 4;
-				i++;
-			}
-			if (mask & 0x0100) {
-				/* mask 0x0100: 6 bytes, 00 00 00 00 00 00 (before focus) and 00 00 00 00 01 00 (on focus) observed */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_FOCUSINFO;
-				ce[i].u.info = malloc(strlen("0123456789ab")+1); 
-				sprintf(ce[i].u.info,"%02x%02x%02x%02x%02x%02x",
-					curdata[curoff],
-					curdata[curoff+1],
-					curdata[curoff+2],
-					curdata[curoff+3],
-					curdata[curoff+4],
-					curdata[curoff+5]
-				);
-				curoff += 6;
-				i++;
-			}
-			if (mask & 0x0200) {
-				/* mask 0x0200: 7 bytes, 00 00 00 00 00 00 00 observed */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_FOCUSMASK;
-				ce[i].u.info = malloc(strlen("0123456789abcd0123456789abcdef")+1); 
-				sprintf(ce[i].u.info,"%02x%02x%02x%02x%02x%02x%02x",
-					curdata[curoff],
-					curdata[curoff+1],
-					curdata[curoff+2],
-					curdata[curoff+3],
-					curdata[curoff+4],
-					curdata[curoff+5],
-					curdata[curoff+6]
-				);
-				curoff += 7;
-				i++;
-			}
-			if (mask & 0x0400) {
-				/* mask 0x0400: 7 bytes, 00 00 00 00 00 00 00 observed */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ce[i].u.info = malloc(strlen("OLCInfo event 0x0400 content 0123456789abcd")+1); 
-				sprintf(ce[i].u.info,"OLCInfo event 0x0400 content %02x%02x%02x%02x%02x%02x%02x",
-					curdata[curoff],
-					curdata[curoff+1],
-					curdata[curoff+2],
-					curdata[curoff+3],
-					curdata[curoff+4],
-					curdata[curoff+5],
-					curdata[curoff+6]
-				);
-				curoff += 7;
-				i++;
-			}
-			if (mask & 0x0800) {
-				/* mask 0x0800: 8 bytes, 00 00 00 00 00 00 00 00 and 19 01 00 00 00 00 00 00 and others observed */
-				/*   might be mask of focus points selected */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ce[i].u.info = malloc(strlen("OLCInfo event 0x0800 content 0123456789abcdef")+1); 
-				sprintf(ce[i].u.info,"OLCInfo event 0x0800 content %02x%02x%02x%02x%02x%02x%02x%02x",
-					curdata[curoff],
-					curdata[curoff+1],
-					curdata[curoff+2],
-					curdata[curoff+3],
-					curdata[curoff+4],
-					curdata[curoff+5],
-					curdata[curoff+6],
-					curdata[curoff+7]
-				);
-				curoff += 8;
-				i++;
-			}
-			if (mask & 0x1000) {
-				/* mask 0x1000: 1 byte, 00 observed */
-				ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-				ce[i].u.info = malloc(strlen("OLCInfo event 0x1000 content 01")+1); 
-				sprintf(ce[i].u.info,"OLCInfo event 0x1000 content %02x",
-					curdata[curoff]
-				);
-				curoff += 1;
-				i++;
-			}
-			/* handle more masks */
-			ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-			ce[i].u.info = malloc(strlen("OLCInfo event mask 0123456789")+1);
-			sprintf(ce[i].u.info, "OLCInfo event mask=%x",  mask);
-			break;
-		}
 		case PTP_EC_CANON_EOS_CameraStatusChanged:
-			ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_CAMERASTATUS;
-			ce[i].u.status =  dtoh32a(curdata+8);
-			ptp_debug (params, "event %d: EOS event CameraStatusChanged (size %d) = %d", i, size, dtoh32a(curdata+8));
+			ptp_debug (params, "event %d: EOS event CameraStatusChanged (size %d)", i, size);
+			(*ce)[i].type = PTP_CANON_EOS_CHANGES_TYPE_CAMERASTATUS;
+			(*ce)[i].u.status =  dtoh32a(curdata+8);
 			params->eos_camerastatus = dtoh32a(curdata+8);
 			break;
 		case 0: /* end marker */
@@ -2376,22 +1818,19 @@
 			ptp_debug (params, "event %d: EOS event 0, but size %d", i, size);
 			break;
 		case PTP_EC_CANON_EOS_BulbExposureTime:
-			ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
-			ce[i].u.info = malloc(strlen("BulbExposureTime 123456789"));
-			sprintf (ce[i].u.info, "BulbExposureTime %d",  dtoh32a(curdata+8));
-			break;
-		case PTP_EC_CANON_EOS_ObjectRemoved:
-			ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_OBJECTREMOVED;
-			ce[i].u.object.oid = dtoh32a(curdata+8);
+			(*ce)[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
+			(*ce)[i].u.info = malloc(strlen("BulbExposureTime 123456789"));
+			sprintf ((*ce)[i].u.info, "BulbExposureTime %d",  dtoh32a(curdata+8));
 			break;
 		default:
 			switch (type) {
 #define XX(x)		case PTP_EC_CANON_EOS_##x: 								\
 				ptp_debug (params, "event %d: unhandled EOS event "#x" (size %d)", i, size); 	\
-				ce[i].u.info = malloc(strlen("unhandled EOS event "#x" (size 123456789)"));	\
-				sprintf (ce[i].u.info, "unhandled EOS event "#x" (size %d)",  size);		\
+				(*ce)[i].u.info = malloc(strlen("unhandled EOS event "#x" (size 123456789)"));	\
+				sprintf ((*ce)[i].u.info, "unhandled EOS event "#x" (size %d)",  size);		\
 				break;
 			XX(RequestGetEvent)
+			XX(ObjectRemoved)
 			XX(RequestGetObjectInfoEx)
 			XX(StorageStatusChanged)
 			XX(StorageInfoChanged)
@@ -2414,24 +1853,23 @@
 				break;
 			}
 			if (size >= 0x8) {	/* event info */
-				unsigned int j;
+				int j;
 				for (j=8;j<size;j++)
 					ptp_debug (params, "    %d: %02x", j, curdata[j]);
 			}
-			ce[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
+			(*ce)[i].type = PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN;
 			break;
 		}
 		curdata += size;
+		i++;
 		if ((size == 8) && (type == 0))
 			break;
-		i++;
 	}
-	if (!i) {
-		free (ce);
-		ce = NULL;
+	if (!entries) {
+		free (*ce);
+		*ce = NULL;
 	}
-	*pce = ce;
-	return i;
+	return entries;
 }
 
 /*
@@ -2442,9 +1880,9 @@
 #define PTP_nikon_ec_Param1		4
 #define PTP_nikon_ec_Size		6
 static inline void
-ptp_unpack_Nikon_EC (PTPParams *params, unsigned char* data, unsigned int len, PTPContainer **ec, unsigned int *cnt)
+ptp_unpack_Nikon_EC (PTPParams *params, unsigned char* data, unsigned int len, PTPContainer **ec, int *cnt)
 {
-	unsigned int i;
+	int i;
 
 	*ec = NULL;
 	if (data == NULL)
@@ -2548,11 +1986,11 @@
 	for (i=0;i<cnt;i++)
 		if (ISOBJECT(dir+i*0x4c)) nrofobs++;
 	handles->n = nrofobs;
-	handles->Handler = calloc(nrofobs,sizeof(handles->Handler[0]));
+	handles->Handler = calloc(sizeof(handles->Handler[0]),nrofobs);
 	if (!handles->Handler) return PTP_RC_GeneralError;
-	*oinfos = calloc(nrofobs,sizeof((*oinfos)[0]));
+	*oinfos = calloc(sizeof((*oinfos)[0]),nrofobs);
 	if (!*oinfos) return PTP_RC_GeneralError;
-	*flags  = calloc(nrofobs,sizeof((*flags)[0]));
+	*flags  = calloc(sizeof((*flags)[0]),nrofobs);
 	if (!*flags) return PTP_RC_GeneralError;
 
 	/* Migrate data into objects ids, handles into
@@ -2593,7 +2031,7 @@
 	}
 	/* Walk over all objects and distribute the storage ids */
 	while (1) {
-		unsigned int changed = 0;
+		int changed = 0;
 		for (i=0;i<cnt;i++) {
 			unsigned char	*cur = dir+i*0x4c;
 			uint32_t	oid = dtoh32a(cur + ptp_canon_dir_objectid);
diff --git a/src/ptp.c b/src/ptp.c
index c1f7f3b..dc68f7c 100644
--- a/src/ptp.c
+++ b/src/ptp.c
@@ -18,25 +18,19 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA  02110-1301  USA
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
  */
 
-#define _DEFAULT_SOURCE
+#define _BSD_SOURCE
 #include "config.h"
 #include "ptp.h"
 
-#ifdef HAVE_LIBXML2
-# include <libxml/parser.h>
-#endif
-
 #include <stdlib.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
 
 #ifdef ENABLE_NLS
 #  include <libintl.h>
@@ -57,29 +51,9 @@
 #  define N_(String) (String)
 #endif
 
-#define CHECK_PTP_RC(RESULT) do { uint16_t r = (RESULT); if (r != PTP_RC_OK) return r; } while(0)
+#define CHECK_PTP_RC(result)	{uint16_t r=(result); if (r!=PTP_RC_OK) return r;}
 
-static inline void
-ptp_init_container(PTPContainer* ptp, uint16_t code, int n_param, ...)
-{
-	va_list	args;
-	int	i;
-
-	memset(ptp, 0, sizeof(*ptp));
-	ptp->Code = code;
-	ptp->Nparam = n_param;
-
-	va_start(args, n_param);
-	for (i=0; i<n_param; ++i)
-		(&ptp->Param1)[i] = va_arg(args, uint32_t);
-	va_end(args);
-}
-
-#define NARGS_SEQ(_1,_2,_3,_4,_5,_6,_7,_8,N,...) N
-#define NARGS(...) NARGS_SEQ(-1, ##__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1, 0)
-
-#define PTP_CNT_INIT(PTP, CODE, ...) \
-	ptp_init_container(&PTP, CODE, NARGS(__VA_ARGS__), ##__VA_ARGS__)
+#define PTP_CNT_INIT(cnt) {memset(&cnt,0,sizeof(cnt));}
 
 static uint16_t ptp_exit_recv_memory_handler (PTPDataHandler*,unsigned char**,unsigned long*);
 static uint16_t ptp_init_recv_memory_handler(PTPDataHandler*);
@@ -126,6 +100,12 @@
 
 /* major PTP functions */
 
+/* Transaction data phase description */
+#define PTP_DP_NODATA		0x0000	/* no data phase */
+#define PTP_DP_SENDDATA		0x0001	/* sending data */
+#define PTP_DP_GETDATA		0x0002	/* receiving data */
+#define PTP_DP_DATA_MASK	0x00ff	/* data phase mask */
+
 /**
  * ptp_transaction:
  * params:	PTPParams*
@@ -154,10 +134,10 @@
  * Upon success PTPContainer* ptp contains PTP Response Phase container with
  * all fields filled in.
  **/
-uint16_t
+static uint16_t
 ptp_transaction_new (PTPParams* params, PTPContainer* ptp, 
-		     uint16_t flags, uint64_t sendlen,
-		     PTPDataHandler *handler
+		uint16_t flags, unsigned int sendlen,
+		PTPDataHandler *handler
 ) {
 	int 		tries;
 	uint16_t	cmd;
@@ -169,23 +149,36 @@
 	ptp->Transaction_ID=params->transaction_id++;
 	ptp->SessionID=params->session_id;
 	/* send request */
-	CHECK_PTP_RC(params->sendreq_func (params, ptp, flags));
+	CHECK_PTP_RC(params->sendreq_func (params, ptp));
 	/* is there a dataphase? */
 	switch (flags&PTP_DP_DATA_MASK) {
 	case PTP_DP_SENDDATA:
 		{
-			uint16_t ret = params->senddata_func(params, ptp, sendlen, handler);
-			if (ret == PTP_ERROR_CANCEL)
-				CHECK_PTP_RC(params->cancelreq_func(params, params->transaction_id-1));
-			CHECK_PTP_RC(ret);
+			uint16_t ret;
+			ret = params->senddata_func(params, ptp,
+						    sendlen, handler);
+			if (ret == PTP_ERROR_CANCEL) {
+				ret = params->cancelreq_func(params, 
+							     params->transaction_id-1);
+				if (ret == PTP_RC_OK)
+					ret = PTP_ERROR_CANCEL;
+			}
+			if (ret != PTP_RC_OK)
+				return ret;
 		}
 		break;
 	case PTP_DP_GETDATA:
 		{
-			uint16_t ret = params->getdata_func(params, ptp, handler);
-			if (ret == PTP_ERROR_CANCEL)
-				CHECK_PTP_RC(params->cancelreq_func(params, params->transaction_id-1));
-			CHECK_PTP_RC(ret);
+			uint16_t ret;
+			ret = params->getdata_func(params, ptp, handler);
+			if (ret == PTP_ERROR_CANCEL) {
+				ret = params->cancelreq_func(params, 
+							     params->transaction_id-1);
+				if (ret == PTP_RC_OK)
+					ret = PTP_ERROR_CANCEL;
+			}
+			if (ret != PTP_RC_OK)
+				return ret;
 		}
 		break;
 	case PTP_DP_NODATA:
@@ -203,12 +196,10 @@
 			tries++;
 			continue;
 		}
-		CHECK_PTP_RC(ret);
-
+		if (ret != PTP_RC_OK)
+			return ret;
+		
 		if (ptp->Transaction_ID < params->transaction_id-1) {
-			/* The Leica uses Transaction ID 0 on result from CloseSession. */
-			if (cmd == PTP_OC_CloseSession)
-				break;
 			tries++;
 			ptp_debug (params,
 				"PTP: Sequence number mismatch %d vs expected %d, suspecting old reply.",
@@ -255,7 +246,8 @@
 
 static uint16_t
 memory_putfunc(PTPParams* params, void* private,
-	       unsigned long sendlen, unsigned char *data
+	       unsigned long sendlen, unsigned char *data,
+	       unsigned long *putlen
 ) {
 	PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)private;
 
@@ -267,13 +259,13 @@
 	}
 	memcpy (priv->data + priv->curoff, data, sendlen);
 	priv->curoff += sendlen;
+	*putlen = sendlen;
 	return PTP_RC_OK;
 }
 
 /* init private struct for receiving data. */
 static uint16_t
-ptp_init_recv_memory_handler(PTPDataHandler *handler)
-{
+ptp_init_recv_memory_handler(PTPDataHandler *handler) {
 	PTPMemHandlerPrivate* priv;
 	priv = malloc (sizeof(PTPMemHandlerPrivate));
 	if (!priv)
@@ -309,8 +301,7 @@
 
 /* free private struct + data */
 static uint16_t
-ptp_exit_send_memory_handler (PTPDataHandler *handler)
-{
+ptp_exit_send_memory_handler (PTPDataHandler *handler) {
 	PTPMemHandlerPrivate* priv = (PTPMemHandlerPrivate*)handler->priv;
 	/* data is owned by caller */
 	free (priv);
@@ -352,20 +343,22 @@
 
 static uint16_t
 fd_putfunc(PTPParams* params, void* private,
-	       unsigned long sendlen, unsigned char *data
+	       unsigned long sendlen, unsigned char *data,
+	       unsigned long *putlen
 ) {
-	ssize_t		written;
+	int		written;
 	PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)private;
 
 	written = write (priv->fd, data, sendlen);
-	if (written != sendlen)
-		return PTP_ERROR_IO;
+	if (written != -1)
+		*putlen = written;
+	else
+		return PTP_RC_GeneralError;
 	return PTP_RC_OK;
 }
 
 static uint16_t
-ptp_init_fd_handler(PTPDataHandler *handler, int fd)
-{
+ptp_init_fd_handler(PTPDataHandler *handler, int fd) {
 	PTPFDHandlerPrivate* priv;
 	priv = malloc (sizeof(PTPFDHandlerPrivate));
 	if (!priv)
@@ -378,25 +371,16 @@
 }
 
 static uint16_t
-ptp_exit_fd_handler (PTPDataHandler *handler)
-{
+ptp_exit_fd_handler (PTPDataHandler *handler) {
 	PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)handler->priv;
 	free (priv);
 	return PTP_RC_OK;
 }
 
 /* Old style transaction, based on memory */
-/* A note on memory management:
- * If called with the flag PTP_DP_GETDATA, this function will internally
- * allocate memory as much as necessary. The caller has to free the memory
- * returned in *data. If the function returns an error, it will free any
- * memory it might have allocated. The recvlen may be NULL. After the
- * function returns, *data will be initialized (valid memory pointer or NULL),
- * i.e. it is not necessary to initialize *data or *recvlen beforehand.
- */
-uint16_t
+static uint16_t
 ptp_transaction (PTPParams* params, PTPContainer* ptp, 
-		uint16_t flags, uint64_t sendlen,
+		uint16_t flags, unsigned int sendlen,
 		unsigned char **data, unsigned int *recvlen
 ) {
 	PTPDataHandler	handler;
@@ -404,17 +388,10 @@
 
 	switch (flags & PTP_DP_DATA_MASK) {
 	case PTP_DP_SENDDATA:
-		if (!data)
-			return PTP_ERROR_BADPARAM;
-		CHECK_PTP_RC(ptp_init_send_memory_handler (&handler, *data, sendlen));
+		ptp_init_send_memory_handler (&handler, *data, sendlen);
 		break;
 	case PTP_DP_GETDATA:
-		if (!data)
-			return PTP_ERROR_BADPARAM;
-		*data = NULL;
-		if (recvlen)
-			*recvlen = 0;
-		CHECK_PTP_RC(ptp_init_recv_memory_handler (&handler));
+		ptp_init_recv_memory_handler (&handler);
 		break;
 	default:break;
 	}
@@ -426,11 +403,6 @@
 	case PTP_DP_GETDATA: {
 		unsigned long len;
 		ptp_exit_recv_memory_handler (&handler, data, &len);
-		if (ret != PTP_RC_OK) {
-			len = 0;
-			free(*data);
-			*data = NULL;
-		}
 		if (recvlen)
 			*recvlen = len;
 		break;
@@ -460,491 +432,45 @@
 uint16_t
 ptp_getdeviceinfo (PTPParams* params, PTPDeviceInfo* deviceinfo)
 {
+	uint16_t 	ret;
+	unsigned long	len;
 	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	unsigned char*	di=NULL;
+	PTPDataHandler	handler;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetDeviceInfo);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ptp_unpack_DI(params, data, deviceinfo, size);
-	free(data);
-	return PTP_RC_OK;
+	ptp_init_recv_memory_handler (&handler);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetDeviceInfo;
+	ptp.Nparam=0;
+	len=0;
+	ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
+	ptp_exit_recv_memory_handler (&handler, &di, &len);
+	if (!di) ret = PTP_RC_GeneralError;
+	if (ret == PTP_RC_OK) ptp_unpack_DI(params, di, deviceinfo, len);
+	free(di);
+	return ret;
 }
 
 uint16_t
 ptp_canon_eos_getdeviceinfo (PTPParams* params, PTPCanonEOSDeviceInfo*di)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
-
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetDeviceInfoEx);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ptp_unpack_EOS_DI(params, data, di, size);
-	free (data);
-	return PTP_RC_OK;
-}
-
-#ifdef HAVE_LIBXML2
-static int
-traverse_tree (PTPParams *params, int depth, xmlNodePtr node)
-{
-	xmlNodePtr	next;
-	xmlChar		*xchar;
-	int		n;
-	char 		*xx;
-
-
-	if (!node) return 0;
-	xx = malloc (depth * 4 + 1);
-	memset (xx, ' ', depth*4);
-	xx[depth*4] = 0;
-
-	n = xmlChildElementCount (node);
-
-	next = node;
-	do {
-		fprintf(stderr,"%snode %s\n", xx,next->name);
-		fprintf(stderr,"%selements %d\n", xx,n);
-		xchar = xmlNodeGetContent (next);
-		fprintf(stderr,"%scontent %s\n", xx,xchar);
-		traverse_tree (params, depth+1,xmlFirstElementChild (next));
-	} while ((next = xmlNextElementSibling (next)));
-	free (xx);
-	return PTP_RC_OK;
-}
-
-static int
-parse_9301_cmd_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di)
-{
-	xmlNodePtr	next;
-	int		cnt;
-
-	cnt = 0;
-	next = xmlFirstElementChild (node);
-	while (next) {
-		cnt++;
-		next = xmlNextElementSibling (next);
-	}
-	di->OperationsSupported_len = cnt;
-	di->OperationsSupported = malloc (cnt*sizeof(di->OperationsSupported[0]));
-	cnt = 0;
-	next = xmlFirstElementChild (node);
-	while (next) {
-		unsigned int p;
-
-		sscanf((char*)next->name, "c%04x", &p);
-		ptp_debug( params, "cmd %s / 0x%04x", next->name, p);
-		di->OperationsSupported[cnt++] = p;
-		next = xmlNextElementSibling (next);
-	}
-	return PTP_RC_OK;
-}
-
-static int
-parse_9301_value (PTPParams *params, const char *str, uint16_t type, PTPPropertyValue *propval)
-{
-	switch (type) {
-	case 6: { /*UINT32*/
-		unsigned int x;
-		if (!sscanf(str,"%08x", &x)) {
-			ptp_debug( params, "could not parse uint32 %s", str);
-			return PTP_RC_GeneralError;
-		}
-		ptp_debug( params, "\t%d", x);
-		propval->u32 = x;
-		break;
-	}
-	case 5: { /*INT32*/
-		int x;
-		if (!sscanf(str,"%08x", &x)) {
-			ptp_debug( params, "could not parse int32 %s", str);
-			return PTP_RC_GeneralError;
-		}
-		ptp_debug( params, "\t%d", x);
-		propval->i32 = x;
-		break;
-	}
-	case 4: { /*UINT16*/
-		unsigned int x;
-		if (!sscanf(str,"%04x", &x)) {
-			ptp_debug( params, "could not parse uint16 %s", str);
-			return PTP_RC_GeneralError;
-		}
-		ptp_debug( params, "\t%d", x);
-		propval->u16 = x;
-		break;
-	}
-	case 3: { /*INT16*/
-		int x;
-		if (!sscanf(str,"%04x", &x)) {
-			ptp_debug( params, "could not parse int16 %s", str);
-			return PTP_RC_GeneralError;
-		}
-		ptp_debug( params, "\t%d", x);
-		propval->i16 = x;
-		break;
-	}
-	case 2: { /*UINT8*/
-		unsigned int x;
-		if (!sscanf(str,"%02x", &x)) {
-			ptp_debug( params, "could not parse uint8 %s", str);
-			return PTP_RC_GeneralError;
-		}
-		ptp_debug( params, "\t%d", x);
-		propval->u8 = x;
-		break;
-	}
-	case 1: { /*INT8*/
-		int x;
-		if (!sscanf(str,"%02x", &x)) {
-			ptp_debug( params, "could not parse int8 %s", str);
-			return PTP_RC_GeneralError;
-		} 
-		ptp_debug( params, "\t%d", x);
-		propval->i8 = x;
-		break;
-	}
-	case 65535: { /* string */
-		int len;
-
-		/* ascii ptp string, 1 byte length, little endian 16 bit chars */
-		if (sscanf(str,"%02x", &len)) {
-			int i;
-			char *xstr = malloc(len+1);
-			for (i=0;i<len;i++) {
-				int xc;
-				if (sscanf(str+2+i*4,"%04x", &xc)) {
-					int cx;
-
-					cx = ((xc>>8) & 0xff) | ((xc & 0xff) << 8);
-					xstr[i] = cx;
-				}
-				xstr[len] = 0;
-			}
-			ptp_debug( params, "\t%s", xstr);
-			propval->str = xstr;
-			break;
-		}
-		ptp_debug( params, "string %s not parseable!", str);
-		return PTP_RC_GeneralError;
-	}
-	case 7: /*INT64*/
-	case 8: /*UINT64*/
-	case 9: /*INT128*/
-	case 10: /*UINT128*/
-	default:
-		ptp_debug( params, "unhandled data type %d!", type);
-		return PTP_RC_GeneralError;
-	}
-	return PTP_RC_OK;
-}
-
-static int
-parse_9301_propdesc (PTPParams *params, xmlNodePtr next, PTPDevicePropDesc *dpd)
-{
-	int type = -1;
-
-	if (!next)
-		return PTP_RC_GeneralError;
-
-	ptp_debug (params, "parse_9301_propdesc");
-	dpd->FormFlag	= PTP_DPFF_None;
-	dpd->GetSet	= PTP_DPGS_Get;
-	do {
-		if (!strcmp((char*)next->name,"type")) {	/* propdesc.DataType */
-			if (!sscanf((char*)xmlNodeGetContent (next), "%04x", &type)) {
-				ptp_debug( params, "\ttype %s not parseable?",xmlNodeGetContent (next));
-				return 0;
-			}
-			ptp_debug( params, "type 0x%x", type);
-			dpd->DataType = type;
-			continue;
-		}
-		if (!strcmp((char*)next->name,"attribute")) {	/* propdesc.GetSet */
-			int attr;
-
-			if (!sscanf((char*)xmlNodeGetContent (next), "%02x", &attr)) {
-				ptp_debug( params, "\tattr %s not parseable",xmlNodeGetContent (next));
-				return 0;
-			}
-			ptp_debug( params, "attribute 0x%x", attr);
-			dpd->GetSet = attr;
-			continue;
-		}
-		if (!strcmp((char*)next->name,"default")) {	/* propdesc.FactoryDefaultValue */
-			ptp_debug( params, "default value");
-			parse_9301_value (params, (char*)xmlNodeGetContent (next), type, &dpd->FactoryDefaultValue);
-			continue;
-		}
-		if (!strcmp((char*)next->name,"value")) {	/* propdesc.CurrentValue */
-			ptp_debug( params, "current value");
-			parse_9301_value (params, (char*)xmlNodeGetContent (next), type, &dpd->CurrentValue);
-			continue;
-		}
-		if (!strcmp((char*)next->name,"enum")) {	/* propdesc.FORM.Enum */
-			int n,i;
-			char *s;
-
-			ptp_debug( params, "enum");
-			dpd->FormFlag = PTP_DPFF_Enumeration;
-			s = (char*)xmlNodeGetContent (next);
-			n = 0;
-			do {
-				s = strchr(s,' ');
-				if (s) s++;
-				n++;
-			} while (s);
-			dpd->FORM.Enum.NumberOfValues = n;
-			dpd->FORM.Enum.SupportedValue = malloc (n * sizeof(PTPPropertyValue));
-			s = (char*)xmlNodeGetContent (next);
-			i = 0;
-			do {
-				parse_9301_value (params, s, type, &dpd->FORM.Enum.SupportedValue[i]); /* should turn ' ' into \0? */
-				i++;
-				s = strchr(s,' ');
-				if (s) s++;
-			} while (s && (i<n));
-			continue;
-		}
-		if (!strcmp((char*)next->name,"range")) {	/* propdesc.FORM.Enum */
-			char *s = (char*)xmlNodeGetContent (next);
-			dpd->FormFlag = PTP_DPFF_Range;
-			ptp_debug( params, "range");
-			parse_9301_value (params, s, type, &dpd->FORM.Range.MinimumValue); /* should turn ' ' into \0? */
-			s = strchr(s,' ');
-			if (!s) continue;
-			s++;
-			parse_9301_value (params, s, type, &dpd->FORM.Range.MaximumValue); /* should turn ' ' into \0? */
-			s = strchr(s,' ');
-			if (!s) continue;
-			s++;
-			parse_9301_value (params, s, type, &dpd->FORM.Range.StepSize); /* should turn ' ' into \0? */
-
-			continue;
-		}
-		ptp_debug (params, "\tpropdescvar: %s", next->name);
-		traverse_tree (params, 3, next);
-	} while ((next = xmlNextElementSibling (next)));
-	return PTP_RC_OK;
-}
-
-static int
-parse_9301_prop_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di)
-{
-	xmlNodePtr	next;
-	int		cnt;
-	unsigned int	i;
-
-	cnt = 0;
-	next = xmlFirstElementChild (node);
-	while (next) {
-		cnt++;
-		next = xmlNextElementSibling (next);
-	}
-
-	di->DevicePropertiesSupported_len = cnt;
-	di->DevicePropertiesSupported = malloc (cnt*sizeof(di->DevicePropertiesSupported[0]));
-	cnt = 0;
-	next = xmlFirstElementChild (node);
-	while (next) {
-		unsigned int p;
-		PTPDevicePropDesc	dpd;
-
-		sscanf((char*)next->name, "p%04x", &p);
-		ptp_debug( params, "prop %s / 0x%04x", next->name, p);
-		parse_9301_propdesc (params, xmlFirstElementChild (next), &dpd);
-		dpd.DevicePropertyCode = p;
-		di->DevicePropertiesSupported[cnt++] = p;
-
-		/* add to cache of device propdesc */
-		for (i=0;i<params->nrofdeviceproperties;i++)
-			if (params->deviceproperties[i].desc.DevicePropertyCode == p)
-				break;
-		if (i == params->nrofdeviceproperties) {
-			params->deviceproperties = realloc(params->deviceproperties,(i+1)*sizeof(params->deviceproperties[0]));
-			memset(&params->deviceproperties[i],0,sizeof(params->deviceproperties[0]));
-			params->nrofdeviceproperties++;
-		} else {
-			ptp_free_devicepropdesc (&params->deviceproperties[i].desc);
-		}
-		/* FIXME: free old entry */
-		/* we are not using dpd, so copy it directly to the cache */
-		time( &params->deviceproperties[i].timestamp);
-		params->deviceproperties[i].desc = dpd;
-
-		next = xmlNextElementSibling (next);
-	}
-	return PTP_RC_OK;
-}
-
-static int
-parse_9301_event_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di)
-{
-	xmlNodePtr	next;
-	int		cnt;
-
-	cnt = 0;
-	next = xmlFirstElementChild (node);
-	while (next) {
-		cnt++;
-		next = xmlNextElementSibling (next);
-	}
-	di->EventsSupported_len = cnt;
-	di->EventsSupported = malloc (cnt*sizeof(di->EventsSupported[0]));
-	cnt = 0;
-	next = xmlFirstElementChild (node);
-	while (next) {
-		unsigned int p;
-
-		sscanf((char*)next->name, "e%04x", &p);
-		ptp_debug( params, "event %s / 0x%04x", next->name, p);
-		di->EventsSupported[cnt++] = p;
-		next = xmlNextElementSibling (next);
-	}
-	return PTP_RC_OK;
-}
-
-static int
-parse_9301_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di)
-{
-	xmlNodePtr	next;
-
-	next = xmlFirstElementChild (node);
-	while (next) {
-		if (!strcmp ((char*)next->name, "cmd")) {
-			parse_9301_cmd_tree (params, next, di);
-			next = xmlNextElementSibling (next);
-			continue;
-		}
-		if (!strcmp ((char*)next->name, "prop")) {
-			parse_9301_prop_tree (params, next, di);
-			next = xmlNextElementSibling (next);
-			continue;
-		}
-		if (!strcmp ((char*)next->name, "event")) {
-			parse_9301_event_tree (params, next, di);
-			next = xmlNextElementSibling (next);
-			continue;
-		}
-		fprintf (stderr,"9301: unhandled type %s\n", next->name);
-		next = xmlNextElementSibling (next);
-	}
-	/*traverse_tree (0, node);*/
-	return PTP_RC_OK;
-}
-
-static uint16_t
-ptp_olympus_parse_output_xml(PTPParams* params, char*data, int len, xmlNodePtr *code)
-{
-        xmlDocPtr       docin;
-        xmlNodePtr      docroot, output, next;
-	int 		result, xcode;
-
-	*code = NULL;
-
-        docin = xmlReadMemory ((char*)data, len, "http://gphoto.org/", "utf-8", 0);
-        if (!docin) return PTP_RC_GeneralError;
-        docroot = xmlDocGetRootElement (docin);
-        if (!docroot) {
-		xmlFreeDoc (docin);
-		return PTP_RC_GeneralError;
-	}
-
-        if (strcmp((char*)docroot->name,"x3c")) {
-                ptp_debug (params, "olympus: docroot is not x3c, but %s", docroot->name);
-		xmlFreeDoc (docin);
-                return PTP_RC_GeneralError;
-        }
-        if (xmlChildElementCount(docroot) != 1) {
-                ptp_debug (params, "olympus: x3c: expected 1 child, got %ld", xmlChildElementCount(docroot));
-		xmlFreeDoc (docin);
-                return PTP_RC_GeneralError;
-        }
-        output = xmlFirstElementChild (docroot);
-        if (strcmp((char*)output->name, "output") != 0) {
-                ptp_debug (params, "olympus: x3c node: expected child 'output', but got %s", (char*)output->name);
-		xmlFreeDoc (docin);
-                return PTP_RC_GeneralError;
-	}
-        next = xmlFirstElementChild (output);
-
-	result = PTP_RC_GeneralError;
-
-	while (next) {
-		if (!strcmp((char*)next->name,"result")) {
-			xmlChar	 *xchar;
-
-			xchar = xmlNodeGetContent (next);
-			if (!sscanf((char*)xchar,"%04x",&result))
-				ptp_debug (params, "failed scanning result from %s", xchar);
-			ptp_debug (params,  "ptp result is 0x%04x", result);
-			next = xmlNextElementSibling (next);
-			continue;
-		}
-		if (sscanf((char*)next->name,"c%x", &xcode)) {
-			ptp_debug (params,  "ptp code node found %s", (char*)next->name);
-			*code = next;
-			next = xmlNextElementSibling (next);
-			continue;
-		}
-		ptp_debug (params, "unhandled node %s", (char*)next->name);
-		next = xmlNextElementSibling (next);
-	}
-
-	if (result != PTP_RC_OK) {
-		*code = NULL;
-		xmlFreeDoc (docin);
-	}
-	return result;
-}
-#endif
-
-uint16_t
-ptp_olympus_getdeviceinfo (PTPParams* params, PTPDeviceInfo *di)
-{
-#ifdef HAVE_LIBXML2
-	PTPContainer	ptp;
 	uint16_t 	ret;
+	PTPContainer	ptp;
+	PTPDataHandler	handler;
+	unsigned long	len;
 	unsigned char	*data;
-	unsigned int	size;
-	xmlNodePtr	code;
 
-	memset (di, 0, sizeof(PTPDeviceInfo));
-
-	PTP_CNT_INIT(ptp, PTP_OC_OLYMPUS_GetDeviceInfo);
-	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
-	/* TODO: check for error, only parse_output_xml if ret == PTP_RC_OK?
-	 * where is 'data' going to be deallocated? */
-	ret = ptp_olympus_parse_output_xml(params,(char*)data,size,&code);
-	if (ret != PTP_RC_OK)
-		return ret;
-
-	ret = parse_9301_tree (params, code, di);
-
-	xmlFreeDoc(code->doc);
+	ptp_init_recv_memory_handler (&handler);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_EOS_GetDeviceInfoEx;
+	ptp.Nparam=0;
+	len=0;
+	data=NULL;
+	ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
+	ptp_exit_recv_memory_handler (&handler, &data, &len);
+	if (ret == PTP_RC_OK) ptp_unpack_EOS_DI(params, data, di, len);
+	free (data);
 	return ret;
-#else
-	return PTP_RC_GeneralError;
-#endif
-}
-
-uint16_t
-ptp_olympus_opensession (PTPParams* params, unsigned char**data, unsigned int *len)
-{
-	PTPContainer	ptp;
-
-	PTP_CNT_INIT(ptp, PTP_OC_OLYMPUS_OpenSession);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, len);
-}
-
-uint16_t
-ptp_olympus_getcameraid (PTPParams* params, unsigned char**data, unsigned int *len)
-{
-	PTPContainer	ptp;
-
-	PTP_CNT_INIT(ptp, PTP_OC_OLYMPUS_GetCameraID);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, len);
 }
 
 /**
@@ -961,14 +487,14 @@
 uint16_t
 ptp_generic_no_data (PTPParams* params, uint16_t code, unsigned int n_param, ...)
 {
-	PTPContainer	ptp;
-	va_list		args;
-	unsigned int	i;
+	PTPContainer ptp;
+	va_list args;
+	int i;
 
 	if( n_param > 5 )
-		return PTP_ERROR_BADPARAM;
+		return PTP_RC_InvalidParameter;
 
-	memset(&ptp, 0, sizeof(ptp));
+	PTP_CNT_INIT(ptp);
 	ptp.Code=code;
 	ptp.Nparam=n_param;
 
@@ -992,8 +518,8 @@
 uint16_t
 ptp_opensession (PTPParams* params, uint32_t session)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
+	uint16_t ret;
+	PTPContainer ptp;
 
 	ptp_debug(params,"PTP: Opening session");
 
@@ -1008,98 +534,16 @@
 	/* no split headers */
 	params->split_header_data = 0;
 
-	PTP_CNT_INIT(ptp, PTP_OC_OpenSession, session);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_OpenSession;
+	ptp.Param1=session;
+	ptp.Nparam=1;
 	ret=ptp_transaction_new(params, &ptp, PTP_DP_NODATA, 0, NULL);
-	/* TODO: check for error */
 	/* now set the global session id to current session number */
 	params->session_id=session;
 	return ret;
 }
 
-void
-ptp_free_devicepropvalue(uint16_t dt, PTPPropertyValue* dpd)
-{
-	switch (dt) {
-	case PTP_DTC_INT8:	case PTP_DTC_UINT8:
-	case PTP_DTC_UINT16:	case PTP_DTC_INT16:
-	case PTP_DTC_UINT32:	case PTP_DTC_INT32:
-	case PTP_DTC_UINT64:	case PTP_DTC_INT64:
-	case PTP_DTC_UINT128:	case PTP_DTC_INT128:
-		/* Nothing to free */
-		break;
-	case PTP_DTC_AINT8:	case PTP_DTC_AUINT8:
-	case PTP_DTC_AUINT16:	case PTP_DTC_AINT16:
-	case PTP_DTC_AUINT32:	case PTP_DTC_AINT32:
-	case PTP_DTC_AUINT64:	case PTP_DTC_AINT64:
-	case PTP_DTC_AUINT128:	case PTP_DTC_AINT128:
-		free(dpd->a.v);
-		break;
-	case PTP_DTC_STR:
-		free(dpd->str);
-		break;
-	}
-}
-
-void
-ptp_free_devicepropdesc(PTPDevicePropDesc* dpd)
-{
-	uint16_t i;
-
-	ptp_free_devicepropvalue (dpd->DataType, &dpd->FactoryDefaultValue);
-	ptp_free_devicepropvalue (dpd->DataType, &dpd->CurrentValue);
-	switch (dpd->FormFlag) {
-	case PTP_DPFF_Range:
-		ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.MinimumValue);
-		ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.MaximumValue);
-		ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.StepSize);
-		break;
-	case PTP_DPFF_Enumeration:
-		if (dpd->FORM.Enum.SupportedValue) {
-			for (i=0;i<dpd->FORM.Enum.NumberOfValues;i++)
-				ptp_free_devicepropvalue (dpd->DataType, dpd->FORM.Enum.SupportedValue+i);
-			free (dpd->FORM.Enum.SupportedValue);
-		}
-	}
-	dpd->DataType = PTP_DTC_UNDEF;
-	dpd->FormFlag = PTP_DPFF_None;
-}
-
-
-void
-ptp_free_objectpropdesc(PTPObjectPropDesc* opd)
-{
-	uint16_t i;
-
-	ptp_free_devicepropvalue (opd->DataType, &opd->FactoryDefaultValue);
-	switch (opd->FormFlag) {
-	case PTP_OPFF_None:
-		break;
-	case PTP_OPFF_Range:
-		ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.MinimumValue);
-		ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.MaximumValue);
-		ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.StepSize);
-		break;
-	case PTP_OPFF_Enumeration:
-		if (opd->FORM.Enum.SupportedValue) {
-			for (i=0;i<opd->FORM.Enum.NumberOfValues;i++)
-				ptp_free_devicepropvalue (opd->DataType, opd->FORM.Enum.SupportedValue+i);
-			free (opd->FORM.Enum.SupportedValue);
-		}
-		break;
-	case PTP_OPFF_DateTime:
-	case PTP_OPFF_FixedLengthArray:
-	case PTP_OPFF_RegularExpression:
-	case PTP_OPFF_ByteArray:
-	case PTP_OPFF_LongString:
-		/* Ignore these presently, we cannot unpack them, so there is nothing to be freed. */
-		break;
-	default:
-		fprintf (stderr, "Unknown OPFF type %d\n", opd->FormFlag);
-		break;
-	}
-}
-
-
 /**
  * ptp_free_params:
  * params:	PTPParams*
@@ -1109,12 +553,11 @@
  * Return values: Some PTP_RC_* code.
  **/
 void
-ptp_free_params (PTPParams *params)
-{
-	unsigned int i;
+ptp_free_params (PTPParams *params) {
+	int i;
 
-	free (params->cameraname);
-	free (params->wifi_profiles);
+	if (params->cameraname) free (params->cameraname);
+	if (params->wifi_profiles) free (params->wifi_profiles);
 	for (i=0;i<params->nrofobjects;i++)
 		ptp_free_object (&params->objects[i]);
 	free (params->objects);
@@ -1125,11 +568,6 @@
 	}
 	free (params->canon_props);
 	free (params->backlogentries);
-
-	for (i=0;i<params->nrofdeviceproperties;i++)
-		ptp_free_devicepropdesc (&params->deviceproperties[i].desc);
-	free (params->deviceproperties);
-
 	ptp_free_DI (&params->deviceinfo);
 }
 
@@ -1144,15 +582,19 @@
 uint16_t
 ptp_getstorageids (PTPParams* params, PTPStorageIDs* storageids)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned int len;
+	unsigned char* sids=NULL;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetStorageIDs);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ptp_unpack_SIDs(params, data, storageids, size);
-	free(data);
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetStorageIDs;
+	ptp.Nparam=0;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &sids, &len);
+	if (ret == PTP_RC_OK) ptp_unpack_SIDs(params, sids, storageids, len);
+	free(sids);
+	return ret;
 }
 
 /**
@@ -1169,15 +611,20 @@
 ptp_getstorageinfo (PTPParams* params, uint32_t storageid,
 			PTPStorageInfo* storageinfo)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* si=NULL;
+	unsigned int len;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetStorageInfo, storageid);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ptp_unpack_SI(params, data, storageinfo, size);
-	free(data);
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetStorageInfo;
+	ptp.Param1=storageid;
+	ptp.Nparam=1;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &si, &len);
+	if (ret == PTP_RC_OK) ptp_unpack_SI(params, si, storageinfo, len);
+	free(si);
+	return ret;
 }
 
 /**
@@ -1199,15 +646,21 @@
 			uint32_t objectformatcode, uint32_t associationOH,
 			PTPObjectHandles* objecthandles)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data;
-	unsigned int	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* oh=NULL;
+	unsigned int len;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetObjectHandles, storage, objectformatcode, associationOH);
-	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetObjectHandles;
+	ptp.Param1=storage;
+	ptp.Param2=objectformatcode;
+	ptp.Param3=associationOH;
+	ptp.Nparam=3;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &oh, &len);
 	if (ret == PTP_RC_OK) {
-		ptp_unpack_OH(params, data, objecthandles, size);
+		ptp_unpack_OH(params, oh, objecthandles, len);
 	} else {
 		if (	(storage == 0xffffffff) &&
 			(objectformatcode == 0) &&
@@ -1221,7 +674,7 @@
 			ret = PTP_RC_OK;
 		}
 	}
-	free(data);
+	free(oh);
 	return ret;
 }
 
@@ -1230,10 +683,19 @@
 			uint32_t objectformatcode, uint32_t associationOH,
 			unsigned char** data)
 {
+	uint16_t ret;
 	PTPContainer ptp;
+	unsigned int len;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetFilesystemManifest, storage, objectformatcode, associationOH);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, NULL);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetFilesystemManifest;
+	ptp.Param1=storage;
+	ptp.Param2=objectformatcode;
+	ptp.Param3=associationOH;
+	ptp.Nparam=3;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, &len);
+	return ret;
 }
 
 /**
@@ -1255,15 +717,23 @@
 			uint32_t objectformatcode, uint32_t associationOH,
 			uint32_t* numobs)
 {
-	PTPContainer	ptp;
+	uint16_t ret;
+	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetNumObjects, storage, objectformatcode, associationOH);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	if (ptp.Nparam >= 1)
-		*numobs = ptp.Param1;
-	else
-		return PTP_RC_GeneralError;
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetNumObjects;
+	ptp.Param1=storage;
+	ptp.Param2=objectformatcode;
+	ptp.Param3=associationOH;
+	ptp.Nparam=3;
+	ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
+	if (ret == PTP_RC_OK) {
+		if (ptp.Nparam >= 1)
+			*numobs = ptp.Param1;
+		else
+			ret = PTP_RC_GeneralError;
+	}
+	return ret;
 }
 
 /**
@@ -1277,13 +747,16 @@
 uint16_t
 ptp_canon_eos_bulbstart (PTPParams* params)
 {
-	PTPContainer	ptp;
+	uint16_t ret;
+	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_BulbStart);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	if ((ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) == 0x2000))
-		return ptp.Param1;
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_CANON_EOS_BulbStart;
+	ptp.Nparam = 0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
+	if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) == 0x2000))
+		ret = ptp.Param1;
+	return ret;
 }
 
 /**
@@ -1300,14 +773,17 @@
 uint16_t
 ptp_canon_eos_capture (PTPParams* params, uint32_t *result)
 {
-	PTPContainer	ptp;
+	uint16_t ret;
+	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_RemoteRelease);
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_CANON_EOS_RemoteRelease;
+	ptp.Nparam = 0;
 	*result = 0;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	if (ptp.Nparam >= 1)
+	ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
+	if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1))
 		*result = ptp.Param1;
-	return PTP_RC_OK;
+	return ret;
 }
 
 /**
@@ -1321,13 +797,16 @@
 uint16_t
 ptp_canon_eos_bulbend (PTPParams* params)
 {
-	PTPContainer	ptp;
+	uint16_t ret;
+	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_BulbEnd);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	if ((ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) == 0x2000))
-		return ptp.Param1;
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_CANON_EOS_BulbEnd;
+	ptp.Nparam = 0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
+	if ((ret == PTP_RC_OK) && (ptp.Nparam >= 1) && ((ptp.Param1 & 0x7000) == 0x2000))
+		ret = ptp.Param1;
+	return ret;
 }
 
 /**
@@ -1344,15 +823,20 @@
 ptp_getobjectinfo (PTPParams* params, uint32_t handle,
 			PTPObjectInfo* objectinfo)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* oi=NULL;
+	unsigned int len;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetObjectInfo, handle);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ptp_unpack_OI(params, data, objectinfo, size);
-	free(data);
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetObjectInfo;
+	ptp.Param1=handle;
+	ptp.Nparam=1;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &oi, &len);
+	if (ret == PTP_RC_OK) ptp_unpack_OI(params, oi, objectinfo, len);
+	free(oi);
+	return ret;
 }
 
 /**
@@ -1370,9 +854,14 @@
 ptp_getobject (PTPParams* params, uint32_t handle, unsigned char** object)
 {
 	PTPContainer ptp;
+	unsigned int len;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetObject, handle);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, NULL);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetObject;
+	ptp.Param1=handle;
+	ptp.Nparam=1;
+	len=0;
+	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, &len);
 }
 
 /**
@@ -1391,7 +880,10 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetObject, handle);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetObject;
+	ptp.Param1=handle;
+	ptp.Nparam=1;
 	return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler);
 }
 
@@ -1413,8 +905,11 @@
 	PTPDataHandler	handler;
 	uint16_t	ret;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetObject, handle);
 	ptp_init_fd_handler (&handler, fd);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetObject;
+	ptp.Param1=handle;
+	ptp.Nparam=1;
 	ret = ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler);
 	ptp_exit_fd_handler (&handler);
 	return ret;
@@ -1441,34 +936,17 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetPartialObject, handle, offset, maxbytes);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetPartialObject;
+	ptp.Param1=handle;
+	ptp.Param2=offset;
+	ptp.Param3=maxbytes;
+	ptp.Nparam=3;
+	*len=0;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len);
 }
 
 /**
- * ptp_getpartialobject_to_handler:
- * params:	PTPParams*
- *		handle			- Object handle
- *		offset			- Offset into object
- *		maxbytes		- Maximum of bytes to read
- *		handler			- a ptp data handler
- *
- * Get object 'handle' from device and send the data to the
- * data handler. Start from offset and read at most maxbytes.
- *
- * Return values: Some PTP_RC_* code.
- **/
-uint16_t
-ptp_getpartialobject_to_handler (PTPParams* params, uint32_t handle, uint32_t offset,
-			uint32_t maxbytes, PTPDataHandler *handler)
-{
-	PTPContainer ptp;
-
-	PTP_CNT_INIT(ptp, PTP_OC_GetPartialObject, handle, offset, maxbytes);
-	return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler);
-}
-
-/**
  * ptp_getthumb:
  * params:	PTPParams*
  *		handle			- Object handle
@@ -1484,7 +962,11 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetThumb, handle);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetThumb;
+	ptp.Param1=handle;
+	ptp.Nparam=1;
+	*len = 0;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len);
 }
 
@@ -1502,9 +984,17 @@
 ptp_deleteobject (PTPParams* params, uint32_t handle, uint32_t ofc)
 {
 	PTPContainer ptp;
+	uint16_t ret;
 
-	PTP_CNT_INIT(ptp, PTP_OC_DeleteObject, handle, ofc);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_DeleteObject;
+	ptp.Param1=handle;
+	ptp.Param2=ofc;
+	ptp.Nparam=2;
+	ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
+	if (ret != PTP_RC_OK) {
+		return ret;
+	}
 	/* If the object is cached and could be removed, cleanse cache. */
 	ptp_remove_object_from_cache(params, handle);
 	return PTP_RC_OK;
@@ -1533,15 +1023,20 @@
 			uint32_t* parenthandle, uint32_t* handle,
 			PTPObjectInfo* objectinfo)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data = NULL;
-	uint32_t	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* oidata=NULL;
+	uint32_t size;
 
-	PTP_CNT_INIT(ptp, PTP_OC_SendObjectInfo, *store, *parenthandle);
-	size = ptp_pack_OI(params, objectinfo, &data);
-	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
-	free(data);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_SendObjectInfo;
+	ptp.Param1=*store;
+	ptp.Param2=*parenthandle;
+	ptp.Nparam=2;
+	
+	size=ptp_pack_OI(params, objectinfo, &oidata);
+	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &oidata, NULL); 
+	free(oidata);
 	*store=ptp.Param1;
 	*parenthandle=ptp.Param2;
 	*handle=ptp.Param3; 
@@ -1552,7 +1047,7 @@
  * ptp_sendobject:
  * params:	PTPParams*
  *		char*	object		- contains the object that is to be sent
- *		uint64_t size		- object size
+ *		uint32_t size		- object size
  *		
  * Sends object to Responder.
  *
@@ -1560,11 +1055,14 @@
  *
  */
 uint16_t
-ptp_sendobject (PTPParams* params, unsigned char* object, uint64_t size)
+ptp_sendobject (PTPParams* params, unsigned char* object, uint32_t size)
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_SendObject);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_SendObject;
+	ptp.Nparam=0;
+
 	return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &object, NULL);
 }
 
@@ -1572,7 +1070,7 @@
  * ptp_sendobject_from_handler:
  * params:	PTPParams*
  *		PTPDataHandler*         - File descriptor to read() object from
- *              uint64_t size           - File/object size
+ *              uint32_t size           - File/object size
  *
  * Sends object from file descriptor by consecutive reads from this
  * descriptor.
@@ -1580,11 +1078,13 @@
  * Return values: Some PTP_RC_* code.
  **/
 uint16_t
-ptp_sendobject_from_handler (PTPParams* params, PTPDataHandler *handler, uint64_t size)
+ptp_sendobject_from_handler (PTPParams* params, PTPDataHandler *handler, uint32_t size)
 {
-	PTPContainer ptp;
+	PTPContainer	ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_SendObject);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_SendObject;
+	ptp.Nparam=0;
 	return ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, handler);
 }
 
@@ -1593,7 +1093,7 @@
  * ptp_sendobject_fromfd:
  * params:	PTPParams*
  *		fd                      - File descriptor to read() object from
- *              uint64_t size           - File/object size
+ *              uint32_t size           - File/object size
  *
  * Sends object from file descriptor by consecutive reads from this
  * descriptor.
@@ -1601,61 +1101,39 @@
  * Return values: Some PTP_RC_* code.
  **/
 uint16_t
-ptp_sendobject_fromfd (PTPParams* params, int fd, uint64_t size)
+ptp_sendobject_fromfd (PTPParams* params, int fd, uint32_t size)
 {
 	PTPContainer	ptp;
 	PTPDataHandler	handler;
 	uint16_t	ret;
 
-	PTP_CNT_INIT(ptp, PTP_OC_SendObject);
 	ptp_init_fd_handler (&handler, fd);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_SendObject;
+	ptp.Nparam=0;
 	ret = ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, &handler);
 	ptp_exit_fd_handler (&handler);
 	return ret;
 }
 
-#define PROPCACHE_TIMEOUT 5	/* seconds */
 
 uint16_t
 ptp_getdevicepropdesc (PTPParams* params, uint16_t propcode, 
 			PTPDevicePropDesc* devicepropertydesc)
 {
-	PTPContainer	ptp;
-	uint16_t	ret = PTP_RC_OK;
-	unsigned char	*data;
-	unsigned int	size;
+	PTPContainer ptp;
+	uint16_t ret;
+	unsigned int len;
+	unsigned char* dpd=NULL;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetDevicePropDesc, propcode);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-
-	if (params->device_flags & DEVICE_FLAG_OLYMPUS_XML_WRAPPED) {
-#ifdef HAVE_LIBXML2
-		xmlNodePtr	code;
-
-		ret = ptp_olympus_parse_output_xml (params,(char*)data,size,&code);
-		if (ret == PTP_RC_OK) {
-			int x;
-
-			if (	(xmlChildElementCount(code) == 1) &&
-					(!strcmp((char*)code->name,"c1014"))
-					) {
-				code = xmlFirstElementChild (code);
-
-				if (	(sscanf((char*)code->name,"p%x", &x)) &&
-						(x == propcode)
-						) {
-					ret = parse_9301_propdesc (params, xmlFirstElementChild (code), devicepropertydesc);
-					xmlFreeDoc(code->doc);
-				}
-			}
-		} else {
-			ptp_debug(params,"failed to parse output xml, ret %x?", ret);
-		}
-#endif
-	} else {
-		ptp_unpack_DPD(params, data, devicepropertydesc, size);
-	}
-	free(data);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetDevicePropDesc;
+	ptp.Param1=propcode;
+	ptp.Nparam=1;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpd, &len);
+	if (ret == PTP_RC_OK) ptp_unpack_DPD(params, dpd, devicepropertydesc, len);
+	free(dpd);
 	return ret;
 }
 
@@ -1664,17 +1142,21 @@
 ptp_getdevicepropvalue (PTPParams* params, uint16_t propcode,
 			PTPPropertyValue* value, uint16_t datatype)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size, offset = 0;
-	uint16_t	ret;
+	PTPContainer ptp;
+	uint16_t ret;
+	unsigned int len;
+	int offset;
+	unsigned char* dpv=NULL;
 
-	PTP_CNT_INIT(ptp, PTP_OC_GetDevicePropValue, propcode);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ret = ptp_unpack_DPV(params, data, &offset, size, value, datatype) ? PTP_RC_OK : PTP_RC_GeneralError;
-	if (ret != PTP_RC_OK)
-		ptp_debug (params, "ptp_getdevicepropvalue: unpacking DPV failed");
-	free(data);
+
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_GetDevicePropValue;
+	ptp.Param1=propcode;
+	ptp.Nparam=1;
+	len=offset=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, &len);
+	if (ret == PTP_RC_OK) ptp_unpack_DPV(params, dpv, &offset, len, value, datatype);
+	free(dpv);
 	return ret;
 }
 
@@ -1682,15 +1164,18 @@
 ptp_setdevicepropvalue (PTPParams* params, uint16_t propcode,
 			PTPPropertyValue *value, uint16_t datatype)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data = NULL;
-	uint32_t	size;
+	PTPContainer ptp;
+	uint16_t ret;
+	uint32_t size;
+	unsigned char* dpv=NULL;
 
-	PTP_CNT_INIT(ptp, PTP_OC_SetDevicePropValue, propcode);
-	size=ptp_pack_DPV(params, value, &data, datatype);
-	ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
-	free(data);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_SetDevicePropValue;
+	ptp.Param1=propcode;
+	ptp.Nparam=1;
+	size=ptp_pack_DPV(params, value, &dpv, datatype);
+	ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &dpv, NULL);
+	free(dpv);
 	return ret;
 }
 
@@ -1717,15 +1202,20 @@
 			uint32_t* parenthandle, uint32_t* handle,
 			PTPObjectInfo* objectinfo)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data = NULL;
-	uint32_t	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* oidata=NULL;
+	uint32_t size;
 
-	PTP_CNT_INIT(ptp, PTP_OC_EK_SendFileObjectInfo, *store, *parenthandle);
-	size=ptp_pack_OI(params, objectinfo, &data);
-	ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
-	free(data);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_EK_SendFileObjectInfo;
+	ptp.Param1=*store;
+	ptp.Param2=*parenthandle;
+	ptp.Nparam=2;
+	
+	size=ptp_pack_OI(params, objectinfo, &oidata);
+	ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &oidata, NULL); 
+	free(oidata);
 	*store=ptp.Param1;
 	*parenthandle=ptp.Param2;
 	*handle=ptp.Param3; 
@@ -1748,7 +1238,9 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_EK_GetSerial);
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_EK_GetSerial;
+	ptp.Nparam = 0;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); 
 }
 
@@ -1768,7 +1260,9 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_EK_SetSerial);
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_EK_SetSerial;
+	ptp.Nparam = 0;
 	return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); 
 }
 
@@ -1778,7 +1272,9 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, 0x9007);
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = 0x9007;
+	ptp.Nparam = 0;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); 
 }
 
@@ -1787,13 +1283,15 @@
 ptp_ek_9009 (PTPParams* params, uint32_t *p1, uint32_t *p2)
 {
 	PTPContainer	ptp;
+	uint16_t	ret;
 
-	PTP_CNT_INIT(ptp, 0x9009);
-	*p1 = *p2 = 0;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = 0x9009;
+	ptp.Nparam = 0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL); 
 	*p1 = ptp.Param1;
 	*p2 = ptp.Param2;
-	return PTP_RC_OK;
+	return ret;
 }
 
 /* unclear yet, but I guess it returns the info from 9008 */
@@ -1802,7 +1300,9 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, 0x900c);
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = 0x900c;
+	ptp.Nparam = 0;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); 
 	/* returned data is 16bit,16bit,32bit,32bit */
 }
@@ -1820,15 +1320,17 @@
 uint16_t
 ptp_ek_settext (PTPParams* params, PTPEKTextParams *text)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data = 0;
-	uint32_t	size;
+	PTPContainer ptp;
+	uint16_t ret;
+	unsigned int size;
+	unsigned char *data;
 
-	PTP_CNT_INIT(ptp, PTP_OC_EK_SetText);
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_EK_SetText;
+	ptp.Nparam = 0;
 	if (0 == (size = ptp_pack_EK_text(params, text, &data)))
 		return PTP_ERROR_BADPARAM;
-	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
+	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL); 
 	free(data);
 	return ret;
 }
@@ -1849,7 +1351,10 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_EK_SendFileObject);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_EK_SendFileObject;
+	ptp.Nparam=0;
+
 	return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &object, NULL);
 }
 
@@ -1869,7 +1374,9 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_EK_SendFileObject);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_EK_SendFileObject;
+	ptp.Nparam=0;
 	return ptp_transaction_new(params, &ptp, PTP_DP_SENDDATA, size, handler);
 }
 
@@ -1903,14 +1410,18 @@
 ptp_canon_getpartialobjectinfo (PTPParams* params, uint32_t handle, uint32_t p2, 
 			uint32_t* size, uint32_t* rp2) 
 {
-	PTPContainer	ptp;
+	uint16_t ret;
+	PTPContainer ptp;
 	
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetPartialObjectInfo, handle, p2);
-	*size = *rp2 = 0;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_GetPartialObjectInfo;
+	ptp.Param1=handle;
+	ptp.Param2=p2;
+	ptp.Nparam=2;
+	ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
 	*size=ptp.Param1;
 	*rp2=ptp.Param2;
-	return PTP_RC_OK;
+	return ret;
 }
 
 /**
@@ -1927,9 +1438,13 @@
 ptp_canon_get_mac_address (PTPParams* params, unsigned char **mac)
 {
 	PTPContainer ptp;
+	unsigned int size = 0;
 
-        PTP_CNT_INIT(ptp, PTP_OC_CANON_GetMACAddress);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, mac, NULL);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_GetMACAddress;
+	ptp.Nparam=0;
+	*mac = NULL;
+	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, mac, &size);
 }
 
 /**
@@ -1951,13 +1466,18 @@
 	uint32_t		**flags		/* size(handles->n) */
 ) {
 	PTPContainer	ptp;
-	unsigned char	*data;
+	unsigned char	*dir = NULL;
+	unsigned int	size = 0;
 	uint16_t	ret;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetDirectory);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NULL));
-	ret = ptp_unpack_canon_directory(params, data, ptp.Param1, handles, oinfos, flags);
-	free (data);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_GetDirectory;
+	ptp.Nparam=0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dir, &size);
+	if (ret != PTP_RC_OK)
+		return ret;
+	ret = ptp_unpack_canon_directory(params, dir, ptp.Param1, handles, oinfos, flags);
+	free (dir);
 	return ret;
 }
 
@@ -1976,13 +1496,17 @@
 uint16_t
 ptp_canon_gettreeinfo (PTPParams* params, uint32_t *out)
 {
-	PTPContainer	ptp;
+	PTPContainer ptp;
+	uint16_t ret;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetTreeInfo, 0xf);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	if (ptp.Nparam > 0)
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_CANON_GetTreeInfo;
+	ptp.Nparam = 1;
+	ptp.Param1 = 0xf;
+	ret = ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL);
+	if ((ret == PTP_RC_OK) && (ptp.Nparam>0))
 		*out = ptp.Param1;
-	return PTP_RC_OK;
+	return ret;
 }
 
 /**
@@ -1999,9 +1523,18 @@
 ptp_canon_getpairinginfo (PTPParams* params, uint32_t nr, unsigned char **data, unsigned int *size)
 {
 	PTPContainer ptp;
+	uint16_t ret;
 	
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetPairingInfo, nr);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_CANON_GetPairingInfo;
+	ptp.Nparam = 1;
+	ptp.Param1 = nr;
+	*data = NULL;
+	*size = 0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
+	if (ret != PTP_RC_OK)
+		return ret;
+	return PTP_RC_OK;
 }
 
 /**
@@ -2020,29 +1553,33 @@
 ptp_canon_gettreesize (PTPParams* params,
 	PTPCanon_directtransfer_entry **entries, unsigned int *cnt)
 {
-	PTPContainer	ptp;
-	uint16_t	ret = PTP_RC_OK;
-	unsigned char	*data, *cur;
-	unsigned int	size, i;
-
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetTreeSize);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	*cnt = dtoh32a(data);
+	PTPContainer ptp;
+	uint16_t ret;
+	unsigned char *out = NULL, *cur;
+	int i;
+	unsigned int size;
+	
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_CANON_GetTreeSize;
+	ptp.Nparam = 0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &out, &size);
+	if (ret != PTP_RC_OK)
+		return ret;
+	*cnt = dtoh32a(out);
 	*entries = malloc(sizeof(PTPCanon_directtransfer_entry)*(*cnt));
 	if (!*entries) {
-		ret = PTP_RC_GeneralError;
-		goto exit;
+		free (out);
+		return PTP_RC_GeneralError;
 	}
-	cur = data+4;
+	cur = out+4;
 	for (i=0;i<*cnt;i++) {
 		unsigned char len;
 		(*entries)[i].oid = dtoh32a(cur);
 		(*entries)[i].str = ptp_unpack_string(params, cur, 4, &len);
 		cur += 4+(cur[4]*2+1);
 	}
-exit:
-	free (data);
-	return ret;
+	free (out);
+	return PTP_RC_OK;
 }
 
 /**
@@ -2067,59 +1604,52 @@
 uint16_t
 ptp_canon_checkevent (PTPParams* params, PTPContainer* event, int* isevent)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char *evdata = NULL;
+	unsigned int len;
 	
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_CheckEvent);
 	*isevent=0;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	if (data && size) { /* check if we had a successfull call with data */
-		ptp_unpack_EC(params, data, event, size);
-		*isevent=1;
-		free(data);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_CheckEvent;
+	ptp.Nparam=0;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &evdata, &len);
+	if (evdata!=NULL) {
+		if (ret == PTP_RC_OK) {
+        		ptp_unpack_EC(params, evdata, event, len);
+    			*isevent=1;
+        	}
+		free(evdata);
 	}
-	return PTP_RC_OK;
+	return ret;
 }
 
 uint16_t
-ptp_add_event (PTPParams *params, PTPContainer *evt)
-{
-	params->events = realloc(params->events, sizeof(PTPContainer)*(params->nrofevents+1));
-	memcpy (&params->events[params->nrofevents],evt,1*sizeof(PTPContainer));
-	params->nrofevents += 1;
-	return PTP_RC_OK;
-}
+ptp_check_event (PTPParams *params) {
+	PTPContainer		event;
+	uint16_t		ret;
 
-uint16_t
-ptp_check_event (PTPParams *params)
-{
-	PTPContainer	event;
-	uint16_t	ret;
-
-	/* Method offered by Nikon DSLR, Nikon 1, and some older Nikon Coolpix P*
-	 * The Nikon Coolpix P2 however does not return anything. So if we never get
-	 * events from here, use the ptp "interrupt" method */
 	if (	(params->deviceinfo.VendorExtensionID == PTP_VENDOR_NIKON) &&
 		ptp_operation_issupported(params, PTP_OC_NIKON_CheckEvent)
 	) {
-		unsigned int evtcnt = 0;
-		PTPContainer *xevent = NULL;
+		int evtcnt;
+		PTPContainer	*xevent = NULL;
 
 		ret = ptp_nikon_check_event(params, &xevent, &evtcnt);
-		if (ret != PTP_RC_OperationNotSupported)
-			CHECK_PTP_RC(ret);
+		if (ret != PTP_RC_OK)
+			return ret;
 
 		if (evtcnt) {
-			params->events = realloc(params->events, sizeof(PTPContainer)*(evtcnt+params->nrofevents));
+			if (params->nrofevents)
+				params->events = realloc(params->events, sizeof(PTPContainer)*(evtcnt+params->nrofevents));
+			else
+				params->events = malloc(sizeof(PTPContainer)*evtcnt);
 			memcpy (&params->events[params->nrofevents],xevent,evtcnt*sizeof(PTPContainer));
 			params->nrofevents += evtcnt;
 			free (xevent);
-			params->event90c7works = 1;
 		}
-		if (params->event90c7works)
-			return PTP_RC_OK;
-		/* fall through to generic event handling */
+		return PTP_RC_OK;
 	}
 	/* should not get here ... EOS has no normal PTP events and another queue handling. */
 	if (	(params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &&
@@ -2133,15 +1663,14 @@
 	) {
 		int isevent;
 
-		CHECK_PTP_RC(ptp_canon_checkevent (params,&event,&isevent));
-
-		if (isevent) {
-			ret = PTP_RC_OK;
+		ret = ptp_canon_checkevent (params,&event,&isevent);
+		if (ret!=PTP_RC_OK)
+			return ret;
+		if (isevent)
 			goto store_event;
-		}
 		/* Event Emulate Mode 0 (unset) and 1-5 get interrupt events. 6-7 does not. */
 		if (params->canon_event_mode > 5)
-			return PTP_RC_OK;
+			return ret;
 
 		/* FIXME: fallthrough or return? */
 #ifdef __APPLE__
@@ -2149,7 +1678,7 @@
 		 * for interrupts, they have no timeout for it. 2010/08/23
 		 * Check back in 2011 or so. -Marcus
 		 */
-		return PTP_RC_OK;
+		return ret;
 #endif
 	}
 	ret = params->event_check(params,&event);
@@ -2157,68 +1686,20 @@
 store_event:
 	if (ret == PTP_RC_OK) {
 		ptp_debug (params, "event: nparams=0x%X, code=0x%X, trans_id=0x%X, p1=0x%X, p2=0x%X, p3=0x%X", event.Nparam,event.Code,event.Transaction_ID, event.Param1, event.Param2, event.Param3);
-		ptp_add_event (params, &event);
-
-		/* handle some PTP stack internal events */
-		switch (event.Code) {
-		case PTP_EC_DevicePropChanged: {
-			unsigned int i;
-
-			/* mark the property for a forced refresh on the next query */
-			for (i=0;i<params->nrofdeviceproperties;i++)
-				if (params->deviceproperties[i].desc.DevicePropertyCode == event.Param1) {
-					params->deviceproperties[i].timestamp = 0;
-					break;
-				}
-			break;
-		}
-		default: /* check if we should handle it internally too */
-			break;
-		}
-	
+		if (params->nrofevents)
+			params->events = realloc(params->events, sizeof(PTPContainer)*(params->nrofevents+1));
+		else
+			params->events = malloc(sizeof(PTPContainer)*1);
+		memcpy (&params->events[params->nrofevents],&event,1*sizeof(PTPContainer));
+		params->nrofevents += 1;
 	}
 	if (ret == PTP_ERROR_TIMEOUT) /* ok, just new events */
 		ret = PTP_RC_OK;
 	return ret;
 }
 
-uint16_t
-ptp_wait_event (PTPParams *params)
-{
-	PTPContainer	event;
-	uint16_t	ret;
-
-	ret = params->event_wait(params,&event);
-	if (ret == PTP_RC_OK) {
-		ptp_debug (params, "event: nparams=0x%X, code=0x%X, trans_id=0x%X, p1=0x%X, p2=0x%X, p3=0x%X", event.Nparam,event.Code,event.Transaction_ID, event.Param1, event.Param2, event.Param3);
-		ptp_add_event (params, &event);
-
-		/* handle some PTP stack internal events */
-		switch (event.Code) {
-		case PTP_EC_DevicePropChanged: {
-			unsigned int i;
-
-			/* mark the property for a forced refresh on the next query */
-			for (i=0;i<params->nrofdeviceproperties;i++)
-				if (params->deviceproperties[i].desc.DevicePropertyCode == event.Param1) {
-					params->deviceproperties[i].timestamp = 0;
-					break;
-				}
-			break;
-		}
-		default: /* check if we should handle it internally too */
-			break;
-		}
-	}
-	if (ret == PTP_ERROR_TIMEOUT) /* ok, just new events */
-		ret = PTP_RC_OK;
-	return ret;
-}
-
-
 int
-ptp_get_one_event(PTPParams *params, PTPContainer *event)
-{
+ptp_get_one_event(PTPParams *params, PTPContainer *event) {
 	if (!params->nrofevents)
 		return 0;
 	memcpy (event, params->events, sizeof(PTPContainer));
@@ -2247,27 +1728,33 @@
 uint16_t
 ptp_canon_eos_getevent (PTPParams* params, PTPCanon_changes_entry **entries, int *nrofentries)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int 	size;
+	PTPContainer ptp;
+	uint16_t	ret;
+	unsigned int 	size = 0;
+	unsigned char	*data = NULL;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetEvent);
 	*nrofentries = 0;
 	*entries = NULL;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	*nrofentries = ptp_unpack_CANON_changes(params,data,size,entries);
+	PTP_CNT_INIT(ptp);
+	ptp.Code = PTP_OC_CANON_EOS_GetEvent;
+	ptp.Nparam = 0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
+	if (ret != PTP_RC_OK) return ret;
+        *nrofentries = ptp_unpack_CANON_changes(params,data,size,entries);
 	free (data);
 	return PTP_RC_OK;
 }
 
 uint16_t
-ptp_check_eos_events (PTPParams *params)
-{
+ptp_check_eos_events (PTPParams *params) {
+	uint16_t		ret;
 	PTPCanon_changes_entry	*entries = NULL, *nentries;
 	int			nrofentries = 0;
 
 	while (1) { /* call it repeatedly until the camera does not report any */
-		CHECK_PTP_RC(ptp_canon_eos_getevent (params, &entries, &nrofentries));
+		ret = ptp_canon_eos_getevent (params, &entries, &nrofentries);
+		if (ret != PTP_RC_OK)
+			return ret;
 		if (!nrofentries)
 			return PTP_RC_OK;
 
@@ -2288,8 +1775,7 @@
 }
 
 int
-ptp_get_one_eos_event (PTPParams *params, PTPCanon_changes_entry *entry)
-{
+ptp_get_one_eos_event (PTPParams *params, PTPCanon_changes_entry *entry) {
 	if (!params->nrofbacklogentries)
 		return 0;
 	memcpy (entry, params->backlogentries, sizeof(*entry));
@@ -2309,7 +1795,7 @@
 ptp_canon_eos_getdevicepropdesc (PTPParams* params, uint16_t propcode,
 	PTPDevicePropDesc *dpd)
 {
-	unsigned int i;
+	int i;
 
 	for (i=0;i<params->nrofcanon_props;i++)
 		if (params->canon_props[i].proptype == propcode)
@@ -2338,24 +1824,34 @@
 ptp_canon_eos_getstorageids (PTPParams* params, PTPStorageIDs* storageids)
 {
 	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
-
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetStorageIDs);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ptp_unpack_SIDs(params, data, storageids, size);
-	free(data);
-	return PTP_RC_OK;
+	unsigned int	len = 0;
+	uint16_t	ret;
+	unsigned char*	sids=NULL;
+	
+	PTP_CNT_INIT(ptp);
+	ptp.Code 	= PTP_OC_CANON_EOS_GetStorageIDs;
+	ptp.Nparam	= 0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &sids, &len);
+	if (ret == PTP_RC_OK) ptp_unpack_SIDs(params, sids, storageids, len);
+	free(sids);
+	return ret;
 }
 
 uint16_t
 ptp_canon_eos_getstorageinfo (PTPParams* params, uint32_t p1, unsigned char **data, unsigned int *size)
 {
-	PTPContainer	ptp;
+	PTPContainer ptp;
+	uint16_t	ret;
 	
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetStorageInfo, p1);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
+	*size = 0;
+	*data = NULL;
+	PTP_CNT_INIT(ptp);
+	ptp.Code 	= PTP_OC_CANON_EOS_GetStorageInfo;
+	ptp.Nparam	= 1;
+	ptp.Param1	= p1;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
 	/* FIXME: do stuff with data */
+	return ret;
 }
 
 uint16_t
@@ -2364,32 +1860,32 @@
 	PTPCANONFolderEntry **entries, unsigned int *nrofentries
 ) {
 	PTPContainer	ptp;
-	uint16_t	ret = PTP_RC_OK;
+	unsigned int	i, size = 0;
 	unsigned char	*data, *xdata;
-	unsigned int	size, i;
+	uint16_t	ret;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetObjectInfoEx, storageid, oid, unk);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	if (!data) {
-		*nrofentries = 0;
-		return PTP_RC_OK;
-	}
+	data = NULL;
+	PTP_CNT_INIT(ptp);
+	ptp.Code 	= PTP_OC_CANON_EOS_GetObjectInfoEx;
+	ptp.Nparam	= 3;
+	ptp.Param1	= storageid;
+	ptp.Param2	= oid;
+	ptp.Param3	= unk;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
+	if (ret != PTP_RC_OK)
+		return ret;
 
 	*nrofentries = dtoh32a(data);
 	*entries = malloc(*nrofentries * sizeof(PTPCANONFolderEntry));
-	if (!*entries) {
-		ret = PTP_RC_GeneralError;
-		goto exit;
-	}
+	if (!*entries)
+		return PTP_RC_GeneralError;
 
 	xdata = data+sizeof(uint32_t);
 	for (i=0;i<*nrofentries;i++) {
 		ptp_unpack_Canon_EOS_FE (params, &xdata[4], &((*entries)[i]));
 		xdata += dtoh32a(xdata);
 	}
-exit:
-	free (data);
-	return ret;
+	return PTP_RC_OK;
 }
 
 /**
@@ -2412,9 +1908,16 @@
 ptp_canon_eos_getpartialobject (PTPParams* params, uint32_t oid, uint32_t offset, uint32_t xsize, unsigned char**data)
 {
 	PTPContainer	ptp;
+	unsigned int	size = 0;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetPartialObject, oid, offset, xsize);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, NULL);
+	*data = NULL;
+	PTP_CNT_INIT(ptp);
+	ptp.Code 	= PTP_OC_CANON_EOS_GetPartialObject;
+	ptp.Nparam	= 3;
+	ptp.Param1	= oid;
+	ptp.Param2	= offset;
+	ptp.Param3	= xsize;
+	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, &size);
 }
 
 uint16_t
@@ -2422,7 +1925,9 @@
 {
 	PTPContainer	ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_SetDevicePropValueEx);
+	PTP_CNT_INIT(ptp);
+	ptp.Code 	= PTP_OC_CANON_EOS_SetDevicePropValueEx;
+	ptp.Nparam	= 0;
 	return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
 }
 
@@ -2433,11 +1938,13 @@
 ) {
 	PTPContainer	ptp;
 	uint16_t	ret;
-	unsigned char	*data = NULL;
-	unsigned int	i, size;
+	int 		i;
+	unsigned char	*data;
+	unsigned int	size;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_SetDevicePropValueEx);
-
+	PTP_CNT_INIT(ptp);
+	ptp.Code 	= PTP_OC_CANON_EOS_SetDevicePropValueEx;
+	ptp.Nparam	= 0;
 	for (i=0;i<params->nrofcanon_props;i++)
 		if (params->canon_props[i].proptype == propcode)
 			break;
@@ -2467,12 +1974,12 @@
 		break;
 	default:
 		if (datatype != PTP_DTC_STR) {
-			data = calloc(3,sizeof(uint32_t));
+			data = calloc(sizeof(uint32_t),3);
 			if (!data) return PTP_RC_GeneralError;
 			size = sizeof(uint32_t)*3;
 		} else {
 			size = strlen(value->str) + 1 + 8;
-			data = calloc(size,sizeof(char));
+			data = calloc(sizeof(char),size);
 			if (!data) return PTP_RC_GeneralError;
 		}
 		switch (datatype) {
@@ -2535,17 +2042,24 @@
 				uint32_t pos, unsigned char** block, 
 				uint32_t* readnum)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char *data=NULL;
+	unsigned int len;
 	
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetPartialObjectEx, handle, offset, size, pos);
-	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NULL);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_GetPartialObjectEx;
+	ptp.Param1=handle;
+	ptp.Param2=offset;
+	ptp.Param3=size;
+	ptp.Param4=pos;
+	ptp.Nparam=4;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len);
 	if (ret==PTP_RC_OK) {
 		*block=data;
 		*readnum=ptp.Param1;
 	}
-	free (data);
 	return ret;
 }
 
@@ -2568,13 +2082,15 @@
 uint16_t
 ptp_canon_getviewfinderimage (PTPParams* params, unsigned char** image, uint32_t* size)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned int len;
 	
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetViewfinderImage);
-	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, NULL);
-	if (ret==PTP_RC_OK)
-		*size=ptp.Param1;
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_GetViewfinderImage;
+	ptp.Nparam=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, &len);
+	if (ret==PTP_RC_OK) *size=ptp.Param1;
 	return ret;
 }
 
@@ -2598,15 +2114,20 @@
 uint16_t
 ptp_canon_getchanges (PTPParams* params, uint16_t** props, uint32_t* propnum)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* data=NULL;
+	unsigned int len;
 	
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetChanges);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	*propnum=ptp_unpack_uint16_t_array(params,data,0,size,props);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_GetChanges;
+	ptp.Nparam=0;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len);
+	if (ret == PTP_RC_OK)
+        	*propnum=ptp_unpack_uint16_t_array(params,data,0,props);
 	free(data);
-	return PTP_RC_OK;
+	return ret;
 }
 
 /**
@@ -2637,29 +2158,34 @@
 			    uint32_t parent, uint32_t handle, 
 			    PTPCANONFolderEntry** entries, uint32_t* entnum)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data;
-	unsigned int	i;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char *data = NULL;
+	unsigned int len;
 	
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetObjectInfoEx, store, p2, parent, handle);
-	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NULL);
-	if (ret != PTP_RC_OK)
-		goto exit;
-
-	*entnum=ptp.Param1;
-	*entries=calloc(*entnum, sizeof(PTPCANONFolderEntry));
-	if (*entries==NULL) {
-		ret=PTP_RC_GeneralError;
-		goto exit;
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CANON_GetObjectInfoEx;
+	ptp.Param1=store;
+	ptp.Param2=p2;
+	ptp.Param3=parent;
+	ptp.Param4=handle;
+	ptp.Nparam=4;
+	len=0;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &len);
+	if (ret == PTP_RC_OK) {
+		int i;
+		*entnum=ptp.Param1;
+		*entries=calloc(*entnum, sizeof(PTPCANONFolderEntry));
+		if (*entries!=NULL) {
+			for(i=0; i<(*entnum); i++)
+				ptp_unpack_Canon_FE(params,
+					data+i*PTP_CANON_FolderEntryLen,
+					&((*entries)[i]) );
+		} else {
+			ret=PTP_ERROR_IO; /* Cannot allocate memory */
+		}
 	}
-	for(i=0; i<(*entnum); i++)
-		ptp_unpack_Canon_FE(params,
-				    data+i*PTP_CANON_FolderEntryLen,
-				    &((*entries)[i]) );
-
-exit:
-	free (data);
+	free(data);
 	return ret;
 }
 
@@ -2683,14 +2209,16 @@
 uint16_t
 ptp_canon_get_objecthandle_by_name (PTPParams* params, char* name, uint32_t* objectid)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data;
-	uint8_t		len = 0;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char *data = NULL;
+	uint8_t len;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetObjectHandleByName);
+	PTP_CNT_INIT (ptp);
+	ptp.Code=PTP_OC_CANON_GetObjectHandleByName;
+	ptp.Nparam=0;
+	len=0;
 	data = malloc (2*(strlen(name)+1)+2);
-	if (!data) return PTP_RC_GeneralError;
 	memset (data, 0, 2*(strlen(name)+1)+2);
 	ptp_pack_string (params, name, data, 0, &len);
 	ret=ptp_transaction (params, &ptp, PTP_DP_SENDDATA, (len+1)*2+1, &data, NULL);
@@ -2719,43 +2247,29 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CANON_GetCustomizeData, themenr);
+	*data = NULL;
+	*size = 0;
+	PTP_CNT_INIT(ptp);
+	ptp.Code	= PTP_OC_CANON_GetCustomizeData;
+	ptp.Param1	= themenr;
+	ptp.Nparam	= 1;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); 
 }
 
 
 uint16_t
-ptp_nikon_curve_download (PTPParams* params, unsigned char **data, unsigned int *size)
-{
+ptp_nikon_curve_download (PTPParams* params, unsigned char **data, unsigned int *size) {
 	PTPContainer ptp;
-
-	PTP_CNT_INIT(ptp, PTP_OC_NIKON_CurveDownload);
+	*data = NULL;
+	*size = 0;
+	PTP_CNT_INIT(ptp);
+	ptp.Code	= PTP_OC_NIKON_CurveDownload;
+	ptp.Nparam	= 0;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); 
 }
 
 /**
- * ptp_sony_sdioconnect:
- *
- * This changes modes of the camera
- *  
- * params:	PTPParams*
- *
- * Return values: Some PTP_RC_* code.
- *
- **/
-uint16_t
-ptp_sony_sdioconnect (PTPParams* params, uint32_t p1, uint32_t p2, uint32_t p3)
-{
-	PTPContainer	ptp;
-	unsigned char	*data;
-
-	PTP_CNT_INIT(ptp, PTP_OC_SONY_SDIOConnect, p1, p2, p3);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NULL));
-	free (data);
-	return PTP_RC_OK;
-}
-/**
- * ptp_sony_get_vendorpropcodes:
+ * ptp_canon_get_vendorpropcodes:
  *
  * This command downloads the vendor specific property codes.
  *  
@@ -2767,343 +2281,38 @@
  *
  **/
 uint16_t
-ptp_sony_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size)
-{
+ptp_nikon_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size) {
 	PTPContainer	ptp;
-	unsigned char	*xdata;
-	unsigned int 	xsize, psize1 = 0, psize2 = 0;
-	uint16_t	*props1 = NULL,*props2 = NULL;
+	uint16_t	ret;
+	unsigned char	*xdata = NULL;
+	unsigned int 	xsize;
 
 	*props = NULL;
 	*size = 0;
-	PTP_CNT_INIT(ptp, PTP_OC_SONY_GetSDIOGetExtDeviceInfo, 0xc8 /* unclear */);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize));
-	if (xsize == 0) {
-		ptp_debug (params, "No special operations sent?");
-		return PTP_RC_OK;
-	}
-
-	psize1 = ptp_unpack_uint16_t_array (params, xdata+2, 0, xsize, &props1);
-	ptp_debug (params, "xsize %d, got size %d\n", xsize, psize1*2 + 2 + 4);
-	if (psize1*2 + 2 + 4 < xsize) {
-		psize2 = ptp_unpack_uint16_t_array(params,xdata+2+psize1*2+4, 0, xsize, &props2);
-	}
-	*size = psize1+psize2;
-	*props = malloc((psize1+psize2)*sizeof(uint16_t));
-	memcpy (*props, props1, psize1*sizeof(uint16_t));
-	memcpy ((*props)+psize1, props2, psize2*sizeof(uint16_t));
-	free (props1);
-	free (props2);
+	PTP_CNT_INIT(ptp);
+	ptp.Code	= PTP_OC_NIKON_GetVendorPropCodes;
+	ptp.Nparam	= 0;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &xdata, &xsize); 
+	if (ret == PTP_RC_OK)
+        	*size = ptp_unpack_uint16_t_array(params,xdata,0,props);
 	free (xdata);
-	return PTP_RC_OK;
-}
-
-uint16_t
-ptp_sony_getdevicepropdesc (PTPParams* params, uint16_t propcode, PTPDevicePropDesc *dpd)
-{
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int 	size, len = 0;
-	uint16_t	ret;
-
-	PTP_CNT_INIT(ptp, PTP_OC_SONY_GetDevicePropdesc, propcode);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	/* first 16 bit is 0xc8 0x00, then an array of 16 bit PTP ids */
-	ret = ptp_unpack_Sony_DPD(params,data,dpd,size,&len) ? PTP_RC_OK : PTP_RC_GeneralError;
-	free (data);
 	return ret;
 }
 
 uint16_t
-ptp_sony_getalldevicepropdesc (PTPParams* params)
-{
-	PTPContainer		ptp;
-	unsigned char		*data, *dpddata;
-	unsigned int		size, readlen;
-	PTPDevicePropDesc	dpd;
-
-	PTP_CNT_INIT(ptp, PTP_OC_SONY_GetAllDevicePropData);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	dpddata = data+8; /* nr of entries 32bit, 0 32bit */
-	size -= 8;
-	while (size>0) {
-		unsigned int	i;
-		uint16_t	propcode;
-
-		if (!ptp_unpack_Sony_DPD (params, dpddata, &dpd, size, &readlen))
-			break;
-
-		propcode = dpd.DevicePropertyCode;
-
-		for (i=0;i<params->nrofdeviceproperties;i++)
-			if (params->deviceproperties[i].desc.DevicePropertyCode == propcode)
-				break;
-
-		if (i == params->nrofdeviceproperties) {
-			params->deviceproperties = realloc(params->deviceproperties,(i+1)*sizeof(params->deviceproperties[0]));
-			memset(&params->deviceproperties[i],0,sizeof(params->deviceproperties[0]));
-			params->nrofdeviceproperties++;
-		} else {
-			ptp_free_devicepropdesc (&params->deviceproperties[i].desc);
-		}
-		params->deviceproperties[i].desc = dpd;
-#if 0
-		ptp_debug (params, "dpd.DevicePropertyCode %04x, readlen %d, getset %d", dpd.DevicePropertyCode, readlen, dpd.GetSet);
-		switch (dpd.DataType) {
-		case PTP_DTC_INT8:
-			ptp_debug (params, "value %d/%x", dpd.CurrentValue.i8, dpd.CurrentValue.i8);
-			break;
-		case PTP_DTC_UINT8:
-			ptp_debug (params, "value %d/%x", dpd.CurrentValue.u8, dpd.CurrentValue.u8);
-			break;
-		case PTP_DTC_UINT16:
-			ptp_debug (params, "value %d/%x", dpd.CurrentValue.u16, dpd.CurrentValue.u16);
-			break;
-		case PTP_DTC_INT16:
-			ptp_debug (params, "value %d/%x", dpd.CurrentValue.i16, dpd.CurrentValue.i16);
-			break;
-		case PTP_DTC_INT32:
-			ptp_debug (params, "value %d/%x", dpd.CurrentValue.i32, dpd.CurrentValue.i32);
-			break;
-		case PTP_DTC_UINT32:
-			ptp_debug (params, "value %d/%x", dpd.CurrentValue.u32, dpd.CurrentValue.u32);
-			break;
-		default:
-			ptp_debug (params, "unknown type %x", dpd.DataType);
-			break;
-		}
-#endif
-		dpddata += readlen;
-		size -= readlen;
-	}
-	free(data);
-	return PTP_RC_OK;
-}
-
-uint16_t
-ptp_sony_setdevicecontrolvaluea (PTPParams* params, uint16_t propcode,
-			PTPPropertyValue *value, uint16_t datatype)
-{
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data;
-	uint32_t	size;
-
-	PTP_CNT_INIT(ptp, PTP_OC_SONY_SetControlDeviceA, propcode);
-	size = ptp_pack_DPV(params, value, &data, datatype);
-	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
-	free(data);
-	return ret;
-}
-
-uint16_t
-ptp_sony_setdevicecontrolvalueb (PTPParams* params, uint16_t propcode,
-			PTPPropertyValue *value, uint16_t datatype)
-{
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data;
-	uint32_t	size;
-
-	PTP_CNT_INIT(ptp, PTP_OC_SONY_SetControlDeviceB, propcode);
-	size = ptp_pack_DPV(params, value, &data , datatype);
-	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
-	free(data);
-	return ret;
-}
-
-uint16_t
-ptp_sony_9280 (PTPParams* params, uint32_t param1,
-	uint32_t additional, uint32_t data2, uint32_t data3, uint32_t data4, uint8_t x, uint8_t y)
-{
-	PTPContainer	ptp;
-	unsigned char 	buf[18];
-	unsigned char	*buffer;
-
-	PTP_CNT_INIT(ptp, 0x9280, param1);
-
-	if ((additional != 0) && (additional != 2))
-		return PTP_RC_GeneralError;
-
-	htod32a(&buf[0], additional);
-	htod32a(&buf[4], data2);
-	htod32a(&buf[8], data3);
-	htod32a(&buf[12], data4);
-
-	/* only sent in the case where additional is 2 */
-	buf[16]= x; buf[17]= y;
-
-	buffer=buf;
-	return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, 16+additional, &buffer, NULL);
-}
-
-uint16_t
-ptp_sony_9281 (PTPParams* params, uint32_t param1) {
-	PTPContainer	ptp;
-	unsigned int	size = 0;
-	unsigned char	*buffer = NULL;
-	uint16_t	ret;
-
-	PTP_CNT_INIT(ptp, 0x9281, param1);
-	ret =  ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buffer, &size);
-	free (buffer);
-	return ret;
-}
-
-/**
- * ptp_generic_getdevicepropdesc:
- *
- * This command gets a propertydesc.
- * If a vendor specific property desc query is available, it uses that.
- * If not, it falls back to the generic PTP getdevicepropdesc.
- *  
- * params:	PTPParams*
- *      uint16_t propcode 
- *      PTPDevicePropDesc *dpd
- *
- * Return values: Some PTP_RC_* code.
- *
- **/
-/* Cache time in seconds. Should perhaps be more granular... */
-#define CACHETIME 2
-
-uint16_t
-ptp_generic_getdevicepropdesc (PTPParams *params, uint16_t propcode, PTPDevicePropDesc *dpd)
-{
-	unsigned int	i;
-	time_t		now;
-
-	for (i=0;i<params->nrofdeviceproperties;i++)
-		if (params->deviceproperties[i].desc.DevicePropertyCode == propcode)
-			break;
-	if (i == params->nrofdeviceproperties) {
-		params->deviceproperties = realloc(params->deviceproperties,(i+1)*sizeof(params->deviceproperties[0]));
-		memset(&params->deviceproperties[i],0,sizeof(params->deviceproperties[0]));
-		params->nrofdeviceproperties++;
-	}
-
-	if (params->deviceproperties[i].desc.DataType != PTP_DTC_UNDEF) {
-		time(&now);
-		if ((now - params->deviceproperties[i].timestamp) <= CACHETIME) {
-			duplicate_DevicePropDesc(&params->deviceproperties[i].desc, dpd);
-			return PTP_RC_OK;
-		}
-		/* free cached entry as we will refetch it. */
-		ptp_free_devicepropdesc (&params->deviceproperties[i].desc);
-	}
-
-	if (	(params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) &&
-		ptp_operation_issupported(params, PTP_OC_SONY_GetAllDevicePropData)
-	) {
-		CHECK_PTP_RC(ptp_sony_getalldevicepropdesc (params));
-
-		for (i=0;i<params->nrofdeviceproperties;i++)
-			if (params->deviceproperties[i].desc.DevicePropertyCode == propcode)
-				break;
-		if (i == params->nrofdeviceproperties) {
-			ptp_debug (params, "property 0x%04x not found?\n", propcode);
-			return PTP_RC_GeneralError;
-		}
-		time(&now);
-		params->deviceproperties[i].timestamp = now;
-		duplicate_DevicePropDesc(&params->deviceproperties[i].desc, dpd);
-		return PTP_RC_OK;
-	}
-	if (	(params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) &&
-		ptp_operation_issupported(params, PTP_OC_SONY_GetDevicePropdesc)
-	) {
-		CHECK_PTP_RC(ptp_sony_getdevicepropdesc (params, propcode, &params->deviceproperties[i].desc));
-
-		time(&now);
-		params->deviceproperties[i].timestamp = now;
-		duplicate_DevicePropDesc(&params->deviceproperties[i].desc, dpd);
-		return PTP_RC_OK;
-	}
-
-
-	if (ptp_operation_issupported(params, PTP_OC_GetDevicePropDesc)) {
-		CHECK_PTP_RC(ptp_getdevicepropdesc (params, propcode, &params->deviceproperties[i].desc));
-
-		time(&now);
-		params->deviceproperties[i].timestamp = now;
-		duplicate_DevicePropDesc(&params->deviceproperties[i].desc, dpd);
-		return PTP_RC_OK;
-	}
-
-	return PTP_RC_OK;
-}
-
-/**
- * ptp_generic_setdevicepropvalue:
- *
- * This command sets a property value, device specific.
- *  
- * params:	PTPParams*
- *      uint16_t propcode 
- *      PTPDevicePropertyValue *value
- *      uint16_t datatype
- *
- * Return values: Some PTP_RC_* code.
- *
- **/
-uint16_t
-ptp_generic_setdevicepropvalue (PTPParams* params, uint16_t propcode,
-	PTPPropertyValue *value, uint16_t datatype)
-{
-	unsigned int i;
-
-	/* reset the cache entry */
-	for (i=0;i<params->nrofdeviceproperties;i++)
-		if (params->deviceproperties[i].desc.DevicePropertyCode == propcode)
-			break;
-	if (i != params->nrofdeviceproperties)
-		params->deviceproperties[i].timestamp = 0;
-
-	/* FIXME: change the cache? hmm */
-	/* this works for some methods, but not for all */
-	if (	(params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) &&
-		ptp_operation_issupported(params, PTP_OC_SONY_SetControlDeviceA)
-	)
-		return ptp_sony_setdevicecontrolvaluea (params, propcode, value, datatype);
-	return ptp_setdevicepropvalue (params, propcode, value, datatype);
-}
-
-/**
- * ptp_nikon_get_vendorpropcodes:
- *
- * This command downloads the vendor specific property codes.
- *  
- * params:	PTPParams*
- *
- * Return values: Some PTP_RC_* code.
- *      unsigned char **data - pointer to data pointer
- *      unsigned int  *size - size of data returned
- *
- **/
-uint16_t
-ptp_nikon_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size)
-{
-	PTPContainer	ptp;
-	unsigned char	*data = NULL;
-	unsigned int	xsize = 0;
-
-	*props = NULL;
-	*size = 0;
-	PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetVendorPropCodes);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &xsize));
-	*size = ptp_unpack_uint16_t_array(params,data,0,xsize,props);
-	free (data);
-	return PTP_RC_OK;
-}
-
-uint16_t
 ptp_nikon_getfileinfoinblock ( PTPParams* params,
 	uint32_t p1, uint32_t p2, uint32_t p3,
 	unsigned char **data, unsigned int *size
 ) {
 	PTPContainer ptp;
-
-	PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetFileInfoInBlock, p1, p2, p3);
+	*data = NULL;
+	*size = 0;
+	PTP_CNT_INIT(ptp);
+	ptp.Code	= PTP_OC_NIKON_GetFileInfoInBlock;
+	ptp.Nparam	= 3;
+	ptp.Param1	= p1;
+	ptp.Param2	= p2;
+	ptp.Param3	= p3;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size); 
 }
 
@@ -3122,7 +2331,9 @@
 {
         PTPContainer ptp;
         
-        PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetLiveViewImg);
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_NIKON_GetLiveViewImg;
+        ptp.Nparam=0;
         return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
 }
 
@@ -3140,18 +2351,18 @@
 ptp_nikon_get_preview_image (PTPParams* params, unsigned char **xdata, unsigned int *xsize,
 	uint32_t *handle)
 {
-	PTPContainer	ptp;
-
-        PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetPreviewImg);
-
-	/* FIXME:
-	 * pdslrdashboard passes 3 parameters:
-	 * objectid, minimum size, maximum size
-	 */
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, xdata, xsize));
-	if (ptp.Nparam > 0)
-		*handle = ptp.Param1;
-	return PTP_RC_OK;
+        PTPContainer	ptp;
+	uint16_t	ret;
+        
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_NIKON_GetPreviewImg;
+        ptp.Nparam=0;
+        ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, xdata, xsize);
+	if (ret == PTP_RC_OK) {
+		if (ptp.Nparam > 0)
+			*handle = ptp.Param1;
+	}
+	return ret;
 }
 
 /**
@@ -3169,7 +2380,10 @@
 {
         PTPContainer ptp;
         
-        PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetViewFinderData, 0x00100000 /* from trace */);
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_CANON_EOS_GetViewFinderData;
+        ptp.Nparam=1;
+        ptp.Param1=0x00100000; /* from trace */
         return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
 }
 
@@ -3178,7 +2392,10 @@
 {
         PTPContainer ptp;
         
-        PTP_CNT_INIT(ptp, PTP_OC_CANON_EOS_GetViewFinderData, 0x00100000 /* from trace */);
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_CANON_EOS_GetViewFinderData;
+        ptp.Nparam=1;
+        ptp.Param1=0x00100000; /* from trace */
         return ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, handler);
 }
 
@@ -3195,18 +2412,23 @@
  *
  **/
 uint16_t
-ptp_nikon_check_event (PTPParams* params, PTPContainer** event, unsigned int* evtcnt)
+ptp_nikon_check_event (PTPParams* params, PTPContainer** event, int* evtcnt)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+        PTPContainer ptp;
+	uint16_t ret;
+	unsigned char *data = NULL;
+	unsigned int size = 0;
 
-	PTP_CNT_INIT(ptp, PTP_OC_NIKON_CheckEvent);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_NIKON_CheckEvent;
+	ptp.Nparam=0;
 	*evtcnt = 0;
-	CHECK_PTP_RC(ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ptp_unpack_Nikon_EC (params, data, size, event, evtcnt);
-	free (data);
-	return PTP_RC_OK;
+	ret = ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
+	if (ret == PTP_RC_OK) {
+		ptp_unpack_Nikon_EC (params, data, size, event, evtcnt);
+		free (data);
+	}
+	return ret;
 }
 
 /**
@@ -3226,7 +2448,9 @@
 {
         PTPContainer ptp;
         
-        PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetDevicePTPIPInfo);
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_NIKON_GetDevicePTPIPInfo;
+        ptp.Nparam=0;
         return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, size);
 }
 
@@ -3243,24 +2467,28 @@
 uint16_t
 ptp_nikon_getwifiprofilelist (PTPParams* params)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data;
-	unsigned int	size, pos, profn, n;
-	char		*buffer;
-	uint8_t		len;
-
-        PTP_CNT_INIT(ptp, PTP_OC_NIKON_GetProfileAllData);
+        PTPContainer ptp;
+	unsigned char* data;
+	unsigned int size;
+	unsigned int pos;
+	unsigned int profn;
+	unsigned int n;
+	char* buffer;
+	uint8_t len;
+	
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_NIKON_GetProfileAllData;
+        ptp.Nparam=0;
+	size = 0;
+	data = NULL;
 	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
 
-	ret = PTP_RC_Undefined; /* FIXME: Add more precise error code */
-
-	if (size < 2)
-		goto exit;
+	if (size < 2) return PTP_RC_Undefined; /* FIXME: Add more precise error code */
 
 	params->wifi_profiles_version = data[0];
 	params->wifi_profiles_number = data[1];
-	free(params->wifi_profiles);
+	if (params->wifi_profiles)
+		free(params->wifi_profiles);
 	
 	params->wifi_profiles = malloc(params->wifi_profiles_number*sizeof(PTPNIKONWifiProfile));
 	memset(params->wifi_profiles, 0, params->wifi_profiles_number*sizeof(PTPNIKONWifiProfile));
@@ -3268,15 +2496,13 @@
 	pos = 2;
 	profn = 0;
 	while (profn < params->wifi_profiles_number && pos < size) {
-		if (pos+6 >= size)
-			goto exit;
+		if (pos+6 >= size) return PTP_RC_Undefined;
 		params->wifi_profiles[profn].id = data[pos++];
 		params->wifi_profiles[profn].valid = data[pos++];
 
 		n = dtoh32a(&data[pos]);
 		pos += 4;
-		if (pos+n+4 >= size)
-			goto exit;
+		if (pos+n+4 >= size) return PTP_RC_Undefined;
 		strncpy(params->wifi_profiles[profn].profile_name, (char*)&data[pos], n);
 		params->wifi_profiles[profn].profile_name[16] = '\0';
 		pos += n;
@@ -3289,20 +2515,17 @@
 		strncpy(params->wifi_profiles[profn].creation_date, buffer, sizeof(params->wifi_profiles[profn].creation_date));
 		free (buffer);
 		pos += (len*2+1);
-		if (pos+1 >= size)
-			goto exit;
+		if (pos+1 >= size) return PTP_RC_Undefined;
 		/* FIXME: check if it is really last usage date */
 		buffer = ptp_unpack_string(params, data, pos, &len);
 		strncpy(params->wifi_profiles[profn].lastusage_date, buffer, sizeof(params->wifi_profiles[profn].lastusage_date));
 		free (buffer);
 		pos += (len*2+1);
-		if (pos+5 >= size)
-			goto exit;
+		if (pos+5 >= size) return PTP_RC_Undefined;
 		
 		n = dtoh32a(&data[pos]);
 		pos += 4;
-		if (pos+n >= size)
-			goto exit;
+		if (pos+n >= size) return PTP_RC_Undefined;
 		strncpy(params->wifi_profiles[profn].essid, (char*)&data[pos], n);
 		params->wifi_profiles[profn].essid[32] = '\0';
 		pos += n;
@@ -3324,11 +2547,8 @@
 
 	ptp_nikon_writewifiprofile(params, &test);
 #endif
-	/* everything went Ok */
-	ret = PTP_RC_OK;
-exit:
-	free (data);
-	return ret;
+
+	return PTP_RC_OK;
 }
 
 /**
@@ -3347,6 +2567,8 @@
 uint16_t
 ptp_nikon_writewifiprofile (PTPParams* params, PTPNIKONWifiProfile* profile)
 {
+	unsigned char guid[16];
+	
 	PTPContainer ptp;
 	unsigned char buffer[1024];
 	unsigned char* data = buffer;
@@ -3354,8 +2576,7 @@
 	int i;
 	uint8_t len;
 	int profilenr = -1;
-	unsigned char guid[16];
-
+	
 	ptp_nikon_getptpipguid(guid);
 
 	if (!params->wifi_profiles)
@@ -3390,11 +2611,9 @@
 	ptp_pack_string(params, "19990909T090909", data, 0x19, &len);
 	
 	/* IP parameters */
-	memcpy(&buffer[0x3A],&profile->ip_address,sizeof(profile->ip_address));
-	/**((unsigned int*)&buffer[0x3A]) = profile->ip_address; *//* Do not reverse bytes */
+	*((unsigned int*)&buffer[0x3A]) = profile->ip_address; /* Do not reverse bytes */
 	buffer[0x3E] = profile->subnet_mask;
-	memcpy(&buffer[0x3F],&profile->gateway_address,sizeof(profile->gateway_address));
-	/**((unsigned int*)&buffer[0x3F]) = profile->gateway_address; */ /* Do not reverse bytes */
+	*((unsigned int*)&buffer[0x3F]) = profile->gateway_address; /* Do not reverse bytes */
 	buffer[0x43] = profile->address_mode;
 	
 	/* Wifi parameters */
@@ -3426,7 +2645,10 @@
 	}
 	size = 0xC4;
 	       
-	PTP_CNT_INIT(ptp, PTP_OC_NIKON_SendProfileData, profilenr);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_NIKON_SendProfileData;
+	ptp.Nparam=1;
+	ptp.Param1=profilenr;
 	return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
 }
 
@@ -3447,15 +2669,20 @@
 ptp_mtp_getobjectpropssupported (PTPParams* params, uint16_t ofc,
 		 uint32_t *propnum, uint16_t **props
 ) {
-	PTPContainer	ptp;
-	unsigned char	*data = NULL;
-	unsigned int	xsize = 0;
-
-        PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjectPropsSupported, ofc);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &xsize));
-	*propnum=ptp_unpack_uint16_t_array (params, data, 0, xsize, props);
+        PTPContainer ptp;
+	uint16_t ret;
+	unsigned char *data = NULL;
+	unsigned int size = 0;
+        
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_MTP_GetObjectPropsSupported;
+        ptp.Nparam = 1;
+        ptp.Param1 = ofc;
+        ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
+	if (ret == PTP_RC_OK)
+        	*propnum=ptp_unpack_uint16_t_array(params,data,0,props);
 	free(data);
-	return PTP_RC_OK;
+	return ret;
 }
 
 /**
@@ -3474,15 +2701,21 @@
 ptp_mtp_getobjectpropdesc (
 	PTPParams* params, uint16_t opc, uint16_t ofc, PTPObjectPropDesc *opd
 ) {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
-
-        PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjectPropDesc, opc, ofc);
-        CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	ptp_unpack_OPD (params, data, opd, size);
+        PTPContainer ptp;
+	uint16_t ret;
+	unsigned char *data = NULL;
+	unsigned int size = 0;
+        
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_MTP_GetObjectPropDesc;
+        ptp.Nparam = 2;
+        ptp.Param1 = opc;
+        ptp.Param2 = ofc;
+        ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
+	if (ret == PTP_RC_OK)
+		ptp_unpack_OPD (params, data, opd, size);
 	free(data);
-	return PTP_RC_OK;
+	return ret;
 }
 
 /**
@@ -3502,17 +2735,20 @@
 	PTPParams* params, uint32_t oid, uint16_t opc,
 	PTPPropertyValue *value, uint16_t datatype
 ) {
-	PTPContainer	ptp;
-	uint16_t	ret = PTP_RC_OK;
-	unsigned char	*data;
-	unsigned int	size, offset = 0;
+        PTPContainer ptp;
+	uint16_t ret;
+	unsigned char *data = NULL;
+	unsigned int size = 0;
+	int offset = 0;
         
-        PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjectPropValue, oid, opc);
-        CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-        if (!ptp_unpack_DPV(params, data, &offset, size, value, datatype)) {
-                ptp_debug (params, "ptp_mtp_getobjectpropvalue: unpacking DPV failed");
-                ret = PTP_RC_GeneralError;
-        }
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_MTP_GetObjectPropValue;
+        ptp.Nparam = 2;
+        ptp.Param1 = oid;
+        ptp.Param2 = opc;
+        ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size);
+	if (ret == PTP_RC_OK)
+		ptp_unpack_DPV(params, data, &offset, size, value, datatype);
 	free(data);
 	return ret;
 }
@@ -3534,12 +2770,16 @@
 	PTPParams* params, uint32_t oid, uint16_t opc,
 	PTPPropertyValue *value, uint16_t datatype
 ) {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data = NULL;
-	uint32_t	size;
-
-        PTP_CNT_INIT(ptp, PTP_OC_MTP_SetObjectPropValue, oid, opc);
+        PTPContainer ptp;
+	uint16_t ret;
+	unsigned char *data = NULL;
+	unsigned int size ;
+        
+        PTP_CNT_INIT(ptp);
+        ptp.Code=PTP_OC_MTP_SetObjectPropValue;
+        ptp.Nparam = 2;
+        ptp.Param1 = oid;
+        ptp.Param2 = opc;
 	size = ptp_pack_DPV(params, value, &data, datatype);
         ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
 	free(data);
@@ -3549,94 +2789,116 @@
 uint16_t
 ptp_mtp_getobjectreferences (PTPParams* params, uint32_t handle, uint32_t** ohArray, uint32_t* arraylen)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	PTPContainer ptp;
+	uint16_t ret;
+	unsigned char* dpv=NULL;
+	unsigned int dpvlen = 0;
 
-	PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjectReferences, handle);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data , &size));
-	/* Sandisk Sansa skips the DATA phase, but returns OK as response.
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_MTP_GetObjectReferences;
+	ptp.Param1=handle;
+	ptp.Nparam=1;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, &dpvlen);
+	if (ret == PTP_RC_OK) {
+		/* Sandisk Sansa skips the DATA phase, but returns OK as response.
 		 * this will gives us a NULL here. Handle it. -Marcus */
-	if ((data == NULL) || (size == 0)) {
-		*arraylen = 0;
-		*ohArray = NULL;
-	} else {
-		*arraylen = ptp_unpack_uint32_t_array(params, data , 0, size, ohArray);
+		if ((dpv == NULL) || (dpvlen == 0)) {
+			*arraylen = 0;
+			*ohArray = NULL;
+		} else {
+			*arraylen = ptp_unpack_uint32_t_array(params, dpv, 0, ohArray);
+		}
 	}
-	free(data);
-	return PTP_RC_OK;
+	free(dpv);
+	return ret;
 }
 
 uint16_t
 ptp_mtp_setobjectreferences (PTPParams* params, uint32_t handle, uint32_t* ohArray, uint32_t arraylen)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data = NULL;
-	uint32_t	size;
+	PTPContainer ptp;
+	uint16_t ret;
+	uint32_t size;
+	unsigned char* dpv=NULL;
 
-	PTP_CNT_INIT(ptp, PTP_OC_MTP_SetObjectReferences, handle);
-	size = ptp_pack_uint32_t_array(params, ohArray, arraylen, &data);
-	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
-	free(data);
+	PTP_CNT_INIT(ptp);
+	ptp.Code   = PTP_OC_MTP_SetObjectReferences;
+	ptp.Param1 = handle;
+	ptp.Nparam = 1;
+	size = ptp_pack_uint32_t_array(params, ohArray, arraylen, &dpv);
+	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, (unsigned char **)&dpv, NULL);
+	free(dpv);
 	return ret;
 }
 
 uint16_t
 ptp_mtp_getobjectproplist (PTPParams* params, uint32_t handle, MTPProperties **props, int *nrofprops)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* opldata = NULL;
+	unsigned int oplsize;
 
-	PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjPropList, handle,
-		     0x00000000U,  /* 0x00000000U should be "all formats" */
-		     0xFFFFFFFFU,  /* 0xFFFFFFFFU should be "all properties" */
-		     0x00000000U,
-		     0xFFFFFFFFU  /* means - return full tree below the Param1 handle */
-	);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	*nrofprops = ptp_unpack_OPL(params, data, props, size);
-	free(data);
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code = PTP_OC_MTP_GetObjPropList;
+	ptp.Param1 = handle;
+	ptp.Param2 = 0x00000000U;  /* 0x00000000U should be "all formats" */
+	ptp.Param3 = 0xFFFFFFFFU;  /* 0xFFFFFFFFU should be "all properties" */
+	ptp.Param4 = 0x00000000U;
+	ptp.Param5 = 0xFFFFFFFFU;  /* means - return full tree below the Param1 handle */
+	ptp.Nparam = 5;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &opldata, &oplsize);  
+	if (ret == PTP_RC_OK) *nrofprops = ptp_unpack_OPL(params, opldata, props, oplsize);
+	if (opldata != NULL)
+		free(opldata);
+	return ret;
 }
 
 uint16_t
 ptp_mtp_getobjectproplist_single (PTPParams* params, uint32_t handle, MTPProperties **props, int *nrofprops)
 {
-	PTPContainer	ptp;
-	unsigned char	*data;
-	unsigned int	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* opldata = NULL;
+	unsigned int oplsize;
 
-	PTP_CNT_INIT(ptp, PTP_OC_MTP_GetObjPropList, handle,
-		     0x00000000U,  /* 0x00000000U should be "all formats" */
-		     0xFFFFFFFFU,  /* 0xFFFFFFFFU should be "all properties" */
-		     0x00000000U,
-		     0x00000000U  /* means - return single tree below the Param1 handle */
-	);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, &size));
-	*nrofprops = ptp_unpack_OPL(params, data, props, size);
-	free(data);
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code = PTP_OC_MTP_GetObjPropList;
+	ptp.Param1 = handle;
+	ptp.Param2 = 0x00000000U;  /* 0x00000000U should be "all formats" */
+	ptp.Param3 = 0xFFFFFFFFU;  /* 0xFFFFFFFFU should be "all properties" */
+	ptp.Param4 = 0x00000000U;
+	ptp.Param5 = 0x00000000U;  /* means - return single tree below the Param1 handle */
+	ptp.Nparam = 5;
+	ret = ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &opldata, &oplsize);  
+	if (ret == PTP_RC_OK) *nrofprops = ptp_unpack_OPL(params, opldata, props, oplsize);
+	if (opldata != NULL)
+		free(opldata);
+	return ret;
 }
 
 uint16_t
 ptp_mtp_sendobjectproplist (PTPParams* params, uint32_t* store, uint32_t* parenthandle, uint32_t* handle,
 			    uint16_t objecttype, uint64_t objectsize, MTPProperties *props, int nrofprops)
 {
-	PTPContainer	ptp;
-	uint16_t	ret;
-	unsigned char	*data = NULL;
-	uint32_t	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* opldata=NULL;
+	uint32_t oplsize;
 
-	PTP_CNT_INIT(ptp, PTP_OC_MTP_SendObjectPropList, *store, *parenthandle, (uint32_t) objecttype,
-		     (uint32_t) (objectsize >> 32), (uint32_t) (objectsize & 0xffffffffU)
-	);
+	PTP_CNT_INIT(ptp);
+	ptp.Code = PTP_OC_MTP_SendObjectPropList;
+	ptp.Param1 = *store;
+	ptp.Param2 = *parenthandle;
+	ptp.Param3 = (uint32_t) objecttype;
+	ptp.Param4 = (uint32_t) (objectsize >> 32);
+	ptp.Param5 = (uint32_t) (objectsize & 0xffffffffU);
+	ptp.Nparam = 5;
 
 	/* Set object handle to 0 for a new object */
-	size = ptp_pack_OPL(params,props,nrofprops,&data);
-	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL);
-	free(data);
+	oplsize = ptp_pack_OPL(params,props,nrofprops,&opldata);
+	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, oplsize, &opldata, NULL); 
+	free(opldata);
 	*store = ptp.Param1;
 	*parenthandle = ptp.Param2;
 	*handle = ptp.Param3; 
@@ -3647,15 +2909,20 @@
 uint16_t
 ptp_mtp_setobjectproplist (PTPParams* params, MTPProperties *props, int nrofprops)
 {
-	PTPContainer	ptp;
-	unsigned char	*data = NULL;
-	uint32_t	size;
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* opldata=NULL;
+	uint32_t oplsize;
+  
+	PTP_CNT_INIT(ptp);
+	ptp.Code = PTP_OC_MTP_SetObjPropList;
+	ptp.Nparam = 0;
+  
+	oplsize = ptp_pack_OPL(params,props,nrofprops,&opldata);
+	ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, oplsize, &opldata, NULL); 
+	free(opldata);
 
-	PTP_CNT_INIT(ptp, PTP_OC_MTP_SetObjPropList);
-	size = ptp_pack_OPL(params,props,nrofprops,&data);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, &data, NULL));
-	free(data);
-	return PTP_RC_OK;
+	return ret;
 }
 
 uint16_t
@@ -3663,7 +2930,8 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_MTP_WMDRMPD_SendWMDRMPDAppRequest);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_MTP_WMDRMPD_SendWMDRMPDAppRequest;
 	return ptp_transaction (params, &ptp, PTP_DP_SENDDATA, size, &appcertmsg, NULL);
 }
 
@@ -3672,7 +2940,8 @@
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_MTP_WMDRMPD_GetWMDRMPDAppResponse);
+	PTP_CNT_INIT(ptp);
+	ptp.Code = PTP_OC_MTP_WMDRMPD_GetWMDRMPDAppResponse;
 	*size = 0;
 	*response = NULL;
 	return ptp_transaction (params, &ptp, PTP_DP_GETDATA, 0, response, size);
@@ -3681,46 +2950,85 @@
 /****** CHDK interface ******/
 
 uint16_t
-ptp_chdk_get_memory(PTPParams* params, int start, int num, unsigned char **buf)
+ptp_chdk_get_memory(PTPParams* params, int start, int num, unsigned char **buf )
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_GetMemory, start, num);
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CHDK;
+	ptp.Nparam=3;
+	ptp.Param1=PTP_CHDK_GetMemory;
+	ptp.Param2=start;
+	ptp.Param3=num;
 	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, buf, NULL);
 }
 
-uint16_t
-ptp_chdk_set_memory_long(PTPParams* params, int addr, int val)
-{
-	PTPContainer ptp;
-	unsigned char *buf = (unsigned char *) &val; /* FIXME ... endianness? */
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_SetMemory, addr, 4);
-	return ptp_transaction(params, &ptp, PTP_DP_SENDDATA, 4, &buf, NULL);
+uint16_t
+ptp_chdk_call(PTPParams* params, int *args, int size, int *ret)
+{
+	uint16_t r;
+	PTPContainer ptp;
+
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CHDK;
+	ptp.Nparam=1;
+	ptp.Param1=PTP_CHDK_CallFunction;
+
+	/* FIXME: check int packing */
+	r=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size*sizeof(int), (unsigned char **) &args, NULL);
+	if ( r == PTP_RC_OK )
+		return r;
+	if ( ret )
+		*ret = ptp.Param1;
+	return r;
 }
 
 uint16_t
-ptp_chdk_download(PTPParams* params, char *remote_fn, PTPDataHandler *handler)
+ptp_chdk_get_propcase(PTPParams* params, int start, int num, int* ints)
 {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_TempData, 0);
-	CHECK_PTP_RC (ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(remote_fn), (unsigned char**)&remote_fn, NULL));
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CHDK;
+	ptp.Nparam=3;
+	ptp.Param1=PTP_CHDK_GetPropCase;
+	ptp.Param2=start;
+	ptp.Param3=num;
+	/* FIXME: unpack ints correctly */
+	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, (unsigned char**)ints, NULL);
+}
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_DownloadFile);
-	return ptp_transaction_new (params, &ptp, PTP_DP_GETDATA, 0, handler);
+uint16_t
+ptp_chdk_get_paramdata(PTPParams* params, int start, int num, unsigned char **buf)
+{
+	PTPContainer ptp;
+
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CHDK;
+	ptp.Nparam=3;
+	ptp.Param1=PTP_CHDK_GetParamData;
+	ptp.Param2=start;
+	ptp.Param3=num;
+	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, buf, NULL);
 }
 
 #if 0
-int ptp_chdk_upload(PTPParams* params, char *local_fn, char *remote_fn)
+int ptp_chdk_upload(char *local_fn, char *remote_fn, PTPParams* params, PTPDeviceInfo* deviceinfo)
 {
   uint16_t ret;
   PTPContainer ptp;
   char *buf = NULL;
   FILE *f;
-  unsigned file_len,data_len,file_name_len;
+  int s,l;
+  struct stat st_buf;
 
-  PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_UploadFile);
+  PTP_CNT_INIT(ptp);
+  ptp.Code=PTP_OC_CHDK;
+  ptp.Nparam=2;
+  ptp.Param1=PTP_CHDK_UploadFile;
+
+  if (stat(local_fn, &st_buf)==0) ptp.Param2=st_buf.st_mtime-_timezone-_daylight; else ptp.Param2=0;
 
   f = fopen(local_fn,"rb");
   if ( f == NULL )
@@ -3729,24 +3037,24 @@
     return 0;
   }
 
+
   fseek(f,0,SEEK_END);
-  file_len = ftell(f);
+  s = ftell(f);
   fseek(f,0,SEEK_SET);
 
-  file_name_len = strlen(remote_fn);
-  data_len = 4 + file_name_len + file_len;
-  buf = malloc(data_len);
-  memcpy(buf,&file_name_len,4);
-  memcpy(buf+4,remote_fn,file_name_len);
-  fread(buf+4+file_name_len,1,file_len,f);
+  l = strlen(remote_fn);
+  buf = malloc(4+l+s);
+  memcpy(buf,&l,4);
+  memcpy(buf+4,remote_fn,l);
+  fread(buf+4+l,1,s,f);
 
   fclose(f);
 
-  ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, data_len, &buf, NULL);
+  ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, 4+l+s, &buf);
 
   free(buf);
 
-  if ( ret != PTP_RC_OK )
+  if ( ret != 0x2001 )
   {
     ptp_error(params,"unexpected return code 0x%x",ret);
     return 0;
@@ -3754,223 +3062,230 @@
   return 1;
 }
 
+int ptp_chdk_download(char *remote_fn, char *local_fn, PTPParams* params, PTPDeviceInfo* deviceinfo)
+{
+  uint16_t ret;
+  PTPContainer ptp;
+  char *buf = NULL;
+  FILE *f;
+
+  PTP_CNT_INIT(ptp);
+  ptp.Code=PTP_OC_CHDK;
+  ptp.Nparam=1;
+  ptp.Param1=PTP_CHDK_TempData;
+  ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(remote_fn), &remote_fn);
+  if ( ret != 0x2001 )
+  {
+    ptp_error(params,"unexpected return code 0x%x",ret);
+    return 0;
+  }
+
+  PTP_CNT_INIT(ptp);
+  ptp.Code=PTP_OC_CHDK;
+  ptp.Nparam=1;
+  ptp.Param1=PTP_CHDK_DownloadFile;
+
+  ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buf);
+  if ( ret != 0x2001 )
+  {
+    ptp_error(params,"unexpected return code 0x%x",ret);
+    return 0;
+  }
+
+  f = fopen(local_fn,"wb");
+  if ( f == NULL )
+  {
+    ptp_error(params,"could not open file \'%s\'",local_fn);
+    free(buf);
+    return 0;
+  }
+
+  fwrite(buf,1,ptp.Param1,f);
+  fclose(f);
+
+  free(buf);
+
+  return 1;
+}
 #endif
 
-/*
- * Preliminary remote capture over USB code. Corresponding CHDK code is in the ptp-remote-capture-test
- * This is under development and should not be included in builds for general distribution
- */
-/*
- * isready: 0: not ready, lowest 2 bits: available image formats, 0x10000000: error
- */
 uint16_t
-ptp_chdk_rcisready(PTPParams* params, int *isready, int *imgnum)
+ptp_chdk_exec_lua(PTPParams* params, char *script, uint32_t *ret)
 {
+	uint16_t r;
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_RemoteCaptureIsReady);
-	*isready = *imgnum = 0;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	*isready=ptp.Param1;
-	*imgnum=ptp.Param2;
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CHDK;
+	ptp.Nparam=1;
+	ptp.Param1=PTP_CHDK_ExecuteLUA;
+	r=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(script)+1, (unsigned char**)&script, NULL);
+	if ( r != PTP_RC_OK )
+		return r;
+	*ret = ptp.Param1;
+	return r;
 }
 
 uint16_t
-ptp_chdk_rcgetchunk(PTPParams* params, int fmt, ptp_chdk_rc_chunk *chunk)
-{
+ptp_chdk_get_script_output(PTPParams* params, char** scriptoutput) {
 	PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_RemoteCaptureGetData, fmt); //get chunk
-
-	chunk->data = NULL;
-	chunk->size = 0;
-	chunk->offset = 0;
-	chunk->last = 0;
-	// TODO should allow ptp_getdata_transaction to send chunks directly to file, or to mem
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &chunk->data, NULL));
-	chunk->size = ptp.Param1;
-	chunk->last = (ptp.Param2 == 0);
-  	chunk->offset = ptp.Param3; //-1 for none
-	return PTP_RC_OK;
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CHDK;
+	ptp.Nparam=1;
+	ptp.Param1=PTP_CHDK_GetScriptOutput;
+	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, (unsigned char **)scriptoutput, NULL);
 }
 
-uint16_t
-ptp_chdk_exec_lua(PTPParams* params, char *script, int flags, int *script_id, int *status)
-{
-	PTPContainer ptp;
+#if 0
+void ptp_chdk_opendir(char *dir, PTPParams* params, PTPDeviceInfo* deviceinfo){
+  uint16_t ret;
+  PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_ExecuteScript, PTP_CHDK_SL_LUA | flags);
-	*script_id = 0;
-	*status = 0;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(script)+1, (unsigned char**)&script, NULL));
-	*script_id = ptp.Param1;
-	*status = ptp.Param2;
-	return PTP_RC_OK;
+  PTP_CNT_INIT(ptp);
+  ptp.Code=PTP_OC_CHDK;
+  ptp.Nparam=1;
+  ptp.Param1=PTP_CHDK_OpenDir;
+  ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(dir)+1, (char*)&dir);
+  if ( ret != 0x2001 )
+  {
+    ptp_error(params,"unexpected return code 0x%x",ret);
+    return;
+  }
 }
 
-uint16_t
-ptp_chdk_get_version(PTPParams* params, int *major, int *minor)
-{
-	PTPContainer ptp;
+void ptp_chdk_closedir(PTPParams* params, PTPDeviceInfo* deviceinfo){
+  uint16_t ret;
+  PTPContainer ptp;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_Version);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	*major = ptp.Param1;
-	*minor = ptp.Param2;
-	return PTP_RC_OK;
+  PTP_CNT_INIT(ptp);
+  ptp.Code=PTP_OC_CHDK;
+  ptp.Nparam=1;
+  ptp.Param1=PTP_CHDK_CloseDir;
+  ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL);
+  if ( ret != 0x2001 )
+  {
+    ptp_error(params,"unexpected return code 0x%x",ret);
+    return;
+  }
 }
 
-uint16_t
-ptp_chdk_get_script_status(PTPParams* params, unsigned *status)
-{
-	PTPContainer ptp;
+struct fileinfo* ptp_chdk_readdir(PTPParams* params, PTPDeviceInfo* deviceinfo){
+  uint16_t ret;
+  PTPContainer ptp;
+  char* buf=NULL;
+  static struct fileinfo fi;
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_ScriptStatus);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	*status = ptp.Param1;
-	return PTP_RC_OK;
-}
-uint16_t
-ptp_chdk_get_script_support(PTPParams* params, unsigned *status)
-{
-	PTPContainer ptp;
+  PTP_CNT_INIT(ptp);
+  ptp.Code=PTP_OC_CHDK;
+  ptp.Nparam=1;
+  ptp.Param1=PTP_CHDK_ReadDir;
+  ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buf);
+  if ( ret != 0x2001 )
+  {
+    ptp_error(params,"unexpected return code 0x%x",ret);
+    return NULL;
+  }
+  if (buf){
+   memcpy(&fi, buf, sizeof(fi));
+   free(buf);
+  }
 
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_ScriptSupport);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL, NULL));
-	*status = ptp.Param1;
-	return PTP_RC_OK;
+  return &fi;
+
 }
 
-uint16_t
-ptp_chdk_write_script_msg(PTPParams* params, char *data, unsigned size, int target_script_id, int *status)
-{
-	PTPContainer ptp;
+void ptp_chdk_download_alt_end(PTPParams* params, PTPDeviceInfo* deviceinfo){ // internal use
+  uint16_t ret;
+  PTPContainer ptp;
+  PTP_CNT_INIT(ptp);
+  ptp.Code=PTP_OC_CHDK;
+  ptp.Nparam=1;
+  ptp.Param1=PTP_CHDK_EndDownloadFile;
+  ret=ptp_transaction(params, &ptp, PTP_DP_NODATA, 0, NULL);
+  if ( ret != 0x2001 ) ptp_error(params,"unexpected return code 0x%x",ret);
+}
 
-	// a zero length data phase appears to do bad things, camera stops responding to PTP
-	if(!size) {
-		ptp_error(params,"zero length message not allowed");
-		*status = 0;
-		return PTP_ERROR_BADPARAM;
+int ptp_chdk_download_alt(char *remote_fn, char *local_fn, PTPParams* params, PTPDeviceInfo* deviceinfo)
+{
+  uint16_t ret;
+  PTPContainer ptp;
+  char *buf = NULL;
+  FILE *f;
+
+  PTP_CNT_INIT(ptp);
+  ptp.Code=PTP_OC_CHDK;
+  ptp.Nparam=1;
+  ptp.Param1=PTP_CHDK_StartDownloadFile;
+  ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, strlen(remote_fn)+1, &remote_fn);
+  if ( ret != 0x2001 )
+  {
+    ptp_error(params,"unexpected return code 0x%x",ret);
+    return 0;
+  }
+  f = fopen(local_fn,"wb");
+  if ( f == NULL )
+  {
+    ptp_error(params,"could not open file \'%s\'",local_fn);
+    return 0;
+  }
+
+  while(1) {
+   PTP_CNT_INIT(ptp);
+   ptp.Code=PTP_OC_CHDK;
+   ptp.Nparam=1;
+   ptp.Param1=PTP_CHDK_ResumeDownloadFile;
+   buf=NULL;
+   ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buf);
+   if ( ret != 0x2001 )
+   {
+     ptp_error(params,"unexpected return code 0x%x",ret);
+     ptp_chdk_download_alt_end(params, deviceinfo);
+     fclose(f);
+     return 0;
+   }
+
+   if (ptp.Param1<=0){free(buf); break;}
+   fwrite(buf, 1, ptp.Param1, f);
+   free(buf);
+  }
+  fclose(f);
+  ptp_chdk_download_alt_end(params, deviceinfo);
+  return 1;
+}
+#endif
+
+uint16_t
+ptp_chdk_get_video_settings(PTPParams* params, ptp_chdk_videosettings* vsettings)
+{
+	uint16_t ret;
+	PTPContainer ptp;
+	unsigned char* buf=NULL;
+
+	PTP_CNT_INIT(ptp);
+	ptp.Code=PTP_OC_CHDK;
+	ptp.Nparam=1;
+	ptp.Param1=PTP_CHDK_GetVideoSettings;
+	ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &buf, NULL);
+	if ( ret != PTP_RC_OK )
+		return ret;
+	if (buf) {
+		/* FIXME: endian convert */
+		memcpy(vsettings, buf, sizeof(ptp_chdk_videosettings));
+		free(buf);
 	}
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_WriteScriptMsg, target_script_id);
-	*status = 0;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, (unsigned char**)&data, NULL));
-	*status = ptp.Param1;
-	return PTP_RC_OK;
-}
-uint16_t
-ptp_chdk_read_script_msg(PTPParams* params, ptp_chdk_script_msg **msg)
-{
-	PTPContainer	ptp;
-	unsigned char	*data;
-
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_ReadScriptMsg);
-
-	*msg = NULL;
-
-	/* camera will always send data, otherwise getdata will cause problems */
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &data, NULL));
-
-	/* for convenience, always allocate an extra byte and null it*/
-	*msg = malloc(sizeof(ptp_chdk_script_msg) + ptp.Param4 + 1);
-	(*msg)->type = ptp.Param1;
-	(*msg)->subtype = ptp.Param2;
-	(*msg)->script_id = ptp.Param3;
-	(*msg)->size = ptp.Param4;
-	memcpy((*msg)->data,data,(*msg)->size);
-	(*msg)->data[(*msg)->size] = 0;
-	free(data);
-	return PTP_RC_OK;
-}
-
-uint16_t
-ptp_chdk_get_live_data(PTPParams* params, unsigned flags, unsigned char **data, unsigned int *data_size)
-{
-	PTPContainer ptp;
-
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_GetDisplayData, flags);
-	*data_size = 0;
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, data, NULL));
-	*data_size = ptp.Param1;
-	return PTP_RC_OK;
-}
-
-uint16_t
-ptp_chdk_call_function(PTPParams* params, int *args, int size, int *ret)
-{
-	PTPContainer ptp;
-
-	PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_CallFunction);
-	CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size*sizeof(int), (unsigned char **) &args, NULL));
-	if (ret)
-		*ret = ptp.Param1;
-	return PTP_RC_OK;
-}
-
-
-
-
-/**
- * Android MTP Extensions
- */
-
-/**
- * ptp_android_getpartialobject64:
- * params:	PTPParams*
- *		handle			- Object handle
- *		offset			- Offset into object
- *		maxbytes		- Maximum of bytes to read
- *		object			- pointer to data area
- *		len			- pointer to returned length
- *
- * Get object 'handle' from device and store the data in newly
- * allocated 'object'. Start from offset and read at most maxbytes.
- *
- * This is a 64bit offset version of the standard GetPartialObject.
- *
- * Return values: Some PTP_RC_* code.
- **/
-uint16_t
-ptp_android_getpartialobject64 (PTPParams* params, uint32_t handle, uint64_t offset,
-				uint32_t maxbytes, unsigned char** object,
-				uint32_t *len)
-{
-	PTPContainer ptp;
-
-	PTP_CNT_INIT(ptp, PTP_OC_ANDROID_GetPartialObject64, handle, offset & 0xFFFFFFFF, offset >> 32, maxbytes);
-	return ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, object, len);
-}
-
-uint16_t
-ptp_android_sendpartialobject (PTPParams* params, uint32_t handle, uint64_t offset,
-				unsigned char* object,	uint32_t len)
-{
-	PTPContainer	ptp;
-	uint16_t	ret;
-
-	PTP_CNT_INIT(ptp, PTP_OC_ANDROID_SendPartialObject, handle, offset & 0xFFFFFFFF, offset >> 32, len);
-
-	/*
-	 * MtpServer.cpp is buggy: it uses write() without offset
-	 * rather than pwrite to send the data for data coming with
-	 * the header packet
-	 */
-	params->split_header_data = 1;
-	ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, len, &object, NULL);
-	params->split_header_data = 0;
-
 	return ret;
 }
 
 
+
 /* Non PTP protocol functions */
 /* devinfo testing functions */
 
 int
 ptp_event_issupported(PTPParams* params, uint16_t event)
 {
-	unsigned int i=0;
+	int i=0;
 
 	for (;i<params->deviceinfo.EventsSupported_len;i++) {
 		if (params->deviceinfo.EventsSupported[i]==event)
@@ -3983,7 +3298,7 @@
 int
 ptp_property_issupported(PTPParams* params, uint16_t property)
 {
-	unsigned int i;
+	int i;
 
 	for (i=0;i<params->deviceinfo.DevicePropertiesSupported_len;i++)
 		if (params->deviceinfo.DevicePropertiesSupported[i]==property)
@@ -3991,6 +3306,88 @@
 	return 0;
 }
 
+/* ptp structures freeing functions */
+void
+ptp_free_devicepropvalue(uint16_t dt, PTPPropertyValue* dpd) {
+	switch (dt) {
+	case PTP_DTC_INT8:	case PTP_DTC_UINT8:
+	case PTP_DTC_UINT16:	case PTP_DTC_INT16:
+	case PTP_DTC_UINT32:	case PTP_DTC_INT32:
+	case PTP_DTC_UINT64:	case PTP_DTC_INT64:
+	case PTP_DTC_UINT128:	case PTP_DTC_INT128:
+		/* Nothing to free */
+		break;
+	case PTP_DTC_AINT8:	case PTP_DTC_AUINT8:
+	case PTP_DTC_AUINT16:	case PTP_DTC_AINT16:
+	case PTP_DTC_AUINT32:	case PTP_DTC_AINT32:
+	case PTP_DTC_AUINT64:	case PTP_DTC_AINT64:
+	case PTP_DTC_AUINT128:	case PTP_DTC_AINT128:
+		if (dpd->a.v)
+			free(dpd->a.v);
+		break;
+	case PTP_DTC_STR:
+		if (dpd->str)
+			free(dpd->str);
+		break;
+	}
+}
+
+void
+ptp_free_devicepropdesc(PTPDevicePropDesc* dpd)
+{
+	uint16_t i;
+
+	ptp_free_devicepropvalue (dpd->DataType, &dpd->FactoryDefaultValue);
+	ptp_free_devicepropvalue (dpd->DataType, &dpd->CurrentValue);
+	switch (dpd->FormFlag) {
+	case PTP_DPFF_Range:
+		ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.MinimumValue);
+		ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.MaximumValue);
+		ptp_free_devicepropvalue (dpd->DataType, &dpd->FORM.Range.StepSize);
+		break;
+	case PTP_DPFF_Enumeration:
+		if (dpd->FORM.Enum.SupportedValue) {
+			for (i=0;i<dpd->FORM.Enum.NumberOfValues;i++)
+				ptp_free_devicepropvalue (dpd->DataType, dpd->FORM.Enum.SupportedValue+i);
+			free (dpd->FORM.Enum.SupportedValue);
+		}
+	}
+}
+
+void
+ptp_free_objectpropdesc(PTPObjectPropDesc* opd)
+{
+	uint16_t i;
+
+	ptp_free_devicepropvalue (opd->DataType, &opd->FactoryDefaultValue);
+	switch (opd->FormFlag) {
+	case PTP_OPFF_None:
+		break;
+	case PTP_OPFF_Range:
+		ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.MinimumValue);
+		ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.MaximumValue);
+		ptp_free_devicepropvalue (opd->DataType, &opd->FORM.Range.StepSize);
+		break;
+	case PTP_OPFF_Enumeration:
+		if (opd->FORM.Enum.SupportedValue) {
+			for (i=0;i<opd->FORM.Enum.NumberOfValues;i++)
+				ptp_free_devicepropvalue (opd->DataType, opd->FORM.Enum.SupportedValue+i);
+			free (opd->FORM.Enum.SupportedValue);
+		}
+		break;
+	case PTP_OPFF_DateTime:
+	case PTP_OPFF_FixedLengthArray:
+	case PTP_OPFF_RegularExpression:
+	case PTP_OPFF_ByteArray:
+	case PTP_OPFF_LongString:
+		/* Ignore these presently, we cannot unpack them, so there is nothing to be freed. */
+		break;
+	default:
+		fprintf (stderr, "Unknown OPFF type %d\n", opd->FormFlag);
+		break;
+	}
+}
+
 void
 ptp_free_objectinfo (PTPObjectInfo *oi)
 {
@@ -4002,7 +3399,7 @@
 void
 ptp_free_object (PTPObject *ob)
 {
-	unsigned int i;
+	int i;
 	if (!ob) return;
 
 	ptp_free_objectinfo (&ob->oi);
@@ -4011,91 +3408,75 @@
 	ob->flags = 0;
 }
 
-/* PTP error descriptions */
-static struct {
-	uint16_t rc;
-	uint16_t vendor;
-	const char *txt;
-} ptp_errors[] = {
-	{PTP_RC_Undefined,		0, N_("PTP Undefined Error")},
-	{PTP_RC_OK,			0, N_("PTP OK!")},
-	{PTP_RC_GeneralError,		0, N_("PTP General Error")},
-	{PTP_RC_SessionNotOpen,		0, N_("PTP Session Not Open")},
-	{PTP_RC_InvalidTransactionID,	0, N_("PTP Invalid Transaction ID")},
-	{PTP_RC_OperationNotSupported,	0, N_("PTP Operation Not Supported")},
-	{PTP_RC_ParameterNotSupported,	0, N_("PTP Parameter Not Supported")},
-	{PTP_RC_IncompleteTransfer,	0, N_("PTP Incomplete Transfer")},
-	{PTP_RC_InvalidStorageId,	0, N_("PTP Invalid Storage ID")},
-	{PTP_RC_InvalidObjectHandle,	0, N_("PTP Invalid Object Handle")},
-	{PTP_RC_DevicePropNotSupported,	0, N_("PTP Device Prop Not Supported")},
-	{PTP_RC_InvalidObjectFormatCode,0, N_("PTP Invalid Object Format Code")},
-	{PTP_RC_StoreFull,		0, N_("PTP Store Full")},
-	{PTP_RC_ObjectWriteProtected,	0, N_("PTP Object Write Protected")},
-	{PTP_RC_StoreReadOnly,		0, N_("PTP Store Read Only")},
-	{PTP_RC_AccessDenied,		0, N_("PTP Access Denied")},
-	{PTP_RC_NoThumbnailPresent,	0, N_("PTP No Thumbnail Present")},
-	{PTP_RC_SelfTestFailed,		0, N_("PTP Self Test Failed")},
-	{PTP_RC_PartialDeletion,	0, N_("PTP Partial Deletion")},
-	{PTP_RC_StoreNotAvailable,	0, N_("PTP Store Not Available")},
-	{PTP_RC_SpecificationByFormatUnsupported, 0, N_("PTP Specification By Format Unsupported")},
-	{PTP_RC_NoValidObjectInfo,	0, N_("PTP No Valid Object Info")},
-	{PTP_RC_InvalidCodeFormat,	0, N_("PTP Invalid Code Format")},
-	{PTP_RC_UnknownVendorCode,	0, N_("PTP Unknown Vendor Code")},
-	{PTP_RC_CaptureAlreadyTerminated, 0, N_("PTP Capture Already Terminated")},
-	{PTP_RC_DeviceBusy,		0, N_("PTP Device Busy")},
-	{PTP_RC_InvalidParentObject,	0, N_("PTP Invalid Parent Object")},
-	{PTP_RC_InvalidDevicePropFormat,0, N_("PTP Invalid Device Prop Format")},
-	{PTP_RC_InvalidDevicePropValue,	0, N_("PTP Invalid Device Prop Value")},
-	{PTP_RC_InvalidParameter,	0, N_("PTP Invalid Parameter")},
-	{PTP_RC_SessionAlreadyOpened,	0, N_("PTP Session Already Opened")},
-	{PTP_RC_TransactionCanceled,	0, N_("PTP Transaction Canceled")},
-	{PTP_RC_SpecificationOfDestinationUnsupported, 0, N_("PTP Specification Of Destination Unsupported")},
+const char *
+ptp_strerror(uint16_t error) {
 
-	{PTP_RC_EK_FilenameRequired,	PTP_VENDOR_EASTMAN_KODAK, N_("Filename Required")},
-	{PTP_RC_EK_FilenameConflicts,	PTP_VENDOR_EASTMAN_KODAK, N_("Filename Conflicts")},
-	{PTP_RC_EK_FilenameInvalid,	PTP_VENDOR_EASTMAN_KODAK, N_("Filename Invalid")},
+	int i;
+	/* PTP error descriptions */
+	static struct {
+		short n;
+		const char *txt;
+	} ptp_errors[] = {
+	{PTP_RC_Undefined, 		N_("PTP: Undefined Error")},
+	{PTP_RC_OK, 			N_("PTP: OK!")},
+	{PTP_RC_GeneralError, 		N_("PTP: General Error")},
+	{PTP_RC_SessionNotOpen, 	N_("PTP: Session Not Open")},
+	{PTP_RC_InvalidTransactionID, 	N_("PTP: Invalid Transaction ID")},
+	{PTP_RC_OperationNotSupported, 	N_("PTP: Operation Not Supported")},
+	{PTP_RC_ParameterNotSupported, 	N_("PTP: Parameter Not Supported")},
+	{PTP_RC_IncompleteTransfer, 	N_("PTP: Incomplete Transfer")},
+	{PTP_RC_InvalidStorageId, 	N_("PTP: Invalid Storage ID")},
+	{PTP_RC_InvalidObjectHandle, 	N_("PTP: Invalid Object Handle")},
+	{PTP_RC_DevicePropNotSupported, N_("PTP: Device Prop Not Supported")},
+	{PTP_RC_InvalidObjectFormatCode, N_("PTP: Invalid Object Format Code")},
+	{PTP_RC_StoreFull, 		N_("PTP: Store Full")},
+	{PTP_RC_ObjectWriteProtected, 	N_("PTP: Object Write Protected")},
+	{PTP_RC_StoreReadOnly, 		N_("PTP: Store Read Only")},
+	{PTP_RC_AccessDenied,		N_("PTP: Access Denied")},
+	{PTP_RC_NoThumbnailPresent, 	N_("PTP: No Thumbnail Present")},
+	{PTP_RC_SelfTestFailed, 	N_("PTP: Self Test Failed")},
+	{PTP_RC_PartialDeletion, 	N_("PTP: Partial Deletion")},
+	{PTP_RC_StoreNotAvailable, 	N_("PTP: Store Not Available")},
+	{PTP_RC_SpecificationByFormatUnsupported,
+				N_("PTP: Specification By Format Unsupported")},
+	{PTP_RC_NoValidObjectInfo, 	N_("PTP: No Valid Object Info")},
+	{PTP_RC_InvalidCodeFormat, 	N_("PTP: Invalid Code Format")},
+	{PTP_RC_UnknownVendorCode, 	N_("PTP: Unknown Vendor Code")},
+	{PTP_RC_CaptureAlreadyTerminated,
+					N_("PTP: Capture Already Terminated")},
+	{PTP_RC_DeviceBusy, 		N_("PTP: Device Busy")},
+	{PTP_RC_InvalidParentObject, 	N_("PTP: Invalid Parent Object")},
+	{PTP_RC_InvalidDevicePropFormat, N_("PTP: Invalid Device Prop Format")},
+	{PTP_RC_InvalidDevicePropValue, N_("PTP: Invalid Device Prop Value")},
+	{PTP_RC_InvalidParameter, 	N_("PTP: Invalid Parameter")},
+	{PTP_RC_SessionAlreadyOpened, 	N_("PTP: Session Already Opened")},
+	{PTP_RC_TransactionCanceled, 	N_("PTP: Transaction Canceled")},
+	{PTP_RC_SpecificationOfDestinationUnsupported,
+			N_("PTP: Specification Of Destination Unsupported")},
+	{PTP_RC_EK_FilenameRequired,	N_("PTP: EK Filename Required")},
+	{PTP_RC_EK_FilenameConflicts,	N_("PTP: EK Filename Conflicts")},
+	{PTP_RC_EK_FilenameInvalid,	N_("PTP: EK Filename Invalid")},
 
-	{PTP_RC_NIKON_HardwareError,		PTP_VENDOR_NIKON, N_("Hardware Error")},
-	{PTP_RC_NIKON_OutOfFocus,		PTP_VENDOR_NIKON, N_("Out of Focus")},
-	{PTP_RC_NIKON_ChangeCameraModeFailed,	PTP_VENDOR_NIKON, N_("Change Camera Mode Failed")},
-	{PTP_RC_NIKON_InvalidStatus,		PTP_VENDOR_NIKON, N_("Invalid Status")},
-	{PTP_RC_NIKON_SetPropertyNotSupported,	PTP_VENDOR_NIKON, N_("Set Property Not Supported")},
-	{PTP_RC_NIKON_WbResetError,		PTP_VENDOR_NIKON, N_("Whitebalance Reset Error")},
-	{PTP_RC_NIKON_DustReferenceError,	PTP_VENDOR_NIKON, N_("Dust Reference Error")},
-	{PTP_RC_NIKON_ShutterSpeedBulb,		PTP_VENDOR_NIKON, N_("Shutter Speed Bulb")},
-	{PTP_RC_NIKON_MirrorUpSequence,		PTP_VENDOR_NIKON, N_("Mirror Up Sequence")},
-	{PTP_RC_NIKON_CameraModeNotAdjustFNumber, PTP_VENDOR_NIKON, N_("Camera Mode Not Adjust FNumber")},
-	{PTP_RC_NIKON_NotLiveView,		PTP_VENDOR_NIKON, N_("Not in Liveview")},
-	{PTP_RC_NIKON_MfDriveStepEnd,		PTP_VENDOR_NIKON, N_("Mf Drive Step End")},
-	{PTP_RC_NIKON_MfDriveStepInsufficiency,	PTP_VENDOR_NIKON, N_("Mf Drive Step Insufficiency")},
-	{PTP_RC_NIKON_AdvancedTransferCancel,	PTP_VENDOR_NIKON, N_("Advanced Transfer Cancel")},
-
-	{PTP_RC_CANON_UNKNOWN_COMMAND,	PTP_VENDOR_CANON, N_("Unknown Command")},
-	{PTP_RC_CANON_OPERATION_REFUSED,PTP_VENDOR_CANON, N_("Operation Refused")},
-	{PTP_RC_CANON_LENS_COVER,	PTP_VENDOR_CANON, N_("Lens Cover Present")},
-	{PTP_RC_CANON_BATTERY_LOW,	PTP_VENDOR_CANON, N_("Battery Low")},
-	{PTP_RC_CANON_NOT_READY,	PTP_VENDOR_CANON, N_("Camera Not Ready")},
-
-	{PTP_ERROR_TIMEOUT,		0, N_("PTP Timeout")},
-	{PTP_ERROR_CANCEL,		0, N_("PTP Cancel Request")},
-	{PTP_ERROR_BADPARAM,		0, N_("PTP Invalid Parameter")},
-	{PTP_ERROR_RESP_EXPECTED,	0, N_("PTP Response Expected")},
-	{PTP_ERROR_DATA_EXPECTED,	0, N_("PTP Data Expected")},
-	{PTP_ERROR_IO,			0, N_("PTP I/O Error")},
-	{0, 0, NULL}
+	{PTP_ERROR_IO,		  N_("PTP: I/O error")},
+	{PTP_ERROR_BADPARAM,	  N_("PTP: Error: bad parameter")},
+	{PTP_ERROR_DATA_EXPECTED, N_("PTP: Protocol error, data expected")},
+	{PTP_ERROR_RESP_EXPECTED, N_("PTP: Protocol error, response expected")},
+	{0, NULL}
 };
 
-const char *
-ptp_strerror(uint16_t ret, uint16_t vendor)
-{
-	int i;
-
-	for (i=0; ptp_errors[i].txt != NULL; i++)
-		if ((ptp_errors[i].rc == ret) && ((ptp_errors[i].vendor == 0) || (ptp_errors[i].vendor == vendor)))
+	for (i=0; ptp_errors[i].txt!=NULL; i++)
+		if (ptp_errors[i].n == error)
 			return ptp_errors[i].txt;
 	return NULL;
 }
 
+void
+ptp_perror(PTPParams* params, uint16_t error) {
+	const char *txt = ptp_strerror(error);
+	if (txt != NULL)
+		ptp_error(params, txt);
+}
+
 const char*
 ptp_get_property_description(PTPParams* params, uint16_t dpc)
 {
@@ -4139,19 +3520,6 @@
 		{PTP_DPC_UploadURL,		N_("Upload URL")},
 		{PTP_DPC_Artist,		N_("Artist")},
 		{PTP_DPC_CopyrightInfo,		N_("Copyright Info")},
-		{PTP_DPC_SupportedStreams,	N_("Supported Streams")},
-		{PTP_DPC_EnabledStreams,	N_("Enabled Streams")},
-		{PTP_DPC_VideoFormat,		N_("Video Format")},
-		{PTP_DPC_VideoResolution,	N_("Video Resolution")},
-		{PTP_DPC_VideoQuality,		N_("Video Quality")},
-		{PTP_DPC_VideoFrameRate,	N_("Video Framerate")},
-		{PTP_DPC_VideoContrast,		N_("Video Contrast")},
-		{PTP_DPC_VideoBrightness,	N_("Video Brightness")},
-		{PTP_DPC_AudioFormat,		N_("Audio Format")},
-		{PTP_DPC_AudioBitrate,		N_("Audio Bitrate")},
-		{PTP_DPC_AudioSamplingRate,	N_("Audio Samplingrate")},
-		{PTP_DPC_AudioBitPerSample,	N_("Audio Bits per sample")},
-		{PTP_DPC_AudioVolume,		N_("Audio Volume")},
 		{0,NULL}
 	};
 	struct {
@@ -4323,14 +3691,6 @@
 		 N_("Color Space")},
 		{PTP_DPC_NIKON_AutoDXCrop,			/* 0xD033 */
 		 N_("Auto DX Crop")},
-		{PTP_DPC_NIKON_FlickerReduction,		/* 0xD034 */
-		 N_("Flicker Reduction")},
-		{PTP_DPC_NIKON_RemoteMode,			/* 0xD035 */
-		 N_("Remote Mode")},
-		{PTP_DPC_NIKON_VideoMode,			/* 0xD036 */
-		 N_("Video Mode")},
-		{PTP_DPC_NIKON_EffectMode,			/* 0xD037 */
-		 N_("Effect Mode")},
 		{PTP_DPC_NIKON_CSMMenuBankSelect,		/* 0xD040 */
 		 "PTP_DPC_NIKON_CSMMenuBankSelect"},
 		{PTP_DPC_NIKON_MenuBankNameA,			/* 0xD041 */
@@ -4476,8 +3836,6 @@
 		 N_("AF Area Point")},
 		{PTP_DPC_NIKON_NormalAFOn,			/* 0xD08E */
 		 N_("Normal AF On")},
-		{PTP_DPC_NIKON_CleanImageSensor,		/* 0xD08F */
-		 N_("Clean Image Sensor")},
 		{PTP_DPC_NIKON_ImageCommentString,		/* 0xD090 */
 		 N_("Image Comment String")},
 		{PTP_DPC_NIKON_ImageCommentEnable,		/* 0xD091 */
@@ -4490,16 +3848,6 @@
 		 N_("Movie Screen Size")},
 		{PTP_DPC_NIKON_MovVoice,			/* 0xD0A1 */
 		 N_("Movie Voice")},
-		{PTP_DPC_NIKON_MovMicrophone,			/* 0xD0A2 */
-		 N_("Movie Microphone")},
-		{PTP_DPC_NIKON_MovFileSlot,			/* 0xD0A3 */
-		 N_("Movie Card Slot")},
-		{PTP_DPC_NIKON_ManualMovieSetting,		/* 0xD0A6 */
-		 N_("Manual Movie Setting")},
-		{PTP_DPC_NIKON_MovQuality,			/* 0xD0A7 */
-		 N_("Movie Quality")},
-		{PTP_DPC_NIKON_MonitorOffDelay,			/* 0xD0B3 */
-		 N_("Monitor Off Delay")},
 		{PTP_DPC_NIKON_Bracketing,			/* 0xD0C0 */
 		 N_("Bracketing Enable")},
 		{PTP_DPC_NIKON_AutoExposureBracketStep,		/* 0xD0C1 */
@@ -4538,8 +3886,6 @@
 		 N_("Vignette Control")},
 		{PTP_DPC_NIKON_AutoDistortionControl,		/* 0xD0F8 */
 		 N_("Auto Distortion Control")},
-		{PTP_DPC_NIKON_SceneMode,			/* 0xD0F9 */
-		 N_("Scene Mode")},
 		{PTP_DPC_NIKON_ExposureTime,			/* 0xD100 */
 		 N_("Nikon Exposure Time")},
 		{PTP_DPC_NIKON_ACPower, N_("AC Power")},	/* 0xD101 */
@@ -4615,8 +3961,8 @@
 		 N_("Slot 2 Save Mode")},
 		{PTP_DPC_NIKON_RawBitMode,			/* 0xD149 */
 		 N_("Raw Bit Mode")},
-		{PTP_DPC_NIKON_ActiveDLighting,			/* 0xD14E */
-		 N_("Active D-Lighting")},
+		{PTP_DPC_NIKON_ISOAutoTime,			/* 0xD14E */
+		 N_("ISO Auto Time")},
 		{PTP_DPC_NIKON_FlourescentType,			/* 0xD14F */
 		 N_("Flourescent Type")},
 		{PTP_DPC_NIKON_TuneColourTemperature,		/* 0xD150 */
@@ -4649,7 +3995,7 @@
 		 N_("Flash Commander Mode")},
 		{PTP_DPC_NIKON_FlashSign,			/* 0xD169 */
 		 N_("Flash Sign")},
-		{PTP_DPC_NIKON_ISO_Auto,			/* 0xD16A */
+		{PTP_DPC_NIKON_ISOAuto,				/* 0xD16A */
 		 N_("ISO Auto")},
 		{PTP_DPC_NIKON_RemoteTimeout,			/* 0xD16B */
 		 N_("Remote Timeout")},
@@ -4701,9 +4047,7 @@
 		 N_("Exposure Display Status")},
 		{PTP_DPC_NIKON_ExposureIndicateStatus,		/* 0xD1B1 */
 		 N_("Exposure Indicate Status")},
-		{PTP_DPC_NIKON_InfoDispErrStatus,		/* 0xD1B2 */
-		 N_("Info Display Error Status")},
-		{PTP_DPC_NIKON_ExposureIndicateLightup,		/* 0xD1B3 */
+		{PTP_DPC_NIKON_ExposureIndicateLightup,		/* 0xD1B2 */
 		 N_("Exposure Indicate Lightup")},
 		{PTP_DPC_NIKON_FlashOpen,			/* 0xD1C0 */
 		 N_("Flash Open")},
@@ -4739,23 +4083,6 @@
 		 N_("Active Pic Ctrl Item")},
 		{PTP_DPC_NIKON_ChangePicCtrlItem,		/* 0xD201 */
 		 N_("Change Pic Ctrl Item")},
-		/* nikon 1 stuff */
-		{PTP_DPC_NIKON_1_ISO,				/* 0xf002 */
-		 N_("ISO")},
-		{PTP_DPC_NIKON_1_ImageSize,			/* 0xf00a */
-		 N_("Image Size")},
-		{PTP_DPC_NIKON_1_LongExposureNoiseReduction,    /* 0xF00D */
-		 N_("Long Exposure Noise Reduction")},
-		{PTP_DPC_NIKON_1_MovQuality,                    /* 0xF01C */
-		 N_("Movie Quality")},
-		{PTP_DPC_NIKON_1_HiISONoiseReduction,           /* 0xF00E */
-		 N_("High ISO Noise Reduction")},
-		{PTP_DPC_NIKON_1_WhiteBalance,           	/* 0xF00C */
-		 N_("White Balance")},
-		{PTP_DPC_NIKON_1_ImageCompression,           	/* 0xF009 */
-		 N_("Image Compression")},
-		{PTP_DPC_NIKON_1_ActiveDLighting,           	/* 0xF00F */
-		 N_("Active D-Lighting")},
 		{0,NULL}
 	};
         struct {
@@ -4795,27 +4122,6 @@
 		{0,NULL}
         };
 
-        struct {
-		uint16_t dpc;
-		const char *txt;
-        } ptp_device_properties_SONY[] = {
-		{PTP_DPC_SONY_DPCCompensation, ("DOC Compensation")},	/* 0xD200 */
-		{PTP_DPC_SONY_DRangeOptimize, ("DRangeOptimize")},	/* 0xD201 */
-		{PTP_DPC_SONY_ImageSize, N_("Image size")},		/* 0xD203 */
-		{PTP_DPC_SONY_ShutterSpeed, N_("Shutter speed")},	/* 0xD20D */
-		{PTP_DPC_SONY_ColorTemp, N_("Color temperature")},	/* 0xD20F */
-		{PTP_DPC_SONY_CCFilter, ("CC Filter")},			/* 0xD210 */
-		{PTP_DPC_SONY_AspectRatio, N_("Aspect Ratio")}, 	/* 0xD211 */
-		{PTP_DPC_SONY_ExposeIndex, N_("Expose Index")},		/* 0xD216 */
-		{PTP_DPC_SONY_PictureEffect, N_("Picture Effect")},	/* 0xD21B */
-		{PTP_DPC_SONY_ABFilter, N_("AB Filter")},		/* 0xD21C */
-		{PTP_DPC_SONY_ISO, N_("ISO")},				/* 0xD21E */
-		{PTP_DPC_SONY_Movie, N_("Movie")},			/* 0xD2C8 */
-		{PTP_DPC_SONY_StillImage, N_("Still Image")},		/* 0xD2C7 */
-		{0,NULL}
-        };
-
-
 	for (i=0; ptp_device_properties[i].txt!=NULL; i++)
 		if (ptp_device_properties[i].dpc==dpc)
 			return (ptp_device_properties[i].txt);
@@ -4846,11 +4152,6 @@
 			if (ptp_device_properties_FUJI[i].dpc==dpc)
 				return (ptp_device_properties_FUJI[i].txt);
 
-	if (params->deviceinfo.VendorExtensionID==PTP_VENDOR_SONY)
-		for (i=0; ptp_device_properties_SONY[i].txt!=NULL; i++)
-			if (ptp_device_properties_SONY[i].dpc==dpc)
-				return (ptp_device_properties_SONY[i].txt);
-
 	return NULL;
 }
 
@@ -4900,9 +4201,9 @@
 
 int
 ptp_render_property_value(PTPParams* params, uint16_t dpc,
-			  PTPDevicePropDesc *dpd, unsigned int length, char *out)
+			  PTPDevicePropDesc *dpd, int length, char *out)
 {
-	unsigned int i;
+	int i;
 	int64_t	kval;
 
 	struct {
@@ -4933,7 +4234,6 @@
 		{PTP_DPC_NIKON_MaxApAtMaxFocalLength, PTP_VENDOR_NIKON, 0.01, 0.0, "f/%.2g"}, /* D0E6 */
 		{PTP_DPC_NIKON_ExternalFlashCompensation, PTP_VENDOR_NIKON, 1.0/6.0, 0.0,"%.0f"}, /* D124 */
 		{PTP_DPC_NIKON_ExposureIndicateStatus, PTP_VENDOR_NIKON, 0.08333, 0.0, N_("%.1f stops")},/* D1B1 - FIXME: check if correct. */
-		{PTP_DPC_NIKON_AngleLevel, PTP_VENDOR_NIKON, 1.0/65536, 0.0, "%.1f'"},/* 0xD067 */
 		{0, 0, 0.0, 0.0, NULL}
 	};
 
@@ -5143,9 +4443,6 @@
 		{PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 1, "Show ISO/Easy ISO"},
 		{PTP_DPC_NIKON_FinderISODisp, PTP_VENDOR_NIKON, 2, "Show frame count"},
 
-		{PTP_DPC_NIKON_RawCompression, PTP_VENDOR_NIKON, 0, N_("Lossless")},	/* D016 */
-		{PTP_DPC_NIKON_RawCompression, PTP_VENDOR_NIKON, 1, N_("Lossy")},
-
 		PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ACPower,PTP_VENDOR_NIKON),		/* D101 */
 		PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AFLockStatus,PTP_VENDOR_NIKON),		/* D104 */
 		PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_AELockStatus,PTP_VENDOR_NIKON),		/* D105 */
@@ -5284,22 +4581,6 @@
 		PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashOpen,PTP_VENDOR_NIKON),		/* D1C0 */
 		PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_FlashCharged,PTP_VENDOR_NIKON),		/* D1C1 */
 
-		PTP_VENDOR_VAL_YN(PTP_DPC_NIKON_ManualMovieSetting,PTP_VENDOR_NIKON),	/* 0xD0A6 */
-
-		{PTP_DPC_NIKON_FlickerReduction, PTP_VENDOR_NIKON, 0, "50Hz"},		/* 0xD034 */
-		{PTP_DPC_NIKON_FlickerReduction, PTP_VENDOR_NIKON, 1, "60Hz"},
-
-		{PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 0, N_("Delayed Remote")},	/* 0xD035 */
-		{PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 1, N_("Quick Response")},	/* 0xD035 */
-		{PTP_DPC_NIKON_RemoteMode, PTP_VENDOR_NIKON, 2, N_("Remote Mirror Up")},/* 0xD035 */
-
-		{PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 0, "5min"},	/* 0xD0b3 */
-		{PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 1, "10min"},	/* 0xD0b3 */
-		{PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 2, "15min"},	/* 0xD0b3 */
-		{PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 3, "20min"},	/* 0xD0b3 */
-		{PTP_DPC_NIKON_MonitorOffDelay, PTP_VENDOR_NIKON, 4, "30min"},	/* 0xD0b3 */
-
-
 		/* Canon stuff */
 		PTP_VENDOR_VAL_BOOL(PTP_DPC_CANON_AssistLight,PTP_VENDOR_CANON),
 		PTP_VENDOR_VAL_RBOOL(PTP_DPC_CANON_RotationScene,PTP_VENDOR_CANON),
@@ -5663,8 +4944,8 @@
 int
 ptp_render_ofc(PTPParams* params, uint16_t ofc, int spaceleft, char *txt)
 {
-	unsigned int i;
-
+	int i;
+	
 	if (!(ofc & 0x8000)) {
 		for (i=0;i<sizeof(ptp_ofc_trans)/sizeof(ptp_ofc_trans[0]);i++)
 			if (ofc == ptp_ofc_trans[i].ofc)
@@ -5699,14 +4980,12 @@
 	return snprintf (txt, spaceleft,_("Unknown(%04x)"), ofc);
 }
 
-typedef struct {
+struct {
 	uint16_t opcode;
 	const char *name;
-} ptp_opcode_trans_t;
-
-ptp_opcode_trans_t ptp_opcode_trans[] = {
+} ptp_opcode_trans[] = {
 	{PTP_OC_Undefined,N_("Undefined")},
-	{PTP_OC_GetDeviceInfo,N_("Get device info")},
+	{PTP_OC_GetDeviceInfo,N_("get device info")},
 	{PTP_OC_OpenSession,N_("Open session")},
 	{PTP_OC_CloseSession,N_("Close session")},
 	{PTP_OC_GetStorageIDs,N_("Get storage IDs")},
@@ -5733,20 +5012,13 @@
 	{PTP_OC_MoveObject,N_("Move object")},
 	{PTP_OC_CopyObject,N_("Copy object")},
 	{PTP_OC_GetPartialObject,N_("Get partial object")},
-	{PTP_OC_InitiateOpenCapture,N_("Initiate open capture")},
-	/* PTP v1.1 operation codes */
-	{PTP_OC_StartEnumHandles,N_("Start Enumerate Handles")},
-	{PTP_OC_EnumHandles,N_("Enumerate Handles")},
-	{PTP_OC_StopEnumHandles,N_("Stop Enumerate Handles")},
-	{PTP_OC_GetVendorExtensionMaps,N_("Get Vendor Extension Maps")},
-	{PTP_OC_GetVendorDeviceInfo,N_("Get Vendor Device Info")},
-	{PTP_OC_GetResizedImageObject,N_("Get Resized Image Object")},
-	{PTP_OC_GetFilesystemManifest,N_("Get Filesystem Manifest")},
-	{PTP_OC_GetStreamInfo,N_("Get Stream Info")},
-	{PTP_OC_GetStream,N_("Get Stream")},
+	{PTP_OC_InitiateOpenCapture,N_("Initiate open capture")}
 };
 
-ptp_opcode_trans_t ptp_opcode_mtp_trans[] = {
+struct {
+	uint16_t opcode;
+	const char *name;
+} ptp_opcode_mtp_trans[] = {
 	{PTP_OC_MTP_GetObjectPropsSupported,N_("Get object properties supported")},
 	{PTP_OC_MTP_GetObjectPropDesc,N_("Get object property description")},
 	{PTP_OC_MTP_GetObjectPropValue,N_("Get object property value")},
@@ -5800,240 +5072,30 @@
 	{PTP_OC_MTP_WMDRMND_GetWMDRMNDLicenseResponse,N_("Get WMDRM-ND License Response")},
 
 	/* WiFi Provisioning MTP Extension Codes (microsoft.com/WPDWCN: 1.0) */
-	{PTP_OC_MTP_WPDWCN_ProcessWFCObject,N_("Process WFC Object")},
-
-	/* Android Direct I/O Extensions */
-	{PTP_OC_ANDROID_GetPartialObject64,N_("Get Partial Object (64bit Offset)")},
-	{PTP_OC_ANDROID_SendPartialObject,N_("Send Partial Object")},
-	{PTP_OC_ANDROID_TruncateObject,N_("Truncate Object")},
-	{PTP_OC_ANDROID_BeginEditObject,N_("Begin Edit Object")},
-	{PTP_OC_ANDROID_EndEditObject,N_("End Edit Object")},
+	{PTP_OC_MTP_WPDWCN_ProcessWFCObject,N_("Process WFC Object")}
 };
 
-ptp_opcode_trans_t ptp_opcode_nikon_trans[] = {
-	{PTP_OC_NIKON_GetProfileAllData,"PTP_OC_NIKON_GetProfileAllData"},
-	{PTP_OC_NIKON_SendProfileData,"PTP_OC_NIKON_SendProfileData"},
-	{PTP_OC_NIKON_DeleteProfile,"PTP_OC_NIKON_DeleteProfile"},
-	{PTP_OC_NIKON_SetProfileData,"PTP_OC_NIKON_SetProfileData"},
-	{PTP_OC_NIKON_AdvancedTransfer,"PTP_OC_NIKON_AdvancedTransfer"},
-	{PTP_OC_NIKON_GetFileInfoInBlock,"PTP_OC_NIKON_GetFileInfoInBlock"},
-	{PTP_OC_NIKON_Capture,"PTP_OC_NIKON_Capture"},
-	{PTP_OC_NIKON_AfDrive,"PTP_OC_NIKON_AfDrive"},
-	{PTP_OC_NIKON_SetControlMode,"PTP_OC_NIKON_SetControlMode"},
-	{PTP_OC_NIKON_DelImageSDRAM,"PTP_OC_NIKON_DelImageSDRAM"},
-	{PTP_OC_NIKON_GetLargeThumb,"PTP_OC_NIKON_GetLargeThumb"},
-	{PTP_OC_NIKON_CurveDownload,"PTP_OC_NIKON_CurveDownload"},
-	{PTP_OC_NIKON_CurveUpload,"PTP_OC_NIKON_CurveUpload"},
-	{PTP_OC_NIKON_CheckEvent,"PTP_OC_NIKON_CheckEvent"},
-	{PTP_OC_NIKON_DeviceReady,"PTP_OC_NIKON_DeviceReady"},
-	{PTP_OC_NIKON_SetPreWBData,"PTP_OC_NIKON_SetPreWBData"},
-	{PTP_OC_NIKON_GetVendorPropCodes,"PTP_OC_NIKON_GetVendorPropCodes"},
-	{PTP_OC_NIKON_AfCaptureSDRAM,"PTP_OC_NIKON_AfCaptureSDRAM"},
-	{PTP_OC_NIKON_GetPictCtrlData,"PTP_OC_NIKON_GetPictCtrlData"},
-	{PTP_OC_NIKON_SetPictCtrlData,"PTP_OC_NIKON_SetPictCtrlData"},
-	{PTP_OC_NIKON_DelCstPicCtrl,"PTP_OC_NIKON_DelCstPicCtrl"},
-	{PTP_OC_NIKON_GetPicCtrlCapability,"PTP_OC_NIKON_GetPicCtrlCapability"},
-	{PTP_OC_NIKON_GetPreviewImg,"PTP_OC_NIKON_GetPreviewImg"},
-	{PTP_OC_NIKON_StartLiveView,"PTP_OC_NIKON_StartLiveView"},
-	{PTP_OC_NIKON_EndLiveView,"PTP_OC_NIKON_EndLiveView"},
-	{PTP_OC_NIKON_GetLiveViewImg,"PTP_OC_NIKON_GetLiveViewImg"},
-	{PTP_OC_NIKON_MfDrive,"PTP_OC_NIKON_MfDrive"},
-	{PTP_OC_NIKON_ChangeAfArea,"PTP_OC_NIKON_ChangeAfArea"},
-	{PTP_OC_NIKON_AfDriveCancel,"PTP_OC_NIKON_AfDriveCancel"},
-	{PTP_OC_NIKON_InitiateCaptureRecInMedia,"PTP_OC_NIKON_InitiateCaptureRecInMedia"},
-	{PTP_OC_NIKON_GetVendorStorageIDs,"PTP_OC_NIKON_GetVendorStorageIDs"},
-	{PTP_OC_NIKON_StartMovieRecInCard,"PTP_OC_NIKON_StartMovieRecInCard"},
-	{PTP_OC_NIKON_EndMovieRec,"PTP_OC_NIKON_EndMovieRec"},
-	{PTP_OC_NIKON_TerminateCapture,"PTP_OC_NIKON_TerminateCapture"},
-	{PTP_OC_NIKON_GetDevicePTPIPInfo,"PTP_OC_NIKON_GetDevicePTPIPInfo"},
-	{PTP_OC_NIKON_GetPartialObjectHiSpeed,"PTP_OC_NIKON_GetPartialObjectHiSpeed"},
-	{PTP_OC_NIKON_GetDevicePropEx,"PTP_OC_NIKON_GetDevicePropEx"},
-};
-
-ptp_opcode_trans_t ptp_opcode_canon_trans[] = {
-	{PTP_OC_CANON_GetPartialObjectInfo,"PTP_OC_CANON_GetPartialObjectInfo"},
-	{PTP_OC_CANON_SetObjectArchive,"PTP_OC_CANON_SetObjectArchive"},
-	{PTP_OC_CANON_KeepDeviceOn,"PTP_OC_CANON_KeepDeviceOn"},
-	{PTP_OC_CANON_LockDeviceUI,"PTP_OC_CANON_LockDeviceUI"},
-	{PTP_OC_CANON_UnlockDeviceUI,"PTP_OC_CANON_UnlockDeviceUI"},
-	{PTP_OC_CANON_GetObjectHandleByName,"PTP_OC_CANON_GetObjectHandleByName"},
-	{PTP_OC_CANON_InitiateReleaseControl,"PTP_OC_CANON_InitiateReleaseControl"},
-	{PTP_OC_CANON_TerminateReleaseControl,"PTP_OC_CANON_TerminateReleaseControl"},
-	{PTP_OC_CANON_TerminatePlaybackMode,"PTP_OC_CANON_TerminatePlaybackMode"},
-	{PTP_OC_CANON_ViewfinderOn,"PTP_OC_CANON_ViewfinderOn"},
-	{PTP_OC_CANON_ViewfinderOff,"PTP_OC_CANON_ViewfinderOff"},
-	{PTP_OC_CANON_DoAeAfAwb,"PTP_OC_CANON_DoAeAfAwb"},
-	{PTP_OC_CANON_GetCustomizeSpec,"PTP_OC_CANON_GetCustomizeSpec"},
-	{PTP_OC_CANON_GetCustomizeItemInfo,"PTP_OC_CANON_GetCustomizeItemInfo"},
-	{PTP_OC_CANON_GetCustomizeData,"PTP_OC_CANON_GetCustomizeData"},
-	{PTP_OC_CANON_SetCustomizeData,"PTP_OC_CANON_SetCustomizeData"},
-	{PTP_OC_CANON_GetCaptureStatus,"PTP_OC_CANON_GetCaptureStatus"},
-	{PTP_OC_CANON_CheckEvent,"PTP_OC_CANON_CheckEvent"},
-	{PTP_OC_CANON_FocusLock,"PTP_OC_CANON_FocusLock"},
-	{PTP_OC_CANON_FocusUnlock,"PTP_OC_CANON_FocusUnlock"},
-	{PTP_OC_CANON_GetLocalReleaseParam,"PTP_OC_CANON_GetLocalReleaseParam"},
-	{PTP_OC_CANON_SetLocalReleaseParam,"PTP_OC_CANON_SetLocalReleaseParam"},
-	{PTP_OC_CANON_AskAboutPcEvf,"PTP_OC_CANON_AskAboutPcEvf"},
-	{PTP_OC_CANON_SendPartialObject,"PTP_OC_CANON_SendPartialObject"},
-	{PTP_OC_CANON_InitiateCaptureInMemory,"PTP_OC_CANON_InitiateCaptureInMemory"},
-	{PTP_OC_CANON_GetPartialObjectEx,"PTP_OC_CANON_GetPartialObjectEx"},
-	{PTP_OC_CANON_SetObjectTime,"PTP_OC_CANON_SetObjectTime"},
-	{PTP_OC_CANON_GetViewfinderImage,"PTP_OC_CANON_GetViewfinderImage"},
-	{PTP_OC_CANON_GetObjectAttributes,"PTP_OC_CANON_GetObjectAttributes"},
-	{PTP_OC_CANON_ChangeUSBProtocol,"PTP_OC_CANON_ChangeUSBProtocol"},
-	{PTP_OC_CANON_GetChanges,"PTP_OC_CANON_GetChanges"},
-	{PTP_OC_CANON_GetObjectInfoEx,"PTP_OC_CANON_GetObjectInfoEx"},
-	{PTP_OC_CANON_InitiateDirectTransfer,"PTP_OC_CANON_InitiateDirectTransfer"},
-	{PTP_OC_CANON_TerminateDirectTransfer ,"PTP_OC_CANON_TerminateDirectTransfer "},
-	{PTP_OC_CANON_SendObjectInfoByPath ,"PTP_OC_CANON_SendObjectInfoByPath "},
-	{PTP_OC_CANON_SendObjectByPath ,"PTP_OC_CANON_SendObjectByPath "},
-	{PTP_OC_CANON_InitiateDirectTansferEx,"PTP_OC_CANON_InitiateDirectTansferEx"},
-	{PTP_OC_CANON_GetAncillaryObjectHandles,"PTP_OC_CANON_GetAncillaryObjectHandles"},
-	{PTP_OC_CANON_GetTreeInfo ,"PTP_OC_CANON_GetTreeInfo "},
-	{PTP_OC_CANON_GetTreeSize ,"PTP_OC_CANON_GetTreeSize "},
-	{PTP_OC_CANON_NotifyProgress ,"PTP_OC_CANON_NotifyProgress "},
-	{PTP_OC_CANON_NotifyCancelAccepted,"PTP_OC_CANON_NotifyCancelAccepted"},
-	{PTP_OC_CANON_902C,"PTP_OC_CANON_902C"},
-	{PTP_OC_CANON_GetDirectory,"PTP_OC_CANON_GetDirectory"},
-	{PTP_OC_CANON_SetPairingInfo,"PTP_OC_CANON_SetPairingInfo"},
-	{PTP_OC_CANON_GetPairingInfo,"PTP_OC_CANON_GetPairingInfo"},
-	{PTP_OC_CANON_DeletePairingInfo,"PTP_OC_CANON_DeletePairingInfo"},
-	{PTP_OC_CANON_GetMACAddress,"PTP_OC_CANON_GetMACAddress"},
-	{PTP_OC_CANON_SetDisplayMonitor,"PTP_OC_CANON_SetDisplayMonitor"},
-	{PTP_OC_CANON_PairingComplete,"PTP_OC_CANON_PairingComplete"},
-	{PTP_OC_CANON_GetWirelessMAXChannel,"PTP_OC_CANON_GetWirelessMAXChannel"},
-	{PTP_OC_CANON_GetWebServiceSpec,"PTP_OC_CANON_GetWebServiceSpec"},
-	{PTP_OC_CANON_GetWebServiceData,"PTP_OC_CANON_GetWebServiceData"},
-	{PTP_OC_CANON_SetWebServiceData,"PTP_OC_CANON_SetWebServiceData"},
-	{PTP_OC_CANON_GetRootCertificateSpec,"PTP_OC_CANON_GetRootCertificateSpec"},
-	{PTP_OC_CANON_GetRootCertificateData,"PTP_OC_CANON_GetRootCertificateData"},
-	{PTP_OC_CANON_SetRootCertificateData,"PTP_OC_CANON_SetRootCertificateData"},
-	{PTP_OC_CANON_EOS_GetStorageIDs,"PTP_OC_CANON_EOS_GetStorageIDs"},
-	{PTP_OC_CANON_EOS_GetStorageInfo,"PTP_OC_CANON_EOS_GetStorageInfo"},
-	{PTP_OC_CANON_EOS_GetObjectInfo,"PTP_OC_CANON_EOS_GetObjectInfo"},
-	{PTP_OC_CANON_EOS_GetObject,"PTP_OC_CANON_EOS_GetObject"},
-	{PTP_OC_CANON_EOS_DeleteObject,"PTP_OC_CANON_EOS_DeleteObject"},
-	{PTP_OC_CANON_EOS_FormatStore,"PTP_OC_CANON_EOS_FormatStore"},
-	{PTP_OC_CANON_EOS_GetPartialObject,"PTP_OC_CANON_EOS_GetPartialObject"},
-	{PTP_OC_CANON_EOS_GetDeviceInfoEx,"PTP_OC_CANON_EOS_GetDeviceInfoEx"},
-	{PTP_OC_CANON_EOS_GetObjectInfoEx,"PTP_OC_CANON_EOS_GetObjectInfoEx"},
-	{PTP_OC_CANON_EOS_GetThumbEx,"PTP_OC_CANON_EOS_GetThumbEx"},
-	{PTP_OC_CANON_EOS_SendPartialObject,"PTP_OC_CANON_EOS_SendPartialObject"},
-	{PTP_OC_CANON_EOS_SetObjectAttributes,"PTP_OC_CANON_EOS_SetObjectAttributes"},
-	{PTP_OC_CANON_EOS_GetObjectTime,"PTP_OC_CANON_EOS_GetObjectTime"},
-	{PTP_OC_CANON_EOS_SetObjectTime,"PTP_OC_CANON_EOS_SetObjectTime"},
-	{PTP_OC_CANON_EOS_RemoteRelease,"PTP_OC_CANON_EOS_RemoteRelease"},
-	{PTP_OC_CANON_EOS_SetDevicePropValueEx,"PTP_OC_CANON_EOS_SetDevicePropValueEx"},
-	{PTP_OC_CANON_EOS_GetRemoteMode,"PTP_OC_CANON_EOS_GetRemoteMode"},
-	{PTP_OC_CANON_EOS_SetRemoteMode,"PTP_OC_CANON_EOS_SetRemoteMode"},
-	{PTP_OC_CANON_EOS_SetEventMode,"PTP_OC_CANON_EOS_SetEventMode"},
-	{PTP_OC_CANON_EOS_GetEvent,"PTP_OC_CANON_EOS_GetEvent"},
-	{PTP_OC_CANON_EOS_TransferComplete,"PTP_OC_CANON_EOS_TransferComplete"},
-	{PTP_OC_CANON_EOS_CancelTransfer,"PTP_OC_CANON_EOS_CancelTransfer"},
-	{PTP_OC_CANON_EOS_ResetTransfer,"PTP_OC_CANON_EOS_ResetTransfer"},
-	{PTP_OC_CANON_EOS_PCHDDCapacity,"PTP_OC_CANON_EOS_PCHDDCapacity"},
-	{PTP_OC_CANON_EOS_SetUILock,"PTP_OC_CANON_EOS_SetUILock"},
-	{PTP_OC_CANON_EOS_ResetUILock,"PTP_OC_CANON_EOS_ResetUILock"},
-	{PTP_OC_CANON_EOS_KeepDeviceOn,"PTP_OC_CANON_EOS_KeepDeviceOn"},
-	{PTP_OC_CANON_EOS_SetNullPacketMode,"PTP_OC_CANON_EOS_SetNullPacketMode"},
-	{PTP_OC_CANON_EOS_UpdateFirmware,"PTP_OC_CANON_EOS_UpdateFirmware"},
-	{PTP_OC_CANON_EOS_TransferCompleteDT,"PTP_OC_CANON_EOS_TransferCompleteDT"},
-	{PTP_OC_CANON_EOS_CancelTransferDT,"PTP_OC_CANON_EOS_CancelTransferDT"},
-	{PTP_OC_CANON_EOS_SetWftProfile,"PTP_OC_CANON_EOS_SetWftProfile"},
-	{PTP_OC_CANON_EOS_GetWftProfile,"PTP_OC_CANON_EOS_GetWftProfile"},
-	{PTP_OC_CANON_EOS_SetProfileToWft,"PTP_OC_CANON_EOS_SetProfileToWft"},
-	{PTP_OC_CANON_EOS_BulbStart,"PTP_OC_CANON_EOS_BulbStart"},
-	{PTP_OC_CANON_EOS_BulbEnd,"PTP_OC_CANON_EOS_BulbEnd"},
-	{PTP_OC_CANON_EOS_RequestDevicePropValue,"PTP_OC_CANON_EOS_RequestDevicePropValue"},
-	{PTP_OC_CANON_EOS_RemoteReleaseOn,"PTP_OC_CANON_EOS_RemoteReleaseOn"},
-	{PTP_OC_CANON_EOS_RemoteReleaseOff,"PTP_OC_CANON_EOS_RemoteReleaseOff"},
-	{PTP_OC_CANON_EOS_RegistBackgroundImage,"PTP_OC_CANON_EOS_RegistBackgroundImage"},
-	{PTP_OC_CANON_EOS_ChangePhotoStudioMode,"PTP_OC_CANON_EOS_ChangePhotoStudioMode"},
-	{PTP_OC_CANON_EOS_GetPartialObjectEx,"PTP_OC_CANON_EOS_GetPartialObjectEx"},
-	{PTP_OC_CANON_EOS_ResetMirrorLockupState,"PTP_OC_CANON_EOS_ResetMirrorLockupState"},
-	{PTP_OC_CANON_EOS_PopupBuiltinFlash,"PTP_OC_CANON_EOS_PopupBuiltinFlash"},
-	{PTP_OC_CANON_EOS_EndGetPartialObjectEx,"PTP_OC_CANON_EOS_EndGetPartialObjectEx"},
-	{PTP_OC_CANON_EOS_MovieSelectSWOn,"PTP_OC_CANON_EOS_MovieSelectSWOn"},
-	{PTP_OC_CANON_EOS_MovieSelectSWOff,"PTP_OC_CANON_EOS_MovieSelectSWOff"},
-	{PTP_OC_CANON_EOS_GetCTGInfo,"PTP_OC_CANON_EOS_GetCTGInfo"},
-	{PTP_OC_CANON_EOS_GetLensAdjust,"PTP_OC_CANON_EOS_GetLensAdjust"},
-	{PTP_OC_CANON_EOS_SetLensAdjust,"PTP_OC_CANON_EOS_SetLensAdjust"},
-	{PTP_OC_CANON_EOS_GetMusicInfo,"PTP_OC_CANON_EOS_GetMusicInfo"},
-	{PTP_OC_CANON_EOS_CreateHandle,"PTP_OC_CANON_EOS_CreateHandle"},
-	{PTP_OC_CANON_EOS_SendPartialObjectEx,"PTP_OC_CANON_EOS_SendPartialObjectEx"},
-	{PTP_OC_CANON_EOS_EndSendPartialObjectEx,"PTP_OC_CANON_EOS_EndSendPartialObjectEx"},
-	{PTP_OC_CANON_EOS_SetCTGInfo,"PTP_OC_CANON_EOS_SetCTGInfo"},
-	{PTP_OC_CANON_EOS_SetRequestOLCInfoGroup,"PTP_OC_CANON_EOS_SetRequestOLCInfoGroup"},
-	{PTP_OC_CANON_EOS_SetRequestRollingPitchingLevel,"PTP_OC_CANON_EOS_SetRequestRollingPitchingLevel"},
-	{PTP_OC_CANON_EOS_GetCameraSupport,"PTP_OC_CANON_EOS_GetCameraSupport"},
-	{PTP_OC_CANON_EOS_SetRating,"PTP_OC_CANON_EOS_SetRating"},
-	{PTP_OC_CANON_EOS_RequestInnerDevelopStart,"PTP_OC_CANON_EOS_RequestInnerDevelopStart"},
-	{PTP_OC_CANON_EOS_RequestInnerDevelopParamChange,"PTP_OC_CANON_EOS_RequestInnerDevelopParamChange"},
-	{PTP_OC_CANON_EOS_RequestInnerDevelopEnd,"PTP_OC_CANON_EOS_RequestInnerDevelopEnd"},
-	{PTP_OC_CANON_EOS_GpsLoggingDataMode,"PTP_OC_CANON_EOS_GpsLoggingDataMode"},
-	{PTP_OC_CANON_EOS_GetGpsLogCurrentHandle,"PTP_OC_CANON_EOS_GetGpsLogCurrentHandle"},
-	{PTP_OC_CANON_EOS_InitiateViewfinder,"PTP_OC_CANON_EOS_InitiateViewfinder"},
-	{PTP_OC_CANON_EOS_TerminateViewfinder,"PTP_OC_CANON_EOS_TerminateViewfinder"},
-	{PTP_OC_CANON_EOS_GetViewFinderData,"PTP_OC_CANON_EOS_GetViewFinderData"},
-	{PTP_OC_CANON_EOS_DoAf,"PTP_OC_CANON_EOS_DoAf"},
-	{PTP_OC_CANON_EOS_DriveLens,"PTP_OC_CANON_EOS_DriveLens"},
-	{PTP_OC_CANON_EOS_DepthOfFieldPreview,"PTP_OC_CANON_EOS_DepthOfFieldPreview"},
-	{PTP_OC_CANON_EOS_ClickWB,"PTP_OC_CANON_EOS_ClickWB"},
-	{PTP_OC_CANON_EOS_Zoom,"PTP_OC_CANON_EOS_Zoom"},
-	{PTP_OC_CANON_EOS_ZoomPosition,"PTP_OC_CANON_EOS_ZoomPosition"},
-	{PTP_OC_CANON_EOS_SetLiveAfFrame,"PTP_OC_CANON_EOS_SetLiveAfFrame"},
-	{PTP_OC_CANON_EOS_TouchAfPosition,"PTP_OC_CANON_EOS_TouchAfPosition"},
-	{PTP_OC_CANON_EOS_SetLvPcFlavoreditMode,"PTP_OC_CANON_EOS_SetLvPcFlavoreditMode"},
-	{PTP_OC_CANON_EOS_SetLvPcFlavoreditParam,"PTP_OC_CANON_EOS_SetLvPcFlavoreditParam"},
-	{PTP_OC_CANON_EOS_AfCancel,"PTP_OC_CANON_EOS_AfCancel"},
-	{PTP_OC_CANON_EOS_SetDefaultCameraSetting,"PTP_OC_CANON_EOS_SetDefaultCameraSetting"},
-	{PTP_OC_CANON_EOS_GetAEData,"PTP_OC_CANON_EOS_GetAEData"},
-	{PTP_OC_CANON_EOS_NotifyNetworkError,"PTP_OC_CANON_EOS_NotifyNetworkError"},
-	{PTP_OC_CANON_EOS_AdapterTransferProgress,"PTP_OC_CANON_EOS_AdapterTransferProgress"},
-	{PTP_OC_CANON_EOS_TransferComplete2,"PTP_OC_CANON_EOS_TransferComplete2"},
-	{PTP_OC_CANON_EOS_CancelTransfer2,"PTP_OC_CANON_EOS_CancelTransfer2"},
-	{PTP_OC_CANON_EOS_FAPIMessageTX,"PTP_OC_CANON_EOS_FAPIMessageTX"},
-	{PTP_OC_CANON_EOS_FAPIMessageRX,"PTP_OC_CANON_EOS_FAPIMessageRX"},
-};
-
-ptp_opcode_trans_t ptp_opcode_sony_trans[] = {
-	{PTP_OC_SONY_SDIOConnect,"PTP_OC_SONY_SDIOConnect"},
-	{PTP_OC_SONY_GetSDIOGetExtDeviceInfo,"PTP_OC_SONY_GetSDIOGetExtDeviceInfo"},
-	{PTP_OC_SONY_GetDevicePropdesc,"PTP_OC_SONY_GetDevicePropdesc"},
-	{PTP_OC_SONY_GetDevicePropertyValue,"PTP_OC_SONY_GetDevicePropertyValue"},
-	{PTP_OC_SONY_SetControlDeviceA,"PTP_OC_SONY_SetControlDeviceA"},
-	{PTP_OC_SONY_GetControlDeviceDesc,"PTP_OC_SONY_GetControlDeviceDesc"},
-	{PTP_OC_SONY_SetControlDeviceB,"PTP_OC_SONY_SetControlDeviceB"},
-	{PTP_OC_SONY_GetAllDevicePropData,"PTP_OC_SONY_GetAllDevicePropData"},
-};
-
-const char*
-ptp_get_opcode_name(PTPParams* params, uint16_t opcode)
+int
+ptp_render_opcode(PTPParams* params, uint16_t opcode, int spaceleft, char *txt)
 {
-#define RETURN_NAME_FROM_TABLE(TABLE, OPCODE) \
-{ \
-	unsigned int i; \
-	for (i=0; i<sizeof(TABLE)/sizeof(TABLE[0]); i++) \
-		if (OPCODE == TABLE[i].opcode) \
-			return _(TABLE[i].name); \
-	return _("Unknown PTP_OC"); \
-}
+	int i;
 
-	if (!(opcode & 0x8000))
-		RETURN_NAME_FROM_TABLE(ptp_opcode_trans, opcode);
-
-	switch (params->deviceinfo.VendorExtensionID) {
-	case PTP_VENDOR_MICROSOFT:
-	case PTP_VENDOR_MTP:	RETURN_NAME_FROM_TABLE(ptp_opcode_mtp_trans, opcode);
-	case PTP_VENDOR_NIKON:	RETURN_NAME_FROM_TABLE(ptp_opcode_nikon_trans, opcode);
-	case PTP_VENDOR_CANON:	RETURN_NAME_FROM_TABLE(ptp_opcode_canon_trans, opcode);
-	case PTP_VENDOR_SONY:	RETURN_NAME_FROM_TABLE(ptp_opcode_sony_trans, opcode);
-	default:
-		break;
+	if (!(opcode & 0x8000)) {
+		for (i=0;i<sizeof(ptp_opcode_trans)/sizeof(ptp_opcode_trans[0]);i++)
+			if (opcode == ptp_opcode_trans[i].opcode)
+				return snprintf(txt, spaceleft, "%s", _(ptp_opcode_trans[i].name));
+	} else {
+		switch (params->deviceinfo.VendorExtensionID) {
+		case PTP_VENDOR_MICROSOFT:
+		case PTP_VENDOR_MTP:
+			for (i=0;i<sizeof(ptp_opcode_mtp_trans)/sizeof(ptp_opcode_mtp_trans[0]);i++)
+				if (opcode == ptp_opcode_mtp_trans[i].opcode)
+					return snprintf(txt, spaceleft, "%s", _(ptp_opcode_mtp_trans[i].name));
+			break;
+		default:break;
+		}
 	}
-#undef RETURN_NAME_FROM_TABLE
-
-	return _("Unknown VendorExtensionID");
+	return snprintf (txt, spaceleft,_("Unknown (%04x)"), opcode);
 }
 
 
@@ -6212,9 +5274,8 @@
 };
 
 int
-ptp_render_mtp_propname(uint16_t propid, int spaceleft, char *txt)
-{
-	unsigned int i;
+ptp_render_mtp_propname(uint16_t propid, int spaceleft, char *txt) {
+	int i;
 	for (i=0;i<sizeof(ptp_opc_trans)/sizeof(ptp_opc_trans[0]);i++)
 		if (propid == ptp_opc_trans[i].id)
 			return snprintf(txt, spaceleft, "%s", ptp_opc_trans[i].name);
@@ -6225,12 +5286,15 @@
  * Allocate and default-initialize a few object properties.
  */
 MTPProperties *
-ptp_get_new_object_prop_entry(MTPProperties **props, int *nrofprops)
-{
+ptp_get_new_object_prop_entry(MTPProperties **props, int *nrofprops) {
 	MTPProperties *newprops;
 	MTPProperties *prop;
 
-	newprops = realloc(*props,sizeof(MTPProperties)*(*nrofprops+1));
+	if (*props == NULL) {
+		newprops = malloc(sizeof(MTPProperties)*(*nrofprops+1));
+	} else {
+		newprops = realloc(*props,sizeof(MTPProperties)*(*nrofprops+1));
+	}
 	if (newprops == NULL)
 		return NULL;
 	prop = &newprops[*nrofprops];
@@ -6278,7 +5342,7 @@
 MTPProperties *
 ptp_find_object_prop_in_cache(PTPParams *params, uint32_t const handle, uint32_t const attribute_id)
 {
-	unsigned int	i;
+	int	i;
 	MTPProperties	*prop;
 	PTPObject	*ob;
 	uint16_t	ret;
@@ -6295,13 +5359,16 @@
 	return NULL;
 }
 
-uint16_t
+void
 ptp_remove_object_from_cache(PTPParams *params, uint32_t handle)
 {
-	unsigned int i;
+	int i;
 	PTPObject	*ob;
+	uint16_t	ret;
 
-	CHECK_PTP_RC(ptp_object_find (params, handle, &ob));
+	ret = ptp_object_find (params, handle, &ob);
+	if (ret != PTP_RC_OK)
+		return;
 	i = ob-params->objects;
 	/* remove object from object info cache */
 	ptp_free_object (ob);
@@ -6311,11 +5378,9 @@
 	params->nrofobjects--;
 	/* We use less memory than before so this shouldn't fail */
 	params->objects = realloc(params->objects, sizeof(PTPObject)*params->nrofobjects);
-	return PTP_RC_OK;
 }
 
-static int _cmp_ob (const void *a, const void *b)
-{
+static int _cmp_ob (const void *a, const void *b) {
 	PTPObject *oa = (PTPObject*)a;
 	PTPObject *ob = (PTPObject*)b;
 
@@ -6323,15 +5388,13 @@
 }
 	
 void
-ptp_objects_sort (PTPParams *params)
-{
+ptp_objects_sort (PTPParams *params) {
 	qsort (params->objects, params->nrofobjects, sizeof(PTPObject), _cmp_ob);
 }
 
 /* Binary search in objects. Needs "objects" to be a sorted by objectid list!  */
 uint16_t
-ptp_object_find (PTPParams *params, uint32_t handle, PTPObject **retob)
-{
+ptp_object_find (PTPParams *params, uint32_t handle, PTPObject **retob) {
 	PTPObject	tmpob;
 
 	tmpob.oid = handle;
@@ -6343,10 +5406,9 @@
 
 /* Binary search in objects + insert of not found. Needs "objects" to be a sorted by objectid list!  */
 uint16_t
-ptp_object_find_or_insert (PTPParams *params, uint32_t handle, PTPObject **retob)
-{
-	unsigned int 	begin, end, cursor;
-	unsigned int	insertat;
+ptp_object_find_or_insert (PTPParams *params, uint32_t handle, PTPObject **retob) {
+	int 		begin, end, cursor;
+	int		insertat;
 	PTPObject	*newobs;
 
 	if (!handle) return PTP_RC_GeneralError;
@@ -6395,7 +5457,7 @@
 	newobs = realloc (params->objects, sizeof(PTPObject)*(params->nrofobjects+1));
 	if (!newobs) return PTP_RC_GeneralError;
 	params->objects = newobs;
-	if (insertat<params->nrofobjects)
+	if (insertat<=params->nrofobjects)
 		memmove (&params->objects[insertat+1],&params->objects[insertat],(params->nrofobjects-insertat)*sizeof(PTPObject));
 	memset(&params->objects[insertat],0,sizeof(PTPObject));
 	params->objects[insertat].oid = handle;
@@ -6405,8 +5467,7 @@
 }
 
 uint16_t
-ptp_object_want (PTPParams *params, uint32_t handle, unsigned int want, PTPObject **retob)
-{
+ptp_object_want (PTPParams *params, uint32_t handle, int want, PTPObject **retob) {
 	uint16_t	ret;
 	PTPObject	*ob;
 	/*Camera 		*camera = ((PTPData *)params->data)->camera;*/
@@ -6420,7 +5481,9 @@
 		ptp_debug (params, "ptp_object_want: querying handle 0?\n");
 		return PTP_RC_GeneralError;
 	}
-	CHECK_PTP_RC(ptp_object_find_or_insert (params, handle, &ob));
+	ret = ptp_object_find_or_insert (params, handle, &ob);
+	if (ret != PTP_RC_OK)
+		return PTP_RC_GeneralError;
 	*retob = ob;
 	/* Do we have all of it already? */
 	if ((ob->flags & want) == want)
@@ -6447,24 +5510,9 @@
 		/* Second EOS issue, 0x20000000 has 0x20000000 as parent */
 		if (ob->oi.ParentObject == handle)
 			ob->oi.ParentObject = 0;
-
-		/* Read out the canon special flags */
-		if ((params->deviceinfo.VendorExtensionID == PTP_VENDOR_CANON) &&
-		    ptp_operation_issupported(params,PTP_OC_CANON_GetObjectInfoEx)) {
-			PTPCANONFolderEntry *ents = NULL;
-			uint32_t            numents = 0;
-
-			ret = ptp_canon_getobjectinfo(params,
-				ob->oi.StorageID,0,
-				ob->oi.ParentObject,handle,
-				&ents,&numents
-			);
-			if ((ret == PTP_RC_OK) && (numents >= 1))
-				ob->canon_flags = ents[0].Flags;
-			free (ents);
-		}
-
 		ob->flags |= X;
+
+		/* EOS bug, DCIM links back to itself. */
 	}
 #undef X
 	if (	(want & PTPOBJECT_MTPPROPLIST_LOADED) &&
@@ -6493,7 +5541,7 @@
 
 		/* Override the ObjectInfo data with data from properties */
 		if (params->device_flags & DEVICE_FLAG_PROPLIST_OVERRIDES_OI) {
-			unsigned int i;
+			int i;
 			MTPProperties *prop = ob->mtpprops;
 
 			for (i=0;i<ob->nrofmtpprops;i++,prop++) {
diff --git a/src/ptp.h b/src/ptp.h
index 6ba3884..c1733dd 100644
--- a/src/ptp.h
+++ b/src/ptp.h
@@ -1,7 +1,7 @@
 /* ptp.h
  *
  * Copyright (C) 2001 Mariusz Woloszyn <emsi@ipartners.pl>
- * Copyright (C) 2003-2014 Marcus Meissner <marcus@jet.franken.de>
+ * Copyright (C) 2003-2012 Marcus Meissner <marcus@jet.franken.de>
  * Copyright (C) 2006-2008 Linus Walleij <triad@df.lth.se>
  *
  * This library is free software; you can redistribute it and/or
@@ -16,8 +16,8 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA  02110-1301  USA
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
  */
 
 #ifndef __PTP_H__
@@ -25,7 +25,7 @@
 
 #include <stdarg.h>
 #include <time.h>
-#if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
+#ifdef HAVE_ICONV
 #include <iconv.h>
 #endif
 #include "gphoto2-endian.h"
@@ -74,16 +74,12 @@
  *
  * Previously we had this as 4096 for MTP devices. We have found
  * and fixed the bugs that made this necessary and it can be 512 again.
- *
- * USB 3.0 has now 1024 byte EPs.
  */
 #define PTP_USB_BULK_HS_MAX_PACKET_LEN_WRITE	512
 #define PTP_USB_BULK_HS_MAX_PACKET_LEN_READ   512
-#define PTP_USB_BULK_SS_MAX_PACKET_LEN_WRITE	1024
-#define PTP_USB_BULK_SS_MAX_PACKET_LEN_READ   1024
 #define PTP_USB_BULK_HDR_LEN		(2*sizeof(uint32_t)+2*sizeof(uint16_t))
-#define PTP_USB_BULK_PAYLOAD_LEN_WRITE	(PTP_USB_BULK_SS_MAX_PACKET_LEN_WRITE-PTP_USB_BULK_HDR_LEN)
-#define PTP_USB_BULK_PAYLOAD_LEN_READ	(PTP_USB_BULK_SS_MAX_PACKET_LEN_READ-PTP_USB_BULK_HDR_LEN)
+#define PTP_USB_BULK_PAYLOAD_LEN_WRITE	(PTP_USB_BULK_HS_MAX_PACKET_LEN_WRITE-PTP_USB_BULK_HDR_LEN)
+#define PTP_USB_BULK_PAYLOAD_LEN_READ	(PTP_USB_BULK_HS_MAX_PACKET_LEN_READ-PTP_USB_BULK_HDR_LEN)
 #define PTP_USB_BULK_REQ_LEN	(PTP_USB_BULK_HDR_LEN+5*sizeof(uint32_t))
 
 struct _PTPUSBBulkContainer {
@@ -169,15 +165,9 @@
 #define PTP_VENDOR_FOTONATION		0x0000000C
 #define PTP_VENDOR_PENTAX		0x0000000D
 #define PTP_VENDOR_FUJI			0x0000000E
-/* not from standards papers, but from traces: */
-#define PTP_VENDOR_SONY			0x00000011 /* observed in the A900 */
-#define PTP_VENDOR_SAMSUNG		0x0000001a /* observed in the Samsung NX1000 */
 /* Vendor extension ID used for MTP (occasionaly, usualy 6 is used) */
 #define PTP_VENDOR_MTP			0xffffffff  
 
-/* gphoto overrides */
-#define PTP_VENDOR_GP_OLYMPUS		0xfffffffe
-
 /* Operation Codes */
 
 /* PTP v1.0 operation codes */
@@ -278,7 +268,6 @@
 /* 902c: no parms, read 3 uint32 in data, no response parms */
 #define PTP_OC_CANON_902C			0x902C
 #define PTP_OC_CANON_GetDirectory		0x902D
-#define PTP_OC_CANON_902E			0x902E
 
 #define PTP_OC_CANON_SetPairingInfo		0x9030
 #define PTP_OC_CANON_GetPairingInfo		0x9031
@@ -289,13 +278,6 @@
 #define PTP_OC_CANON_PairingComplete		0x9035
 #define PTP_OC_CANON_GetWirelessMAXChannel	0x9036
 
-#define PTP_OC_CANON_GetWebServiceSpec		0x9068
-#define PTP_OC_CANON_GetWebServiceData		0x9069
-#define PTP_OC_CANON_SetWebServiceData		0x906B
-#define PTP_OC_CANON_GetRootCertificateSpec	0x906C
-#define PTP_OC_CANON_GetRootCertificateData	0x906D
-#define PTP_OC_CANON_SetRootCertificateData	0x906F
-
 /* 9101: no args, 8 byte data (01 00 00 00 00 00 00 00), no resp data. */
 #define PTP_OC_CANON_EOS_GetStorageIDs		0x9101
 /* 9102: 1 arg (0)
@@ -377,7 +359,7 @@
 #define PTP_OC_CANON_EOS_TransferCompleteDT	0x9120
 #define PTP_OC_CANON_EOS_CancelTransferDT	0x9121
 #define PTP_OC_CANON_EOS_SetWftProfile		0x9122
-#define PTP_OC_CANON_EOS_GetWftProfile		0x9123
+#define PTP_OC_CANON_EOS_GetWftProfile		0x9122
 #define PTP_OC_CANON_EOS_SetProfileToWft	0x9124
 #define PTP_OC_CANON_EOS_BulbStart		0x9125
 #define PTP_OC_CANON_EOS_BulbEnd		0x9126
@@ -388,54 +370,17 @@
 /* 0x9129 args (0x1/0x2), no data, no resp args */
 #define PTP_OC_CANON_EOS_RemoteReleaseOff	0x9129
 
-#define PTP_OC_CANON_EOS_RegistBackgroundImage	0x912A
-#define PTP_OC_CANON_EOS_ChangePhotoStudioMode	0x912B
-#define PTP_OC_CANON_EOS_GetPartialObjectEx	0x912C
-#define PTP_OC_CANON_EOS_ResetMirrorLockupState	0x9130
-#define PTP_OC_CANON_EOS_PopupBuiltinFlash	0x9131
-#define PTP_OC_CANON_EOS_EndGetPartialObjectEx	0x9132
-#define PTP_OC_CANON_EOS_MovieSelectSWOn	0x9133
-#define PTP_OC_CANON_EOS_MovieSelectSWOff	0x9134
-#define PTP_OC_CANON_EOS_GetCTGInfo		0x9135
-#define PTP_OC_CANON_EOS_GetLensAdjust		0x9136
-#define PTP_OC_CANON_EOS_SetLensAdjust		0x9137
-#define PTP_OC_CANON_EOS_GetMusicInfo		0x9138
-/* 3 paramaeters, no data, OFC, size, unknown */
-#define PTP_OC_CANON_EOS_CreateHandle		0x9139
-#define PTP_OC_CANON_EOS_SendPartialObjectEx	0x913A
-#define PTP_OC_CANON_EOS_EndSendPartialObjectEx	0x913B
-#define PTP_OC_CANON_EOS_SetCTGInfo		0x913C
-#define PTP_OC_CANON_EOS_SetRequestOLCInfoGroup	0x913D
-#define PTP_OC_CANON_EOS_SetRequestRollingPitchingLevel	0x913E
-#define PTP_OC_CANON_EOS_GetCameraSupport	0x913F
-#define PTP_OC_CANON_EOS_SetRating		0x9140 /* 2 args */
-#define PTP_OC_CANON_EOS_RequestInnerDevelopStart	0x9141 /* 2 args: 1 type, 1 object? */
-#define PTP_OC_CANON_EOS_RequestInnerDevelopParamChange	0x9142
-#define PTP_OC_CANON_EOS_RequestInnerDevelopEnd		0x9143
-#define PTP_OC_CANON_EOS_GpsLoggingDataMode		0x9144 /* 1 arg */
-#define PTP_OC_CANON_EOS_GetGpsLogCurrentHandle		0x9145
-
 #define PTP_OC_CANON_EOS_InitiateViewfinder	0x9151
 #define PTP_OC_CANON_EOS_TerminateViewfinder	0x9152
-/* EOS M2 wlan: 2 params, 0x00200000 0x01000000 */
 #define PTP_OC_CANON_EOS_GetViewFinderData	0x9153
 #define PTP_OC_CANON_EOS_DoAf			0x9154
 #define PTP_OC_CANON_EOS_DriveLens		0x9155
-#define PTP_OC_CANON_EOS_DepthOfFieldPreview	0x9156 /* 1 arg */
-#define PTP_OC_CANON_EOS_ClickWB		0x9157 /* 2 args: x,y */
-#define PTP_OC_CANON_EOS_Zoom			0x9158 /* 1 arg */
-#define PTP_OC_CANON_EOS_ZoomPosition		0x9159 /* 2 args: x,y */
-#define PTP_OC_CANON_EOS_SetLiveAfFrame		0x915A
-#define PTP_OC_CANON_EOS_TouchAfPosition	0x915B /* 3 args: type,x,y */
-#define PTP_OC_CANON_EOS_SetLvPcFlavoreditMode	0x915C /* 1 arg */
-#define PTP_OC_CANON_EOS_SetLvPcFlavoreditParam	0x915D /* 1 arg */
+#define PTP_OC_CANON_EOS_DepthOfFieldPreview	0x9156
+#define PTP_OC_CANON_EOS_ClickWB		0x9157
+#define PTP_OC_CANON_EOS_Zoom			0x9158
+#define PTP_OC_CANON_EOS_ZoomPosition		0x9159
+#define PTP_OC_CANON_EOS_SetLiveAfFrame		0x915a
 #define PTP_OC_CANON_EOS_AfCancel		0x9160
-#define PTP_OC_CANON_EOS_SetDefaultCameraSetting		0x91BE
-#define PTP_OC_CANON_EOS_GetAEData		0x91BF
-#define PTP_OC_CANON_EOS_NotifyNetworkError	0x91E8
-#define PTP_OC_CANON_EOS_AdapterTransferProgress	0x91E9
-#define PTP_OC_CANON_EOS_TransferComplete2	0x91F0
-#define PTP_OC_CANON_EOS_CancelTransfer2	0x91F1
 #define PTP_OC_CANON_EOS_FAPIMessageTX		0x91FE
 #define PTP_OC_CANON_EOS_FAPIMessageRX		0x91FF
 
@@ -448,8 +393,8 @@
 #define PTP_OC_NIKON_GetFileInfoInBlock	0x9011
 #define PTP_OC_NIKON_Capture		0x90C0	/* 1 param,   no data */
 #define PTP_OC_NIKON_AfDrive		0x90C1	/* no params, no data */
-#define PTP_OC_NIKON_SetControlMode	0x90C2	/* 1 param,  no data */
-#define PTP_OC_NIKON_DelImageSDRAM	0x90C3	/* 1 param,  no data */
+#define PTP_OC_NIKON_SetControlMode	0x90C2	/* 1 param,   no data */
+#define PTP_OC_NIKON_DelImageSDRAM	0x90C3	/* no params, no data */
 #define PTP_OC_NIKON_GetLargeThumb	0x90C4
 #define PTP_OC_NIKON_CurveDownload	0x90C5	/* 1 param,   data in */
 #define PTP_OC_NIKON_CurveUpload	0x90C6	/* 1 param,   data out */
@@ -458,39 +403,22 @@
 #define PTP_OC_NIKON_SetPreWBData	0x90C9	/* 3 params,  data out */
 #define PTP_OC_NIKON_GetVendorPropCodes	0x90CA	/* 0 params, data in */
 #define PTP_OC_NIKON_AfCaptureSDRAM	0x90CB	/* no params, no data */
-#define PTP_OC_NIKON_GetPictCtrlData	0x90CC	/* 2 params, data in */
-#define PTP_OC_NIKON_SetPictCtrlData	0x90CD	/* 2 params, data out */
-#define PTP_OC_NIKON_DelCstPicCtrl	0x90CE	/* 1 param, no data */
-#define PTP_OC_NIKON_GetPicCtrlCapability	0x90CF	/* 1 param, data in */
+#define PTP_OC_NIKON_GetPictCtrlData	0x90CC
+#define PTP_OC_NIKON_SetPictCtrlData	0x90CD
+#define PTP_OC_NIKON_DelCstPicCtrl	0x90CE
+#define PTP_OC_NIKON_GetPicCtrlCapability	0x90CF
 
 /* Nikon Liveview stuff */
 #define PTP_OC_NIKON_GetPreviewImg	0x9200
-#define PTP_OC_NIKON_StartLiveView	0x9201	/* no params */
-#define PTP_OC_NIKON_EndLiveView	0x9202	/* no params */
-#define PTP_OC_NIKON_GetLiveViewImg	0x9203	/* no params, data in */
-#define PTP_OC_NIKON_MfDrive		0x9204	/* 2 params */
-#define PTP_OC_NIKON_ChangeAfArea	0x9205	/* 2 params */
-#define PTP_OC_NIKON_AfDriveCancel	0x9206	/* no params */
-/* 2 params:
- * 0xffffffff == No AF before,  0xfffffffe == AF before capture
- * sdram=1, card=0
- */
-#define PTP_OC_NIKON_InitiateCaptureRecInMedia	0x9207	/* 1 params */
-
-#define PTP_OC_NIKON_GetVendorStorageIDs	0x9209	/* no params, data in */
-
-#define PTP_OC_NIKON_StartMovieRecInCard	0x920a	/* no params, no data */
-#define PTP_OC_NIKON_EndMovieRec		0x920b	/* no params, no data */
-
-#define PTP_OC_NIKON_TerminateCapture		0x920c	/* 2 params */
+#define PTP_OC_NIKON_StartLiveView	0x9201
+#define PTP_OC_NIKON_EndLiveView	0x9202
+#define PTP_OC_NIKON_GetLiveViewImg	0x9203
+#define PTP_OC_NIKON_MfDrive		0x9204
+#define PTP_OC_NIKON_ChangeAfArea	0x9205
+#define PTP_OC_NIKON_AfDriveCancel	0x9206
 
 #define PTP_OC_NIKON_GetDevicePTPIPInfo	0x90E0
 
-#define PTP_OC_NIKON_GetPartialObjectHiSpeed	0x9400	/* 3 params, data in */
-
-/* From Nikon V1 Trace */
-#define PTP_OC_NIKON_GetDevicePropEx		0x9504	/* gets device prop dataa */
-
 /* Casio EX-F1 (from http://code.google.com/p/exf1ctrl/ ) */
 #define PTP_OC_CASIO_STILL_START	0x9001
 #define PTP_OC_CASIO_STILL_STOP		0x9002
@@ -522,30 +450,6 @@
 #define PTP_OC_CASIO_GET_OBJECT		0x9025
 #define PTP_OC_CASIO_GET_THUMBNAIL	0x9026
 
-/* Sony stuff */
-/* 9201:
- *  3 params: 1,0,0 ; IN: data 8 bytes all 0
- * or:
- *  3 params: 2,0,0 ; IN: data 8 bytes all 0 
- * or
- *  3 params: 3,0,0,: IN: data 8 butes all 0
- */
-#define PTP_OC_SONY_SDIOConnect			0x9201
-/* 9202: 1 param, 0xc8; IN data: 
- * 16 bit: 0xc8
- * ptp array 32 bit: index, 16 bit values of propcodes  */
-#define PTP_OC_SONY_GetSDIOGetExtDeviceInfo	0x9202
-
-#define PTP_OC_SONY_GetDevicePropdesc		0x9203
-#define PTP_OC_SONY_GetDevicePropertyValue	0x9204
-/* 1 param, 16bit propcode, SEND DATA: propvalue */
-#define PTP_OC_SONY_SetControlDeviceA		0x9205
-#define PTP_OC_SONY_GetControlDeviceDesc	0x9206
-/* 1 param, 16bit propcode, SEND DATA: propvalue */
-#define PTP_OC_SONY_SetControlDeviceB		0x9207
-/* get all device property data at once */
-#define PTP_OC_SONY_GetAllDevicePropData	0x9209	/* gets a 4126 byte blob of device props ?*/
-
 /* Microsoft / MTP extension codes */
 
 #define PTP_OC_MTP_GetObjectPropsSupported	0x9801
@@ -638,37 +542,12 @@
 #define PTP_OC_OLYMPUS_SetCameraControlMode		0x910b
 #define PTP_OC_OLYMPUS_SetWBRGBGain			0x910c
 #define PTP_OC_OLYMPUS_GetDeviceInfo			0x9301
-#define PTP_OC_OLYMPUS_OpenSession			0x9302
+#define PTP_OC_OLYMPUS_Init1				0x9302
 #define PTP_OC_OLYMPUS_SetDateTime			0x9402
 #define PTP_OC_OLYMPUS_GetDateTime			0x9482
 #define PTP_OC_OLYMPUS_SetCameraID			0x9501
 #define PTP_OC_OLYMPUS_GetCameraID			0x9581
 
-/* Android Random I/O Extensions Codes */
-#define PTP_OC_ANDROID_GetPartialObject64		0x95C1
-#define PTP_OC_ANDROID_SendPartialObject		0x95C2
-#define PTP_OC_ANDROID_TruncateObject			0x95C3
-#define PTP_OC_ANDROID_BeginEditObject			0x95C4
-#define PTP_OC_ANDROID_EndEditObject			0x95C5
-
-/* Leica opcodes, from Lightroom tether plugin */
-#define PTP_OC_LEICA_SetCameraSettings			0x9001
-#define PTP_OC_LEICA_GetCameraSettings			0x9002
-#define PTP_OC_LEICA_GetLensParameter			0x9003
-/* probably 2 arguments.
- * generic: releaseStage, stepSize
- * Release(releasestage) = (releasestage,0)
- * Release() = (0,0)
- * AEStart() = (1,0)
- * Autofocusrelease() = (2,0)
- * AutofocusPush() = (1,0) ... same as AEStart?
- * KeepCameraActive() = (0xe,0)
- */
-#define PTP_OC_LEICA_Release				0x9004
-#define PTP_OC_LEICA_OpenLESession			0x9005
-#define PTP_OC_LEICA_CloseLESession			0x9006
-#define PTP_OC_LEICA_RequestObjectTransferReady		0x9007
-
 /* Proprietary vendor extension operations mask */
 #define PTP_OC_EXTENSION_MASK           0xF000
 #define PTP_OC_EXTENSION                0x9000
@@ -680,7 +559,7 @@
 #define PTP_RC_OK                       0x2001
 #define PTP_RC_GeneralError             0x2002
 #define PTP_RC_SessionNotOpen           0x2003
-#define PTP_RC_InvalidTransactionID     0x2004
+#define PTP_RC_InvalidTransactionID	0x2004
 #define PTP_RC_OperationNotSupported    0x2005
 #define PTP_RC_ParameterNotSupported    0x2006
 #define PTP_RC_IncompleteTransfer       0x2007
@@ -767,12 +646,12 @@
 #define PTP_RC_MTP_WFC_Version_Not_Supported	0xA122
 
 /* libptp2 extended ERROR codes */
-#define PTP_ERROR_TIMEOUT		0x02FA
-#define PTP_ERROR_CANCEL		0x02FB
-#define PTP_ERROR_BADPARAM		0x02FC
-#define PTP_ERROR_RESP_EXPECTED		0x02FD
-#define PTP_ERROR_DATA_EXPECTED		0x02FE
 #define PTP_ERROR_IO			0x02FF
+#define PTP_ERROR_DATA_EXPECTED		0x02FE
+#define PTP_ERROR_RESP_EXPECTED		0x02FD
+#define PTP_ERROR_BADPARAM		0x02FC
+#define PTP_ERROR_CANCEL		0x02FB
+#define PTP_ERROR_TIMEOUT		0x02FA
 
 /* PTP Event Codes */
 
@@ -796,40 +675,36 @@
 #define PTP_EC_CANON_ExtendedErrorcode		0xC005	/* ? */
 #define PTP_EC_CANON_ObjectInfoChanged		0xC008
 #define PTP_EC_CANON_RequestObjectTransfer	0xC009
-#define PTP_EC_CANON_ShutterButtonPressed0	0xC00B
 #define PTP_EC_CANON_CameraModeChanged		0xC00C
-#define PTP_EC_CANON_ShutterButtonPressed1	0xC00E
+#define PTP_EC_CANON_ShutterButtonPressed	0xC00E
 
 #define PTP_EC_CANON_StartDirectTransfer	0xC011
 #define PTP_EC_CANON_StopDirectTransfer		0xC013
 
 /* Canon EOS events */
-#define PTP_EC_CANON_EOS_RequestGetEvent		0xc101
-#define PTP_EC_CANON_EOS_ObjectAddedEx			0xc181
-#define PTP_EC_CANON_EOS_ObjectRemoved			0xc182
-#define PTP_EC_CANON_EOS_RequestGetObjectInfoEx		0xc183
-#define PTP_EC_CANON_EOS_StorageStatusChanged		0xc184
-#define PTP_EC_CANON_EOS_StorageInfoChanged		0xc185
-#define PTP_EC_CANON_EOS_RequestObjectTransfer		0xc186
-#define PTP_EC_CANON_EOS_ObjectInfoChangedEx		0xc187
-#define PTP_EC_CANON_EOS_ObjectContentChanged		0xc188
-#define PTP_EC_CANON_EOS_PropValueChanged		0xc189
-#define PTP_EC_CANON_EOS_AvailListChanged		0xc18a
-#define PTP_EC_CANON_EOS_CameraStatusChanged		0xc18b
-#define PTP_EC_CANON_EOS_WillSoonShutdown		0xc18d
-#define PTP_EC_CANON_EOS_ShutdownTimerUpdated		0xc18e
-#define PTP_EC_CANON_EOS_RequestCancelTransfer		0xc18f
+#define PTP_EC_CANON_EOS_RequestGetEvent	0xc101
+#define PTP_EC_CANON_EOS_ObjectAddedEx		0xc181
+#define PTP_EC_CANON_EOS_ObjectRemoved		0xc182
+#define PTP_EC_CANON_EOS_RequestGetObjectInfoEx	0xc183
+#define PTP_EC_CANON_EOS_StorageStatusChanged	0xc184
+#define PTP_EC_CANON_EOS_StorageInfoChanged	0xc185
+#define PTP_EC_CANON_EOS_RequestObjectTransfer	0xc186
+#define PTP_EC_CANON_EOS_ObjectInfoChangedEx	0xc187
+#define PTP_EC_CANON_EOS_ObjectContentChanged	0xc188
+#define PTP_EC_CANON_EOS_PropValueChanged	0xc189
+#define PTP_EC_CANON_EOS_AvailListChanged	0xc18a
+#define PTP_EC_CANON_EOS_CameraStatusChanged	0xc18b
+#define PTP_EC_CANON_EOS_WillSoonShutdown	0xc18d
+#define PTP_EC_CANON_EOS_ShutdownTimerUpdated	0xc18e
+#define PTP_EC_CANON_EOS_RequestCancelTransfer	0xc18f
 #define PTP_EC_CANON_EOS_RequestObjectTransferDT	0xc190
 #define PTP_EC_CANON_EOS_RequestCancelTransferDT	0xc191
-#define PTP_EC_CANON_EOS_StoreAdded			0xc192
-#define PTP_EC_CANON_EOS_StoreRemoved			0xc193
-#define PTP_EC_CANON_EOS_BulbExposureTime		0xc194
-#define PTP_EC_CANON_EOS_RecordingTime			0xc195
-#define PTP_EC_CANON_EOS_RequestObjectTransferTS	0xC1a2
-#define PTP_EC_CANON_EOS_AfResult			0xc1a3
-#define PTP_EC_CANON_EOS_CTGInfoCheckComplete		0xc1a4
-#define PTP_EC_CANON_EOS_OLCInfoChanged			0xc1a5
-#define PTP_EC_CANON_EOS_RequestObjectTransferFTP	0xc1f1
+#define PTP_EC_CANON_EOS_StoreAdded		0xc192
+#define PTP_EC_CANON_EOS_StoreRemoved		0xc193
+#define PTP_EC_CANON_EOS_BulbExposureTime	0xc194
+#define PTP_EC_CANON_EOS_RecordingTime		0xc195
+#define PTP_EC_CANON_EOS_RequestObjectTransferTS		0xC1a2
+#define PTP_EC_CANON_EOS_AfResult		0xc1a3
 
 /* Nikon extension Event Codes */
 
@@ -840,15 +715,6 @@
 #define PTP_EC_Nikon_AdvancedTransfer		0xC103
 #define PTP_EC_Nikon_PreviewImageAdded		0xC104
 
-/* Olympus E series */
-#define PTP_EC_Olympus_PropertyChanged		0xC102
-#define PTP_EC_Olympus_CaptureComplete		0xC103
-
-/* Sony */
-#define PTP_EC_Sony_ObjectAdded			0xC201
-#define PTP_EC_Sony_ObjectRemoved		0xC202
-#define PTP_EC_Sony_PropertyChanged		0xC203
-
 /* MTP Event codes */
 #define PTP_EC_MTP_ObjectPropChanged		0xC801
 #define PTP_EC_MTP_ObjectPropDescChanged	0xC802
@@ -994,11 +860,8 @@
 #define PTP_OFC_CANON_CRW			0xb101
 #define PTP_OFC_CANON_CRW3			0xb103
 #define PTP_OFC_CANON_MOV			0xb104
-#define PTP_OFC_CANON_MOV2			0xb105
 /* CHDK specific raw mode */
 #define PTP_OFC_CANON_CHDK_CRW			0xb1ff
-/* Sony */
-#define PTP_OFC_SONY_RAW			0xb101
 /* MTP extensions */
 #define PTP_OFC_MTP_MediaCard			0xb211
 #define PTP_OFC_MTP_MediaCardGroup		0xb212
@@ -1261,16 +1124,11 @@
 
 typedef struct _PTPNIKONWifiProfile PTPNIKONWifiProfile;
 
-enum _PTPCanon_changes_types {
-	PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN,
-	PTP_CANON_EOS_CHANGES_TYPE_OBJECTINFO,
-	PTP_CANON_EOS_CHANGES_TYPE_OBJECTTRANSFER,
-	PTP_CANON_EOS_CHANGES_TYPE_PROPERTY,
-	PTP_CANON_EOS_CHANGES_TYPE_CAMERASTATUS,
-	PTP_CANON_EOS_CHANGES_TYPE_FOCUSINFO,
-	PTP_CANON_EOS_CHANGES_TYPE_FOCUSMASK,
-	PTP_CANON_EOS_CHANGES_TYPE_OBJECTREMOVED
-};
+#define PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN		0
+#define PTP_CANON_EOS_CHANGES_TYPE_OBJECTINFO		1
+#define PTP_CANON_EOS_CHANGES_TYPE_OBJECTTRANSFER	2
+#define PTP_CANON_EOS_CHANGES_TYPE_PROPERTY		3
+#define PTP_CANON_EOS_CHANGES_TYPE_CAMERASTATUS		4
 
 struct _PTPCanon_New_Object {
 	uint32_t	oid;
@@ -1278,7 +1136,7 @@
 };
 
 struct _PTPCanon_changes_entry {
-	enum _PTPCanon_changes_types	type;
+	int	type;
 	union {
 		struct _PTPCanon_New_Object	object;	/* TYPE_OBJECTINFO */
 		char				*info;
@@ -1290,6 +1148,7 @@
 
 typedef struct _PTPCanon_Property {
 	uint32_t		size;
+	uint32_t		type;
 	uint32_t		proptype;
 	unsigned char		*data;
 
@@ -1494,7 +1353,7 @@
 #define PTP_DPC_CANON_EOS_ExpCompensation	0xD104
 #define PTP_DPC_CANON_EOS_AutoExposureMode	0xD105
 #define PTP_DPC_CANON_EOS_DriveMode		0xD106
-#define PTP_DPC_CANON_EOS_MeteringMode		0xD107
+#define PTP_DPC_CANON_EOS_MeteringMode		0xD107 
 #define PTP_DPC_CANON_EOS_FocusMode		0xD108
 #define PTP_DPC_CANON_EOS_WhiteBalance		0xD109
 #define PTP_DPC_CANON_EOS_ColorTemperature	0xD10A
@@ -1507,7 +1366,6 @@
 #define PTP_DPC_CANON_EOS_BatteryPower		0xD111
 #define PTP_DPC_CANON_EOS_BatterySelect		0xD112
 #define PTP_DPC_CANON_EOS_CameraTime		0xD113
-#define PTP_DPC_CANON_EOS_AutoPowerOff		0xD114
 #define PTP_DPC_CANON_EOS_Owner			0xD115
 #define PTP_DPC_CANON_EOS_ModelID		0xD116
 #define PTP_DPC_CANON_EOS_PTPExtensionVersion	0xD119
@@ -1526,41 +1384,25 @@
 #define PTP_DPC_CANON_EOS_CompressionM1		0xD131
 #define PTP_DPC_CANON_EOS_CompressionM2		0xD132
 #define PTP_DPC_CANON_EOS_CompressionL		0xD133
-#define PTP_DPC_CANON_EOS_AEModeDial		0xD138
-#define PTP_DPC_CANON_EOS_AEModeCustom		0xD139
-#define PTP_DPC_CANON_EOS_MirrorUpSetting	0xD13A
-#define PTP_DPC_CANON_EOS_HighlightTonePriority	0xD13B
-#define PTP_DPC_CANON_EOS_AFSelectFocusArea	0xD13C
-#define PTP_DPC_CANON_EOS_HDRSetting		0xD13D
 #define PTP_DPC_CANON_EOS_PCWhiteBalance1	0xD140
 #define PTP_DPC_CANON_EOS_PCWhiteBalance2	0xD141
 #define PTP_DPC_CANON_EOS_PCWhiteBalance3	0xD142
 #define PTP_DPC_CANON_EOS_PCWhiteBalance4	0xD143
 #define PTP_DPC_CANON_EOS_PCWhiteBalance5	0xD144
 #define PTP_DPC_CANON_EOS_MWhiteBalance		0xD145
-#define PTP_DPC_CANON_EOS_MWhiteBalanceEx	0xD146
-#define PTP_DPC_CANON_EOS_UnknownPropD14D	0xD14D  /*found in Canon EOS 5D M3*/
 #define PTP_DPC_CANON_EOS_PictureStyleStandard	0xD150
 #define PTP_DPC_CANON_EOS_PictureStylePortrait	0xD151
 #define PTP_DPC_CANON_EOS_PictureStyleLandscape	0xD152
 #define PTP_DPC_CANON_EOS_PictureStyleNeutral	0xD153
 #define PTP_DPC_CANON_EOS_PictureStyleFaithful	0xD154
 #define PTP_DPC_CANON_EOS_PictureStyleBlackWhite	0xD155
-#define PTP_DPC_CANON_EOS_PictureStyleAuto	0xD156
 #define PTP_DPC_CANON_EOS_PictureStyleUserSet1	0xD160
 #define PTP_DPC_CANON_EOS_PictureStyleUserSet2	0xD161
 #define PTP_DPC_CANON_EOS_PictureStyleUserSet3	0xD162
 #define PTP_DPC_CANON_EOS_PictureStyleParam1	0xD170
 #define PTP_DPC_CANON_EOS_PictureStyleParam2	0xD171
 #define PTP_DPC_CANON_EOS_PictureStyleParam3	0xD172
-#define PTP_DPC_CANON_EOS_HighISOSettingNoiseReduction	0xD178
-#define PTP_DPC_CANON_EOS_MovieServoAF		0xD179
-#define PTP_DPC_CANON_EOS_ContinuousAFValid	0xD17A
-#define PTP_DPC_CANON_EOS_Attenuator		0xD17B
-#define PTP_DPC_CANON_EOS_UTCTime		0xD17C
-#define PTP_DPC_CANON_EOS_Timezone		0xD17D
-#define PTP_DPC_CANON_EOS_Summertime		0xD17E
-#define PTP_DPC_CANON_EOS_FlavorLUTParams	0xD17F
+#define PTP_DPC_CANON_EOS_FlavorLUTParams	0xD17f
 #define PTP_DPC_CANON_EOS_CustomFunc1		0xD180
 #define PTP_DPC_CANON_EOS_CustomFunc2		0xD181
 #define PTP_DPC_CANON_EOS_CustomFunc3		0xD182
@@ -1581,16 +1423,6 @@
 #define PTP_DPC_CANON_EOS_CustomFunc18		0xD191
 #define PTP_DPC_CANON_EOS_CustomFunc19		0xD192
 #define PTP_DPC_CANON_EOS_CustomFunc19		0xD192
-#define PTP_DPC_CANON_EOS_InnerDevelop		0xD193
-#define PTP_DPC_CANON_EOS_MultiAspect		0xD194
-#define PTP_DPC_CANON_EOS_MovieSoundRecord	0xD195
-#define PTP_DPC_CANON_EOS_MovieRecordVolume	0xD196
-#define PTP_DPC_CANON_EOS_WindCut		0xD197
-#define PTP_DPC_CANON_EOS_ExtenderType		0xD198
-#define PTP_DPC_CANON_EOS_OLCInfoVersion	0xD199
-#define PTP_DPC_CANON_EOS_UnknownPropD19A	0xD19A /*found in Canon EOS 5D M3*/
-#define PTP_DPC_CANON_EOS_UnknownPropD19C	0xD19C /*found in Canon EOS 5D M3*/
-#define PTP_DPC_CANON_EOS_UnknownPropD19D	0xD19D /*found in Canon EOS 5D M3*/
 #define PTP_DPC_CANON_EOS_CustomFuncEx		0xD1a0
 #define PTP_DPC_CANON_EOS_MyMenu		0xD1a1
 #define PTP_DPC_CANON_EOS_MyMenuList		0xD1a2
@@ -1619,23 +1451,6 @@
 #define PTP_DPC_CANON_EOS_LvAfSystem		0xD1ba
 #define PTP_DPC_CANON_EOS_MovSize		0xD1bb
 #define PTP_DPC_CANON_EOS_LvViewTypeSelect	0xD1bc
-#define PTP_DPC_CANON_EOS_MirrorDownStatus	0xD1bd
-#define PTP_DPC_CANON_EOS_MovieParam		0xD1be
-#define PTP_DPC_CANON_EOS_MirrorLockupState	0xD1bf
-#define PTP_DPC_CANON_EOS_FlashChargingState	0xD1C0
-#define PTP_DPC_CANON_EOS_AloMode		0xD1C1
-#define PTP_DPC_CANON_EOS_FixedMovie		0xD1C2
-#define PTP_DPC_CANON_EOS_OneShotRawOn		0xD1C3
-#define PTP_DPC_CANON_EOS_ErrorForDisplay	0xD1C4
-#define PTP_DPC_CANON_EOS_AEModeMovie		0xD1C5
-#define PTP_DPC_CANON_EOS_BuiltinStroboMode	0xD1C6
-#define PTP_DPC_CANON_EOS_StroboDispState	0xD1C7
-#define PTP_DPC_CANON_EOS_StroboETTL2Metering	0xD1C8
-#define PTP_DPC_CANON_EOS_ContinousAFMode	0xD1C9
-#define PTP_DPC_CANON_EOS_MovieParam2		0xD1CA
-#define PTP_DPC_CANON_EOS_StroboSettingExpComposition		0xD1CB
-#define PTP_DPC_CANON_EOS_MovieParam3		0xD1CC
-#define PTP_DPC_CANON_EOS_LVMedicalRotate	0xD1CF
 #define PTP_DPC_CANON_EOS_Artist		0xD1d0
 #define PTP_DPC_CANON_EOS_Copyright		0xD1d1
 #define PTP_DPC_CANON_EOS_BracketValue		0xD1d2
@@ -1650,8 +1465,6 @@
 #define PTP_DPC_CANON_EOS_StroboWirelessSetting	0xD1db
 #define PTP_DPC_CANON_EOS_StroboFiring		0xD1dc
 #define PTP_DPC_CANON_EOS_LensID		0xD1dd
-#define PTP_DPC_CANON_EOS_LCDBrightness		0xD1de
-#define PTP_DPC_CANON_EOS_CADarkBright		0xD1df
 
 /* Nikon extension device property codes */
 #define PTP_DPC_NIKON_ShootingBank			0xD010
@@ -1690,11 +1503,8 @@
 #define PTP_DPC_NIKON_JPEG_Compression_Policy		0xD031
 #define PTP_DPC_NIKON_ColorSpace			0xD032
 #define PTP_DPC_NIKON_AutoDXCrop			0xD033
-#define PTP_DPC_NIKON_FlickerReduction			0xD034
-#define PTP_DPC_NIKON_RemoteMode			0xD035
 #define PTP_DPC_NIKON_VideoMode				0xD036
 #define PTP_DPC_NIKON_EffectMode			0xD037
-#define PTP_DPC_NIKON_1_Mode				0xD038
 #define PTP_DPC_NIKON_CSMMenuBankSelect			0xD040
 #define PTP_DPC_NIKON_MenuBankNameA			0xD041
 #define PTP_DPC_NIKON_MenuBankNameB			0xD042
@@ -1722,7 +1532,7 @@
 #define PTP_DPC_NIKON_ExposureBaseMatrix		0xD05A
 #define PTP_DPC_NIKON_ExposureBaseCenter		0xD05B
 #define PTP_DPC_NIKON_ExposureBaseSpot			0xD05C
-#define PTP_DPC_NIKON_LiveViewAFArea			0xD05D /* FIXME: AfAtLiveview? */
+#define PTP_DPC_NIKON_LiveViewAFArea			0xD05D
 #define PTP_DPC_NIKON_AELockMode			0xD05E
 #define PTP_DPC_NIKON_AELAFLMode			0xD05F
 #define PTP_DPC_NIKON_LiveViewAFFocus			0xD061
@@ -1776,12 +1586,6 @@
 #define PTP_DPC_NIKON_MovScreenSize			0xD0A0
 #define PTP_DPC_NIKON_MovVoice				0xD0A1
 #define PTP_DPC_NIKON_MovMicrophone			0xD0A2
-#define PTP_DPC_NIKON_MovFileSlot			0xD0A3
-#define PTP_DPC_NIKON_MovRecProhibitCondition		0xD0A4
-#define PTP_DPC_NIKON_ManualMovieSetting		0xD0A6
-#define PTP_DPC_NIKON_MovQuality			0xD0A7
-#define PTP_DPC_NIKON_LiveViewScreenDisplaySetting	0xD0B2
-#define PTP_DPC_NIKON_MonitorOffDelay			0xD0B3
 #define PTP_DPC_NIKON_Bracketing			0xD0C0
 #define PTP_DPC_NIKON_AutoExposureBracketStep		0xD0C1
 #define PTP_DPC_NIKON_AutoExposureBracketProgram	0xD0C2
@@ -1803,8 +1607,6 @@
 #define PTP_DPC_NIKON_VignetteCtrl			0xD0F7
 #define PTP_DPC_NIKON_AutoDistortionControl		0xD0F8
 #define PTP_DPC_NIKON_SceneMode				0xD0F9
-#define PTP_DPC_NIKON_SceneMode2			0xD0FD
-#define PTP_DPC_NIKON_SelfTimerInterval			0xD0FE
 #define PTP_DPC_NIKON_ExposureTime			0xD100	/* Shutter Speed */
 #define PTP_DPC_NIKON_ACPower				0xD101
 #define PTP_DPC_NIKON_WarningStatus			0xD102
@@ -1845,7 +1647,7 @@
 #define PTP_DPC_NIKON_BW_Setting_Type			0xD146
 #define PTP_DPC_NIKON_Slot2SaveMode			0xD148
 #define PTP_DPC_NIKON_RawBitMode			0xD149
-#define PTP_DPC_NIKON_ActiveDLighting			0xD14E /* was PTP_DPC_NIKON_ISOAutoTime */
+#define PTP_DPC_NIKON_ISOAutoTime			0xD14E
 #define PTP_DPC_NIKON_FlourescentType			0xD14F
 #define PTP_DPC_NIKON_TuneColourTemperature		0xD150
 #define PTP_DPC_NIKON_TunePreset0			0xD151
@@ -1868,11 +1670,6 @@
 #define PTP_DPC_NIKON_FlashModeManualPower		0xD16D
 #define PTP_DPC_NIKON_FlashModeCommanderPower		0xD16E
 #define PTP_DPC_NIKON_AutoFP				0xD16F
-#define PTP_DPC_NIKON_DateImprintSetting		0xD170
-#define PTP_DPC_NIKON_DateCounterSelect			0xD171
-#define PTP_DPC_NIKON_DateCountData			0xD172
-#define PTP_DPC_NIKON_DateCountDisplaySetting		0xD173
-#define PTP_DPC_NIKON_RangeFinderSetting		0xD174
 #define PTP_DPC_NIKON_CSMMenu				0xD180
 #define PTP_DPC_NIKON_WarningDisplay			0xD181
 #define PTP_DPC_NIKON_BatteryCellKind			0xD182
@@ -1891,10 +1688,6 @@
 #define PTP_DPC_NIKON_LiveViewStatus			0xD1A2
 #define PTP_DPC_NIKON_LiveViewImageZoomRatio		0xD1A3
 #define PTP_DPC_NIKON_LiveViewProhibitCondition		0xD1A4
-#define PTP_DPC_NIKON_MovieShutterSpeed			0xD1A8
-#define PTP_DPC_NIKON_MovieFNumber			0xD1A9
-#define PTP_DPC_NIKON_MovieISO				0xD1AA
-#define PTP_DPC_NIKON_LiveViewMovieMode			0xD1AC /* ? */
 #define PTP_DPC_NIKON_ExposureDisplayStatus		0xD1B0
 #define PTP_DPC_NIKON_ExposureIndicateStatus		0xD1B1
 #define PTP_DPC_NIKON_InfoDispErrStatus			0xD1B2
@@ -1914,36 +1707,8 @@
 #define PTP_DPC_NIKON_FlashCommandBMode			0xD1DA
 #define PTP_DPC_NIKON_FlashCommandBCompensation		0xD1DB
 #define PTP_DPC_NIKON_FlashCommandBValue		0xD1DC
-#define PTP_DPC_NIKON_ApplicationMode			0xD1F0
-#define PTP_DPC_NIKON_ActiveSlot			0xD1F2
 #define PTP_DPC_NIKON_ActivePicCtrlItem			0xD200
 #define PTP_DPC_NIKON_ChangePicCtrlItem			0xD201
-#define PTP_DPC_NIKON_MovieNrHighISO			0xD236
-
-
-/* Nikon V1 (or WU adapter?) Trace */
-/* d241 - gets string "Nikon_WU2_0090B5123C61" */
-#define PTP_DPC_NIKON_D241				0xD241
-/* d244 - gets a single byte 0x00 */
-#define PTP_DPC_NIKON_D244				0xD244
-/* d247 - gets 3 bytes 0x01 0x00 0x00 */
-#define PTP_DPC_NIKON_D247				0xD247
-/* S9700 */
-#define PTP_DPC_NIKON_GUID				0xD24F
-/* d250 - gets a string "0000123C61" */
-#define PTP_DPC_NIKON_D250				0xD250
-/* d251 - gets a 0x0100000d */
-#define PTP_DPC_NIKON_D251				0xD251
-
-/* this is irregular, as it should be -0x5000 or 0xD000 based */
-#define PTP_DPC_NIKON_1_ISO				0xF002
-#define PTP_DPC_NIKON_1_ImageCompression		0xF009
-#define PTP_DPC_NIKON_1_ImageSize			0xF00A
-#define PTP_DPC_NIKON_1_WhiteBalance			0xF00C
-#define PTP_DPC_NIKON_1_LongExposureNoiseReduction	0xF00D
-#define PTP_DPC_NIKON_1_HiISONoiseReduction		0xF00E
-#define PTP_DPC_NIKON_1_ActiveDLighting			0xF00F
-#define PTP_DPC_NIKON_1_MovQuality			0xF01C
 
 /* Fuji specific */
 #define PTP_DPC_FUJI_ColorTemperature			0xD017
@@ -2058,25 +1823,6 @@
 #define PTP_DPC_OLYMPUS_ISOBracket			0xD15D
 #define PTP_DPC_OLYMPUS_MyModeStatus			0xD15E
 
-/* Sony A900 */
-#define PTP_DPC_SONY_DPCCompensation			0xD200
-#define PTP_DPC_SONY_DRangeOptimize			0xD201
-#define PTP_DPC_SONY_ImageSize				0xD203
-#define PTP_DPC_SONY_ShutterSpeed			0xD20D
-#define PTP_DPC_SONY_ColorTemp				0xD20F
-#define PTP_DPC_SONY_CCFilter				0xD210
-#define PTP_DPC_SONY_AspectRatio			0xD211
-#define PTP_DPC_SONY_ExposeIndex			0xD216
-#define PTP_DPC_SONY_PictureEffect			0xD21B
-#define PTP_DPC_SONY_ABFilter				0xD21C
-#define PTP_DPC_SONY_ISO				0xD21E /* ? */
-/* also seen: D2C3 D2C4 */
-/* semi control opcodes */
-#define PTP_DPC_SONY_Movie				0xD2C8 /* ? */
-#define PTP_DPC_SONY_StillImage				0xD2C7 /* ? */
-
-
-
 /* Casio EX-F1 */
 #define PTP_DPC_CASIO_MONITOR		0xD001 
 #define PTP_DPC_CASIO_STORAGE		0xD002 //Not reported by DeviceInfo?
@@ -2106,8 +1852,6 @@
 #define PTP_DPC_CASIO_UNKNOWN_17	0xD030
 #define PTP_DPC_CASIO_UNKNOWN_18	0xD080
 
-#define PTP_DPC_RICOH_ShutterSpeed	0xD00F
-
 /* MTP specific Object Properties */
 #define PTP_OPC_StorageID				0xDC01
 #define PTP_OPC_ObjectFormat				0xDC02
@@ -2311,7 +2055,7 @@
 
 typedef uint16_t (* PTPDataPutFunc)	(PTPParams* params, void*priv,
 					unsigned long sendlen,
-	                                unsigned char *data);
+	                                unsigned char *data, unsigned long *putlen);
 typedef struct _PTPDataHandler {
 	PTPDataGetFunc		getfunc;
 	PTPDataPutFunc		putfunc;
@@ -2322,9 +2066,9 @@
  * This functions take PTP oriented arguments and send them over an
  * appropriate data layer doing byteorder conversion accordingly.
  */
-typedef uint16_t (* PTPIOSendReq)	(PTPParams* params, PTPContainer* req, int dataphase);
+typedef uint16_t (* PTPIOSendReq)	(PTPParams* params, PTPContainer* req);
 typedef uint16_t (* PTPIOSendData)	(PTPParams* params, PTPContainer* ptp,
-					 uint64_t size, PTPDataHandler*getter);
+					 unsigned long size, PTPDataHandler*getter);
 
 typedef uint16_t (* PTPIOGetResp)	(PTPParams* params, PTPContainer* resp);
 typedef uint16_t (* PTPIOGetData)	(PTPParams* params, PTPContainer* ptp,
@@ -2356,24 +2100,10 @@
 	PTPObjectInfo	oi;
 	uint32_t	canon_flags;
 	MTPProperties	*mtpprops;
-	unsigned int	nrofmtpprops;
+	int		nrofmtpprops;
 };
 typedef struct _PTPObject PTPObject;
 
-/* The Device Property Cache */
-struct _PTPDeviceProperty {
-	time_t			timestamp;
-	PTPDevicePropDesc	desc;
-	PTPPropertyValue	value;
-};
-typedef struct _PTPDeviceProperty PTPDeviceProperty;
-
-/* Transaction data phase description, internal flags to sendreq / transaction driver. */
-#define PTP_DP_NODATA           0x0000  /* no data phase */
-#define PTP_DP_SENDDATA         0x0001  /* sending data */
-#define PTP_DP_GETDATA          0x0002  /* receiving data */
-#define PTP_DP_DATA_MASK        0x00ff  /* data phase mask */
-
 struct _PTPParams {
 	/* device flags */
 	uint32_t	device_flags;
@@ -2403,16 +2133,13 @@
 	/* ptp session ID */
 	uint32_t	session_id;
 
-	/* used for open capture */
-	uint32_t	opencapture_transid;
-
 	/* PTP IO: if we have MTP style split header/data transfers */
 	int		split_header_data;
 	int		ocs64; /* 64bit objectsize */
 
 	/* PTP: internal structures used by ptp driver */
 	PTPObject	*objects;
-	unsigned int	nrofobjects;
+	int		nrofobjects;
 
 	PTPDeviceInfo	deviceinfo;
 
@@ -2420,30 +2147,19 @@
 	PTPContainer	*events;
 	int		nrofevents;
 
-	/* live view enabled */
-	int			inliveview;
-
-	/* PTP: Device Property Caching */
-	PTPDeviceProperty	*deviceproperties;
-	unsigned int		nrofdeviceproperties;
-
 	/* PTP: Canon specific flags list */
 	PTPCanon_Property	*canon_props;
-	unsigned int		nrofcanon_props;
+	int			nrofcanon_props;
 	int			canon_viewfinder_on;
 	int			canon_event_mode;
 
 	/* PTP: Canon EOS event queue */
 	PTPCanon_changes_entry	*backlogentries;
-	unsigned int		nrofbacklogentries;
+	int			nrofbacklogentries;
 	int			eos_captureenabled;
+	int			eos_viewfinderenabled;
 	int			eos_camerastatus;
 
-	/* PTP: Nikon specifics */
-	int			controlmode;
-	int			event90c7works;
-	int			deletesdramfails;
-
 	/* PTP: Wifi profiles */
 	uint8_t 	wifi_profiles_version;
 	uint8_t		wifi_profiles_number;
@@ -2459,9 +2175,8 @@
 	PTPDeviceInfo	outer_deviceinfo;
 	char		*olympus_cmd;
 	char		*olympus_reply;
-	struct _PTPParams *outer_params;
 
-#if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H)
+#ifdef HAVE_ICONV
 	/* PTP: iconv converters */
 	iconv_t	cd_locale_to_ucs2;
 	iconv_t cd_ucs2_to_locale;
@@ -2474,19 +2189,15 @@
 	uint16_t	response_packet_size;
 };
 
-/* Asynchronous event callback */
-typedef void(* PTPEventCbFn) (PTPParams *params, uint16_t code, PTPContainer *event, void *user_data);
-
 /* last, but not least - ptp functions */
-uint16_t ptp_usb_sendreq	(PTPParams* params, PTPContainer* req, int dataphase);
+uint16_t ptp_usb_sendreq	(PTPParams* params, PTPContainer* req);
 uint16_t ptp_usb_senddata	(PTPParams* params, PTPContainer* ptp,
-				 uint64_t size, PTPDataHandler *handler);
+				 unsigned long size, PTPDataHandler *handler);
 uint16_t ptp_usb_getresp	(PTPParams* params, PTPContainer* resp);
 uint16_t ptp_usb_getdata	(PTPParams* params, PTPContainer* ptp, 
 	                         PTPDataHandler *handler);
 uint16_t ptp_usb_event_check	(PTPParams* params, PTPContainer* event);
 uint16_t ptp_usb_event_wait	(PTPParams* params, PTPContainer* event);
-uint16_t ptp_usb_event_async	(PTPParams *params, PTPEventCbFn cb, void *user_data);
 
 uint16_t ptp_usb_control_get_extended_event_data (PTPParams *params, char *buffer, int *size);
 uint16_t ptp_usb_control_device_reset_request (PTPParams *params);
@@ -2495,9 +2206,9 @@
 
 
 int      ptp_ptpip_connect	(PTPParams* params, const char *port);
-uint16_t ptp_ptpip_sendreq	(PTPParams* params, PTPContainer* req, int dataphase);
+uint16_t ptp_ptpip_sendreq	(PTPParams* params, PTPContainer* req);
 uint16_t ptp_ptpip_senddata	(PTPParams* params, PTPContainer* ptp,
-				uint64_t size, PTPDataHandler *handler);
+				unsigned long size, PTPDataHandler *handler);
 uint16_t ptp_ptpip_getresp	(PTPParams* params, PTPContainer* resp);
 uint16_t ptp_ptpip_getdata	(PTPParams* params, PTPContainer* ptp, 
 	                         PTPDataHandler *handler);
@@ -2510,15 +2221,6 @@
 
 uint16_t ptp_opensession	(PTPParams *params, uint32_t session);
 
-uint16_t ptp_transaction_new (PTPParams* params, PTPContainer* ptp, 
-                uint16_t flags, uint64_t sendlen,
-                PTPDataHandler *handler
-);
-uint16_t ptp_transaction (PTPParams* params, PTPContainer* ptp,
-                uint16_t flags, uint64_t sendlen,
-                unsigned char **data, unsigned int *recvlen
-);
-
 /**
  * ptp_closesession:
  * params:      PTPParams*
@@ -2528,16 +2230,6 @@
  * Return values: Some PTP_RC_* code.
  **/
 #define ptp_closesession(params) ptp_generic_no_data(params,PTP_OC_CloseSession,0)
-
-/**
- * ptp_powerdown:
- * params:      PTPParams*
- *
- * Powers down device.
- *
- * Return values: Some PTP_RC_* code.
- **/
-#define ptp_powerdown(params) ptp_generic_no_data(params,PTP_OC_PowerDown,0)
 /**
  * ptp_resetdevice:
  * params:      PTPParams*
@@ -2584,9 +2276,6 @@
 uint16_t ptp_getpartialobject	(PTPParams* params, uint32_t handle, uint32_t offset,
 				uint32_t maxbytes, unsigned char** object,
 				uint32_t *len);
-uint16_t ptp_getpartialobject_to_handler (PTPParams* params, uint32_t handle, uint32_t offset,
-                        	uint32_t maxbytes, PTPDataHandler *handler);
-
 uint16_t ptp_getthumb		(PTPParams *params, uint32_t handle,
 				unsigned char** object, unsigned int *len);
 
@@ -2608,9 +2297,9 @@
  */
 #define ptp_setobjectprotection(params,oid,newprot) ptp_generic_no_data(params,PTP_OC_SetObjectProtection,2,oid,newprot)
 uint16_t ptp_sendobject		(PTPParams* params, unsigned char* object,
-				 uint64_t size);
-uint16_t ptp_sendobject_fromfd  (PTPParams* params, int fd, uint64_t size);
-uint16_t ptp_sendobject_from_handler  (PTPParams* params, PTPDataHandler*, uint64_t size);
+				 uint32_t size);
+uint16_t ptp_sendobject_fromfd  (PTPParams* params, int fd, uint32_t size);
+uint16_t ptp_sendobject_from_handler  (PTPParams* params, PTPDataHandler*, uint32_t size);
 /**
  * ptp_initiatecapture:
  * params:      PTPParams*
@@ -2627,19 +2316,12 @@
  **/
 #define ptp_initiatecapture(params,storageid,ofc) ptp_generic_no_data(params,PTP_OC_InitiateCapture,2,storageid,ofc)
 
-#define ptp_initiateopencapture(params,storageid,ofc)	ptp_generic_no_data(params,PTP_OC_InitiateOpenCapture,2,storageid,ofc)
-#define ptp_terminateopencapture(params,transid)	ptp_generic_no_data(params,PTP_OC_TerminateOpenCapture,1,transid)
-
 uint16_t ptp_getdevicepropdesc	(PTPParams* params, uint16_t propcode,
 				PTPDevicePropDesc *devicepropertydesc);
-uint16_t ptp_generic_getdevicepropdesc (PTPParams *params, uint16_t propcode,
-				PTPDevicePropDesc *dpd);
 uint16_t ptp_getdevicepropvalue	(PTPParams* params, uint16_t propcode,
 				PTPPropertyValue* value, uint16_t datatype);
 uint16_t ptp_setdevicepropvalue (PTPParams* params, uint16_t propcode,
                         	PTPPropertyValue* value, uint16_t datatype);
-uint16_t ptp_generic_setdevicepropvalue (PTPParams* params, uint16_t propcode,
-                        	PTPPropertyValue* value, uint16_t datatype);
 uint16_t ptp_getfilesystemmanifest (PTPParams* params, uint32_t storage,
                         uint32_t objectformatcode, uint32_t associationOH,
                         unsigned char** data);
@@ -2647,8 +2329,6 @@
 
 
 uint16_t ptp_check_event (PTPParams *params);
-uint16_t ptp_wait_event (PTPParams *params);
-uint16_t ptp_add_event (PTPParams *params, PTPContainer *evt);
 int ptp_get_one_event (PTPParams *params, PTPContainer *evt);
 uint16_t ptp_check_eos_events (PTPParams *params);
 int ptp_get_one_eos_event (PTPParams *params, PTPCanon_changes_entry *entry);
@@ -2846,12 +2526,6 @@
  * Return values: Some PTP_RC_* code.
  *
  **/
-#define CANON_EOS_OLC_BUTTON 		0x0001
-#define CANON_EOS_OLC_SHUTTERSPEED 	0x0002
-#define CANON_EOS_OLC_APERTURE 		0x0004
-#define CANON_EOS_OLC_ISO 		0x0008
-
-#define ptp_canon_eos_setrequestolcinfogroup(params,igmask) ptp_generic_no_data(params,PTP_OC_CANON_EOS_SetRequestOLCInfoGroup,1,igmask)
 #define ptp_canon_eos_requestdevicepropvalue(params,prop) ptp_generic_no_data(params,PTP_OC_CANON_EOS_RequestDevicePropValue,1,prop)
 uint16_t ptp_canon_eos_capture (PTPParams* params, uint32_t *result);
 uint16_t ptp_canon_eos_getevent (PTPParams* params, PTPCanon_changes_entry **entries, int *nrofentries);
@@ -2968,18 +2642,6 @@
 uint16_t ptp_nikon_getptpipinfo (PTPParams* params, unsigned char **data, unsigned int *size);
 uint16_t ptp_nikon_getwifiprofilelist (PTPParams* params);
 uint16_t ptp_nikon_writewifiprofile (PTPParams* params, PTPNIKONWifiProfile* profile);
-
-uint16_t ptp_sony_sdioconnect (PTPParams* params, uint32_t p1, uint32_t p2, uint32_t p3);
-uint16_t ptp_sony_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int *size);
-uint16_t ptp_sony_getdevicepropdesc (PTPParams* params, uint16_t propcode,
-				PTPDevicePropDesc *devicepropertydesc);
-uint16_t ptp_sony_getalldevicepropdesc (PTPParams* params);
-uint16_t ptp_sony_setdevicecontrolvaluea (PTPParams* params, uint16_t propcode,
-                        	PTPPropertyValue* value, uint16_t datatype);
-uint16_t ptp_sony_setdevicecontrolvalueb (PTPParams* params, uint16_t propcode,
-                        	PTPPropertyValue* value, uint16_t datatype);
-uint16_t ptp_sony_9280 (PTPParams* params, uint32_t additional, uint32_t data1, uint32_t data2, uint32_t data3, uint32_t data4, uint8_t x, uint8_t y);
-uint16_t ptp_sony_9281 (PTPParams* params, uint32_t param1);
 /**
  * ptp_nikon_deletewifiprofile:
  *
@@ -3005,19 +2667,6 @@
  **/
 #define ptp_nikon_setcontrolmode(params,mode) ptp_generic_no_data(params,PTP_OC_NIKON_SetControlMode,1,mode)
 /**
- * ptp_nikon_terminatecapture:
- *
- * This command appears to terminate a longer capture
- *  
- * params:      PTPParams*
- *      uint32_t a 
- *      uint32_t b 
- *
- * Return values: Some PTP_RC_* code.
- *
- **/
-#define ptp_nikon_terminatecapture(params,p1,p2) ptp_generic_no_data(params,PTP_OC_NIKON_TerminateCapture,2,p1,p2)
-/**
  * ptp_nikon_afdrive:
  *
  * This command runs (drives) the lens autofocus.
@@ -3029,41 +2678,6 @@
  **/
 #define ptp_nikon_afdrive(params) ptp_generic_no_data(params,PTP_OC_NIKON_AfDrive,0)
 /**
- * ptp_nikon_changeafarea:
- *
- * This command starts movie capture (to card)
- *  
- * params:      PTPParams*
- * x: x coordinate
- * y: y coordinate
- *
- * Return values: Some PTP_RC_* code.
- *
- **/
-#define ptp_nikon_changeafarea(params,x,y) ptp_generic_no_data(params,PTP_OC_NIKON_ChangeAfArea,2,x,y)
-/**
- * ptp_nikon_startmovie:
- *
- * This command starts movie capture (to card)
- *  
- * params:      PTPParams*
- *
- * Return values: Some PTP_RC_* code.
- *
- **/
-#define ptp_nikon_startmovie(params) ptp_generic_no_data(params,PTP_OC_NIKON_StartMovieRecInCard,0)
-/**
- * ptp_nikon_stopmovie:
- *
- * This command stops movie capture (to card)
- *  
- * params:      PTPParams*
- *
- * Return values: Some PTP_RC_* code.
- *
- **/
-#define ptp_nikon_stopmovie(params) ptp_generic_no_data(params,PTP_OC_NIKON_EndMovieRec,0)
-/**
  * ptp_canon_eos_afdrive:
  *
  * This command runs (drives) the lens autofocus.
@@ -3075,17 +2689,6 @@
  **/
 #define ptp_canon_eos_afdrive(params) ptp_generic_no_data(params,PTP_OC_CANON_EOS_DoAf,0)
 /**
- * ptp_canon_eos_afcancel:
- *
- * This command cancels the lens autofocus.
- *  
- * params:      PTPParams*
- *
- * Return values: Some PTP_RC_* code.
- *
- **/
-#define ptp_canon_eos_afcancel(params) ptp_generic_no_data(params,PTP_OC_CANON_EOS_AfCancel,0)
-/**
  * ptp_canon_eos_zoom:
  *
  * This command runs (drives) the lens autofocus.
@@ -3099,7 +2702,7 @@
 #define ptp_canon_eos_zoom(params,x) ptp_generic_no_data(params,PTP_OC_CANON_EOS_Zoom,1,x)
 #define ptp_canon_eos_zoomposition(params,x,y) ptp_generic_no_data(params,PTP_OC_CANON_EOS_ZoomPosition,2,x,y)
 
-#define ptp_canon_eos_remotereleaseon(params,x,y) ptp_generic_no_data(params,PTP_OC_CANON_EOS_RemoteReleaseOn,2,x,y)
+#define ptp_canon_eos_remotereleaseon(params,x) ptp_generic_no_data(params,PTP_OC_CANON_EOS_RemoteReleaseOn,1,x)
 #define ptp_canon_eos_remotereleaseoff(params,x) ptp_generic_no_data(params,PTP_OC_CANON_EOS_RemoteReleaseOff,1,x)
 /**
  * ptp_nikon_mfdrive:
@@ -3133,28 +2736,12 @@
  * This command captures a picture on the Nikon.
  *  
  * params:      PTPParams*
- *      uint32_t x: unknown parameter. seen to be -1.
+ *      uint32_t x - unknown parameter. seen to be -1.
  *
  * Return values: Some PTP_RC_* code.
  *
  **/
 #define ptp_nikon_capture(params,x) ptp_generic_no_data(params,PTP_OC_NIKON_Capture,1,x)
-
-/**
- * ptp_nikon_capture2:
- *
- * This command captures a picture on the Nikon.
- *  
- * params:      PTPParams*
- * af: 		autofocus before capture (1 yes , 0 no)
- * target:	sdram 1, card 0
- *
- * Return values: Some PTP_RC_* code.
- * 2 params:
- * 0xffffffff == No AF before,  0xfffffffe == AF before capture
- * sdram=1, card=0
- */
-#define ptp_nikon_capture2(params,af,target) ptp_generic_no_data(params,PTP_OC_NIKON_InitiateCaptureRecInMedia,2,af?0xfffffffe:0xffffffff,target)
 /**
  * ptp_nikon_capture_sdram:
  *
@@ -3202,7 +2789,7 @@
  *
  **/
 #define ptp_nikon_end_liveview(params) ptp_generic_no_data(params,PTP_OC_NIKON_EndLiveView,0)
-uint16_t ptp_nikon_check_event (PTPParams* params, PTPContainer **evt, unsigned int *evtcnt);
+uint16_t ptp_nikon_check_event (PTPParams* params, PTPContainer **evt, int *evtcnt);
 uint16_t ptp_nikon_getfileinfoinblock (PTPParams* params, uint32_t p1, uint32_t p2, uint32_t p3,
 					unsigned char **data, unsigned int *size);
 /**
@@ -3219,23 +2806,6 @@
 #define ptp_nikon_device_ready(params) ptp_generic_no_data (params, PTP_OC_NIKON_DeviceReady, 0)
 uint16_t ptp_mtp_getobjectpropssupported (PTPParams* params, uint16_t ofc, uint32_t *propnum, uint16_t **props);
 
-
-/* Android MTP Extensions */
-uint16_t ptp_android_getpartialobject64	(PTPParams* params, uint32_t handle, uint64_t offset,
-					uint32_t maxbytes, unsigned char** object,
-					uint32_t *len);
-#define ptp_android_begineditobject(params,handle) ptp_generic_no_data (params, PTP_OC_ANDROID_BeginEditObject, 1, handle)
-#define ptp_android_truncate(params,handle,offset) ptp_generic_no_data (params, PTP_OC_ANDROID_TruncateObject, 3, handle, (offset & 0xFFFFFFFF), (offset >> 32))
-uint16_t ptp_android_sendpartialobject (PTPParams *params, uint32_t handle,
-					uint64_t offset, unsigned char *object, uint32_t len);
-#define ptp_android_endeditobject(params,handle) ptp_generic_no_data (params, PTP_OC_ANDROID_EndEditObject, 1, handle)
-
-uint16_t ptp_olympus_getdeviceinfo (PTPParams*, PTPDeviceInfo*);
-#define ptp_olympus_setcameracontrolmode(params,p1) ptp_generic_no_data (params, PTP_OC_OLYMPUS_SetCameraControlMode, 1, p1)
-uint16_t ptp_olympus_opensession (PTPParams*, unsigned char**, unsigned int *);
-#define ptp_olympus_capture(params,p1) ptp_generic_no_data (params, PTP_OC_OLYMPUS_Capture, 1, p1)
-uint16_t ptp_olympus_getcameraid (PTPParams*, unsigned char**, unsigned int *);
-
 /* Non PTP protocol functions */
 static inline int
 ptp_operation_issupported(PTPParams* params, uint16_t operation)
@@ -3252,41 +2822,74 @@
 int ptp_event_issupported	(PTPParams* params, uint16_t event);
 int ptp_property_issupported	(PTPParams* params, uint16_t property);
 
+void ptp_free_devicepropdesc	(PTPDevicePropDesc* dpd);
+void ptp_free_devicepropvalue	(uint16_t dt, PTPPropertyValue* dpd);
+void ptp_free_objectpropdesc	(PTPObjectPropDesc* dpd);
 void ptp_free_params		(PTPParams *params);
-void ptp_free_objectpropdesc	(PTPObjectPropDesc*);
-void ptp_free_devicepropdesc	(PTPDevicePropDesc*);
-void ptp_free_devicepropvalue	(uint16_t, PTPPropertyValue*);
 void ptp_free_objectinfo	(PTPObjectInfo *oi);
 void ptp_free_object		(PTPObject *oi);
 
-const char *ptp_strerror	(uint16_t ret, uint16_t vendor);
+const char *ptp_strerror(uint16_t error);
+void ptp_perror			(PTPParams* params, uint16_t error);
 void ptp_debug			(PTPParams *params, const char *format, ...);
 void ptp_error			(PTPParams *params, const char *format, ...);
 
 
-const char* ptp_get_property_description(PTPParams* params, uint16_t dpc);
-
-const char* ptp_get_opcode_name(PTPParams* params, uint16_t opcode);
+const char*
+ptp_get_property_description(PTPParams* params, uint16_t dpc);
 
 int
 ptp_render_property_value(PTPParams* params, uint16_t dpc,
-                          PTPDevicePropDesc *dpd, unsigned int length, char *out);
+                          PTPDevicePropDesc *dpd, int length, char *out);
 int ptp_render_ofc(PTPParams* params, uint16_t ofc, int spaceleft, char *txt);
+int ptp_render_opcode(PTPParams* params, uint16_t opcode, int spaceleft, char *txt);
 int ptp_render_mtp_propname(uint16_t propid, int spaceleft, char *txt);
 MTPProperties *ptp_get_new_object_prop_entry(MTPProperties **props, int *nrofprops);
 void ptp_destroy_object_prop(MTPProperties *prop);
 void ptp_destroy_object_prop_list(MTPProperties *props, int nrofprops);
 MTPProperties *ptp_find_object_prop_in_cache(PTPParams *params, uint32_t const handle, uint32_t const attribute_id);
-uint16_t ptp_remove_object_from_cache(PTPParams *params, uint32_t handle);
+void ptp_remove_object_from_cache(PTPParams *params, uint32_t handle);
 uint16_t ptp_add_object_to_cache(PTPParams *params, uint32_t handle);
-uint16_t ptp_object_want (PTPParams *, uint32_t handle, unsigned int want, PTPObject**retob);
+uint16_t ptp_object_want (PTPParams *, uint32_t handle, int want, PTPObject**retob);
 void ptp_objects_sort (PTPParams *);
 uint16_t ptp_object_find (PTPParams *params, uint32_t handle, PTPObject **retob);
 uint16_t ptp_object_find_or_insert (PTPParams *params, uint32_t handle, PTPObject **retob);
 /* ptpip.c */
 void ptp_nikon_getptpipguid (unsigned char* guid);
 
-/* CHDK specifics */
+enum PTP_CHDK_Command {
+  PTP_CHDK_Shutdown = 0,    /* param2 is 0 (hard), 1 (soft), 2 (reboot) or 3 (reboot fw update)
+                               if param2 == 3, then filename of fw update is send as data (empty for default) */
+  PTP_CHDK_GetMemory,       /* param2 is base address (or 0 for live image buffer, 1 for bitmap buffer)
+                               param3 is size (in bytes)
+                               return data is memory block */
+  PTP_CHDK_SetMemoryLong,   /* param2 is address
+                               param3 is value */
+  PTP_CHDK_CallFunction,    /* data is array of function pointer and (long) arguments  (max: 10 args)
+                               return param1 is return value */
+  PTP_CHDK_GetPropCase,     /* param2 is base id
+                               param3 is number of properties
+                               return data is array of longs */
+  PTP_CHDK_GetParamData,    /* param2 is base id
+                               param3 is number of parameters
+                               return data is sequence of strings prefixed by their length (as long) */
+  PTP_CHDK_TempData,        /* data is data to be stored for later */
+  PTP_CHDK_UploadFile,      /* data is 4-byte length of filename, followed by filename and contents */
+  PTP_CHDK_DownloadFile,    /* preceded by PTP_CHDK_TempData with filename
+                               return data are file contents */
+  PTP_CHDK_SwitchMode,      /* param2 is 0 (playback) or 1 (record) */
+  PTP_CHDK_ExecuteLUA,      /* data is script to be executed */
+  PTP_CHDK_GetVideoSettings,
+  PTP_CHDK_GetScriptOutput, /* return script output in ASCIIZ */
+  PTP_CHDK_OpenDir,         /* open directory listing, data is directory name */
+  PTP_CHDK_ReadDir,         /* return data is next file info */
+  PTP_CHDK_CloseDir,        /* close directory listing */
+  PTP_CHDK_GetShootingModesList, /* not used */
+  PTP_CHDK_StartDownloadFile,
+  PTP_CHDK_ResumeDownloadFile,
+  PTP_CHDK_EndDownloadFile,
+};
+
 #define PTP_OC_CHDK	0x9999
 typedef struct tagptp_chdk_videosettings {
 	long live_image_buffer_width;
@@ -3298,56 +2901,19 @@
 	unsigned palette[16]; 
 } ptp_chdk_videosettings;
 
-/* Nafraf: Test this!!!*/
+#define ptp_chdk_shutdown_hard(params) ptp_generic_no_data(params,PTP_OC_CHDK,2,PTP_CHDK_Shutdown,0)
+#define ptp_chdk_shutdown_soft(params) ptp_generic_no_data(params,PTP_OC_CHDK,2,PTP_CHDK_Shutdown,1)
+#define ptp_chdk_reboot(params) ptp_generic_no_data(params,PTP_OC_CHDK,2,PTP_CHDK_Shutdown,2)
+#define ptp_chdk_reboot_fw_update(params) ptp_generic_no_data(params,PTP_OC_CHDK,2,PTP_CHDK_Shutdown,3)
+uint16_t ptp_chdk_get_memory(PTPParams* params, int start, int num, unsigned char**);
+#define ptp_chdk_set_memory_long(params,addr,val) ptp_generic_no_data(params,PTP_OC_CHDK,3,PTP_CHDK_SetMemoryLong,addr,val)
+uint16_t ptp_chdk_call(PTPParams* params, int *args, int size, int *ret);
+uint16_t ptp_chdk_get_propcase(PTPParams* params, int start, int num, int* ints);
+uint16_t ptp_chdk_get_paramdata(PTPParams* params, int start, int num, unsigned char** x);
 #define ptp_chdk_switch_mode(params,mode) ptp_generic_no_data(params,PTP_OC_CHDK,2,PTP_CHDK_SwitchMode,mode)
-
-/* include CHDK ptp protocol definitions from a CHDK source tree */
-#include "chdk_ptp.h"
-#if (PTP_CHDK_VERSION_MAJOR < 2 || (PTP_CHDK_VERSION_MAJOR == 2 && PTP_CHDK_VERSION_MINOR < 5))
-#error your chdk headers are too old, unset CHDK_SRC_DIR in config.mk
-#endif
-#include "chdk_live_view.h"
-
-/* the following happens to match what is used in CHDK, but is not part of the protocol */
-typedef struct {
-    unsigned size;
-    unsigned script_id; /* id of script message is to/from  */
-    unsigned type;
-    unsigned subtype;
-    char data[];
-} ptp_chdk_script_msg;
-
-/*
-chunk for remote capture
-*/
-typedef struct {
-	uint32_t size; /* length of data */
-	int last; /* is it the last chunk? */
-	uint32_t offset; /* offset within file, or -1 */
-	unsigned char *data; /* data, must be free'd by caller when done */
-} ptp_chdk_rc_chunk;
-
-
-uint16_t ptp_chdk_get_memory(PTPParams* params, int start, int num, unsigned char **);
-uint16_t ptp_chdk_set_memory_long(PTPParams* params, int addr, int val);
-int ptp_chdk_upload(PTPParams* params, char *local_fn, char *remote_fn);
-uint16_t ptp_chdk_download(PTPParams* params, char *remote_fn, PTPDataHandler *handler);
-
-/* remote capture */
-uint16_t ptp_chdk_rcisready(PTPParams* params, int *isready,int *imgnum);
-uint16_t ptp_chdk_rcgetchunk(PTPParams* params,int fmt, ptp_chdk_rc_chunk *chunk);
-
-uint16_t ptp_chdk_exec_lua(PTPParams* params, char *script, int flags, int *script_id,int *status);
-uint16_t ptp_chdk_get_version(PTPParams* params, int *major, int *minor);
-uint16_t ptp_chdk_get_script_support(PTPParams* params, unsigned *status);
-uint16_t ptp_chdk_get_script_status(PTPParams* params, unsigned *status);
-uint16_t ptp_chdk_write_script_msg(PTPParams* params, char *data, unsigned size, int target_script_id, int *status);
-uint16_t ptp_chdk_read_script_msg(PTPParams* params, ptp_chdk_script_msg **msg);
-uint16_t ptp_chdk_get_live_data(PTPParams* params, unsigned flags, unsigned char **data, unsigned int *data_size);
-uint16_t ptp_chdk_call_function(PTPParams* params, int *args, int size, int *ret);
-
-/*uint16_t ptp_chdk_get_script_output(PTPParams* params, char **output ); */
-/*uint16_t ptp_chdk_get_video_settings(PTPParams* params, ptp_chdk_videosettings* vsettings);*/
+uint16_t ptp_chdk_exec_lua(PTPParams *params, char *script, uint32_t* ret);
+uint16_t ptp_chdk_get_script_output(PTPParams* params, char **output );
+uint16_t ptp_chdk_get_video_settings(PTPParams* params, ptp_chdk_videosettings* vsettings);
 
 #ifdef __cplusplus
 }
diff --git a/src/util.c b/src/util.c
index 7f778a5..7e3b39a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -34,36 +34,9 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <string.h>
-#include "config.h"
 #include "libmtp.h"
 #include "util.h"
 
-
-/**
- * This prints to stdout info about device being UNKNOWN, its
- * ids, and libmtp's version number.
- *
- * @param dev_number the device number
- * @param id_vendor vendor ID from the usb_device_desc struct
- * @param id_product product ID from the usb_device_desc struct
- */
-void device_unknown(const int dev_number, const int id_vendor, const int id_product)
-{
-  // This device is unknown to the developers
-  LIBMTP_ERROR("Device %d (VID=%04x and PID=%04x) is UNKNOWN in libmtp v%s.\n",
-    dev_number,
-    id_vendor,
-    id_product,
-    LIBMTP_VERSION_STRING);
-  LIBMTP_ERROR("Please report this VID/PID and the device model to the "
-               "libmtp development team\n");
-  /*
-   * Trying to get iManufacturer or iProduct from the device at this
-   * point would require opening a device handle, that we don't want
-   * to do right now. (Takes time for no good enough reason.)
-   */
-}
-
 /**
  * This dumps out a number of bytes to a textual, hexadecimal
  * dump.
@@ -77,7 +50,7 @@
 {
   unsigned char *bp = (unsigned char *) buf;
   uint32_t i;
-
+  
   for (i = 0; i < n; i++) {
     fprintf(f, "%02x ", *bp);
     bp++;
@@ -103,31 +76,31 @@
   uint32_t ln, lc;
   int i;
   unsigned char *bp = (unsigned char *) buf;
-
+  
   lc = 0;
   while (remain) {
     fprintf(f, "\t%04x:", dump_boundry-0x10);
-
+    
     ln = ( remain > 16 ) ? 16 : remain;
-
+    
     for (i = 0; i < ln; i++) {
       if ( ! (i%2) ) fprintf(f, " ");
       fprintf(f, "%02x", bp[16*lc+i]);
     }
-
+    
     if ( ln < 16 ) {
       int width = ((16-ln)/2)*5 + (2*(ln%2));
       fprintf(f, "%*.*s", width, width, "");
     }
-
+    
     fprintf(f, "\t");
     for (i = 0; i < ln; i++) {
       unsigned char ch= bp[16*lc+i];
-      fprintf(f, "%c", ( ch >= 0x20 && ch <= 0x7e ) ?
+      fprintf(f, "%c", ( ch >= 0x20 && ch <= 0x7e ) ? 
 	      ch : '.');
     }
     fprintf(f, "\n");
-
+    
     lc++;
     remain -= ln;
     dump_boundry += ln;
diff --git a/src/util.h b/src/util.h
index e888e9f..02be5bf 100644
--- a/src/util.h
+++ b/src/util.h
@@ -24,7 +24,7 @@
 #define __MTP__UTIL__H
 
 #ifdef HAVE_CONFIG_H
-#include "config.h" // To get HAVE_STRNDUP
+#include "config.h"
 #endif
 
 void data_dump(FILE *f, void *buf, uint32_t nbytes);
@@ -32,7 +32,6 @@
 #ifndef HAVE_STRNDUP
 char *strndup (const char *s, size_t n);
 #endif
-void device_unknown(const int dev_number, const int id_vendor, const int id_product);
 
 /**
  * Info macro
diff --git a/util/Makefile.in b/util/Makefile.in
index 9b217ed..3249223 100644
--- a/util/Makefile.in
+++ b/util/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
-
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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.
@@ -14,62 +15,15 @@
 
 @SET_MAKE@
 
+#if USE_LINUX
+#bin_PROGRAMS=mtp-hotplug
+#mtp_hotplug_SOURCES=mtp-hotplug.c
+#
+#mtp_probedir=@UDEV@
+#mtp_probe_PROGRAMS=mtp-probe
+#mtp_probe_SOURCES=mtp-probe.c
+#endif
 VPATH = @srcdir@
-am__is_gnu_make = { \
-  if test -z '$(MAKELEVEL)'; then \
-    false; \
-  elif test -n '$(MAKE_HOST)'; then \
-    true; \
-  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
-    true; \
-  else \
-    false; \
-  fi; \
-}
-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@
@@ -89,6 +43,7 @@
 build_triplet = @build@
 host_triplet = @host@
 subdir = util
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/byteorder.m4 \
 	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/libtool.m4 \
@@ -97,18 +52,15 @@
 	$(top_srcdir)/m4/stdint.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DIST_SOURCES =
-am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AS = @AS@
 AUTOCONF = @AUTOCONF@
@@ -254,6 +206,7 @@
 	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign util/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
 	  $(AUTOMAKE) --foreign util/Makefile
+.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
 	  *config.status*) \
@@ -277,30 +230,12 @@
 
 clean-libtool:
 	-rm -rf .libs _libs
-
-ID: $(am__tagged_files)
-	$(am__define_uniq_tagged_files); mkid -fID $$unique
 tags: TAGS
 TAGS:
 
 ctags: CTAGS
 CTAGS:
 
-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
 
 distdir: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -434,22 +369,16 @@
 
 .MAKE: install-am install-strip
 
-.PHONY: all all-am check check-am clean \
-	clean-generic clean-libtool \
-	cscopelist-am distclean \
-	distclean-compile 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 \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am uninstall uninstall-am
-
-.PRECIOUS: Makefile
+.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
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/util/mtp-hotplug.c b/util/mtp-hotplug.c
index 8e118ae..a4cec86 100644
--- a/util/mtp-hotplug.c
+++ b/util/mtp-hotplug.c
@@ -29,7 +29,6 @@
 static void usage(void)
 {
   fprintf(stderr, "usage: hotplug [-u -H -i -a\"ACTION\"] -p\"DIR\" -g\"GROUP\" -m\"MODE\"\n");
-  fprintf(stderr, "       -w:  use hwdb syntax\n");
   fprintf(stderr, "       -u:  use udev syntax\n");
   fprintf(stderr, "       -o:  use old udev syntax\n");
   fprintf(stderr, "       -H:  use hal syntax\n");
@@ -46,8 +45,7 @@
   style_udev,
   style_udev_old,
   style_hal,
-  style_usbids,
-  style_hwdb
+  style_usbids
 };
 
 int main (int argc, char **argv)
@@ -75,7 +73,7 @@
   char *udev_group= NULL;
   char *udev_mode = NULL;
 
-  while ( (opt = getopt(argc, argv, "wuoiHa:p:g:m:")) != -1 ) {
+  while ( (opt = getopt(argc, argv, "uoiHa:p:g:m:")) != -1 ) {
     switch (opt) {
     case 'a':
       udev_action = strdup(optarg);
@@ -92,9 +90,6 @@
     case 'i':
       style = style_usbids;
       break;
-    case 'w':
-      style = style_hwdb;
-      break;
     case 'p':
       strncpy(mtp_probe_dir,optarg,sizeof(mtp_probe_dir));
       mtp_probe_dir[sizeof(mtp_probe_dir)-1] = '\0';
@@ -159,8 +154,6 @@
       printf("ATTR{idVendor}==\"0cf3\", GOTO=\"libmtp_rules_end\"\n");
       printf("# Sensitive Atmel JTAG programmers\n");
       printf("ATTR{idVendor}==\"03eb\", GOTO=\"libmtp_rules_end\"\n");
-      printf("# Sensitive Philips device\n");
-      printf("ATTR{idVendor}==\"0471\", ATTR{idProduct}==\"083f\", GOTO=\"libmtp_rules_end\"\n");
       break;
     case style_udev_old:
       printf("# UDEV-style hotplug map for libmtp\n");
@@ -185,9 +178,6 @@
       printf("# usb.ids style device list from libmtp\n");
       printf("# Compare: http://www.linux-usb.org/usb.ids\n");
       break;
-    case style_hwdb:
-      printf("# hardware database file for libmtp supported devices\n");
-      break;
     }
 
     for (i = 0; i < numentries; i++) {
@@ -206,7 +196,7 @@
           printf("# %s %s\n", entry->vendor, entry->product);
           printf("libmtp.sh    0x0003  0x%04x  0x%04x  0x0000  0x0000  0x00    0x00    0x00    0x00    0x00    0x00    0x00000000\n", entry->vendor_id, entry->product_id);
           break;
-      case style_hal:
+        case style_hal:
           printf("      <!-- %s %s -->\n", entry->vendor, entry->product);
           printf("      <match key=\"usb.vendor_id\" int=\"0x%04x\">\n", entry->vendor_id);
           printf("        <match key=\"usb.product_id\" int=\"0x%04x\">\n", entry->product_id);
@@ -241,19 +231,12 @@
           printf("        </match>\n");
           printf("      </match>\n");
         break;
-      case style_usbids:
+        case style_usbids:
           if (last_vendor != entry->vendor_id) {
             printf("%04x\n", entry->vendor_id);
           }
           printf("\t%04x  %s %s\n", entry->product_id, entry->vendor, entry->product);
         break;
-      case style_hwdb:
-          printf("# %s %s\n", entry->vendor, entry->product);
-          printf("usb:v%04xp%04x*\n", entry->vendor_id, entry->product_id);
-          printf(" ID_MEDIA_PLAYER=1\n");
-          printf(" ID_MTP_DEVICE=1\n");
-          printf("\n");
-          break;
       }
       last_vendor = entry->vendor_id;
     }
@@ -265,7 +248,6 @@
   // Then the footer.
   switch (style) {
   case style_usbmap:
-  case style_hwdb:
     break;
   case style_udev:
   case style_udev_old:
diff --git a/util/mtp-probe.c b/util/mtp-probe.c
index 3ff2040..3e52086 100644
--- a/util/mtp-probe.c
+++ b/util/mtp-probe.c
@@ -45,242 +45,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <syslog.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
 #include <libmtp.h>
-#include <regex.h>
-#include <fcntl.h>
-
-enum ep_type {
-  OTHER_EP,
-  BULK_OUT_EP,
-  BULK_IN_EP,
-  INTERRUPT_IN_EP,
-  INTERRUPT_OUT_EP,
-};
-
-static enum ep_type get_ep_type(char *path)
-{
-  char pbuf[FILENAME_MAX];
-  int len = strlen(path);
-  int fd;
-  char buf[128];
-  int bread;
-  int is_out = 0;
-  int is_in = 0;
-  int is_bulk = 0;
-  int is_interrupt = 0;
-  int i;
-
-  strcpy(pbuf, path);
-  pbuf[len++] = '/';
-
-  /* Check the type */
-  strncpy(pbuf + len, "type", FILENAME_MAX - len);
-  pbuf[FILENAME_MAX - 1] = '\0'; /* Sentinel */
-
-  fd = open(pbuf, O_RDONLY);
-  if (fd < 0)
-    return OTHER_EP;
-  bread = read(fd, buf, sizeof(buf));
-  close(fd);
-  if (bread < 2)
-    return OTHER_EP;
-
-  for (i = 0; i < bread; i++)
-    if(buf[i] == 0x0d || buf[i] == 0x0a)
-      buf[i] = '\0';
-
-  if (!strcmp(buf, "Bulk"))
-    is_bulk = 1;
-  if (!strcmp(buf, "Interrupt"))
-    is_interrupt = 1;
-
-  /* Check the direction */
-  strncpy(pbuf + len, "direction", FILENAME_MAX - len);
-  pbuf[FILENAME_MAX - 1] = '\0'; /* Sentinel */
-
-  fd = open(pbuf, O_RDONLY);
-  if (fd < 0)
-    return OTHER_EP;
-  bread = read(fd, buf, sizeof(buf));
-  close(fd);
-  if (bread < 2)
-    return OTHER_EP;
-
-  for (i = 0; i < bread; i++)
-    if(buf[i] == 0x0d || buf[i] == 0x0a)
-      buf[i] = '\0';
-
-  if (!strcmp(buf, "in"))
-    is_in = 1;
-  if (!strcmp(buf, "out"))
-    is_out = 1;
-
-  if (is_bulk && is_in)
-    return BULK_IN_EP;
-  if (is_bulk && is_out)
-    return BULK_OUT_EP;
-  if (is_interrupt && is_in)
-    return INTERRUPT_IN_EP;
-  if (is_interrupt && is_out)
-    return INTERRUPT_OUT_EP;
-
-  return OTHER_EP;
-}
-
-static int has_3_ep(char *path)
-{
-  char pbuf[FILENAME_MAX];
-  int len = strlen(path);
-  int fd;
-  char buf[128];
-  int bread;
-
-  strcpy(pbuf, path);
-  pbuf[len++] = '/';
-  strncpy(pbuf + len, "bNumEndpoints", FILENAME_MAX - len);
-  pbuf[FILENAME_MAX - 1] = '\0'; /* Sentinel */
-
-  fd = open(pbuf, O_RDONLY);
-  if (fd < 0)
-    return -1;
-  /* Read all contents to buffer */
-  bread = read(fd, buf, sizeof(buf));
-  close(fd);
-  if (bread < 2)
-    return 0;
-
-  /* 0x30, 0x33 = "03", maybe we should parse it? */
-  if (buf[0] == 0x30 && buf[1] == 0x33)
-    return 1;
-
-  return 0;
-}
-
-static int check_interface(char *sysfspath)
-{
-  char dirbuf[FILENAME_MAX];
-  int len = strlen(sysfspath);
-  DIR *dir;
-  struct dirent *dent;
-  regex_t r;
-  int ret;
-  int bulk_out_ep_found = 0;
-  int bulk_in_ep_found = 0;
-  int interrupt_in_ep_found = 0;
-
-  ret = has_3_ep(sysfspath);
-  if (ret <= 0)
-    return ret;
-
-  /* Yes it has three endpoints ... look even closer! */
-  dir = opendir(sysfspath);
-  if (!dir)
-    return -1;
-
-  strcpy(dirbuf, sysfspath);
-  dirbuf[len++] = '/';
-
-  /* Check for dirs that identify endpoints */
-  ret = regcomp(&r, "^ep_[0-9a-f]+$", REG_EXTENDED | REG_NOSUB);
-  if (ret) {
-    closedir(dir);
-    return -1;
-  }
-
-  while ((dent = readdir(dir))) {
-    struct stat st;
-
-    /* No need to check those beginning with a period */
-    if (dent->d_name[0] == '.')
-      continue;
-
-    strncpy(dirbuf + len, dent->d_name, FILENAME_MAX - len);
-    dirbuf[FILENAME_MAX - 1] = '\0'; /* Sentinel */
-    ret = lstat(dirbuf, &st);
-    if (ret)
-      continue;
-    if (S_ISDIR(st.st_mode) && !regexec(&r, dent->d_name, 0, 0, 0)) {
-      enum ep_type ept;
-
-      ept = get_ep_type(dirbuf);
-      if (ept == BULK_OUT_EP)
-	bulk_out_ep_found = 1;
-      else if (ept == BULK_IN_EP)
-	bulk_in_ep_found = 1;
-      else if (ept == INTERRUPT_IN_EP)
-	interrupt_in_ep_found = 1;
-    }
-  }
-
-  regfree(&r);
-  closedir(dir);
-
-  /*
-   * If this is fulfilled the interface is an MTP candidate
-   */
-  if (bulk_out_ep_found &&
-      bulk_in_ep_found &&
-      interrupt_in_ep_found) {
-    return 1;
-  }
-
-  return 0;
-}
-
-static int check_sysfs(char *sysfspath)
-{
-  char dirbuf[FILENAME_MAX];
-  int len = strlen(sysfspath);
-  DIR *dir;
-  struct dirent *dent;
-  regex_t r;
-  int ret;
-  int look_closer = 0;
-
-  dir = opendir(sysfspath);
-  if (!dir)
-    return -1;
-
-  strcpy(dirbuf, sysfspath);
-  dirbuf[len++] = '/';
-
-  /* Check for dirs that identify interfaces */
-  ret = regcomp(&r, "^[0-9]+-[0-9]+(\\.[0-9])*\\:[0-9]+\\.[0-9]+$", REG_EXTENDED | REG_NOSUB);
-  if (ret) {
-    closedir(dir);
-    return -1;
-  }
-
-  while ((dent = readdir(dir))) {
-    struct stat st;
-    int ret;
-
-    /* No need to check those beginning with a period */
-    if (dent->d_name[0] == '.')
-      continue;
-
-    strncpy(dirbuf + len, dent->d_name, FILENAME_MAX - len);
-    dirbuf[FILENAME_MAX - 1] = '\0'; /* Sentinel */
-    ret = lstat(dirbuf, &st);
-    if (ret)
-      continue;
-
-    /* Look closer at dirs that may be interfaces */
-    if (S_ISDIR(st.st_mode)) {
-      if (!regexec(&r, dent->d_name, 0, 0, 0))
-      if (check_interface(dirbuf) > 0)
-	/* potential MTP interface! */
-	look_closer = 1;
-    }
-  }
-
-  regfree(&r);
-  closedir(dir);
-  return look_closer;
-}
 
 int main (int argc, char **argv)
 {
@@ -301,14 +66,7 @@
 
   syslog(LOG_INFO, "checking bus %d, device %d: \"%s\"\n", busno, devno, fname);
 
-  ret = check_sysfs(fname);
-  /*
-   * This means that regular directory check either agrees that this may be a
-   * MTP device, or that it doesn't know (failed). In that case, kick the deeper
-   * check inside LIBMTP.
-   */
-  if (ret != 0)
-    ret = LIBMTP_Check_Specific_Device(busno, devno);
+  ret = LIBMTP_Check_Specific_Device(busno, devno);
   if (ret) {
     syslog(LOG_INFO, "bus: %d, device: %d was an MTP device\n", busno, devno);
     printf("1");