[med-svn] [SCM] cufflinks branch, upstream, updated. upstream/1.3.0-1-g0a8ddec

Charles Plessy plessy at debian.org
Thu May 24 03:58:38 UTC 2012


The following commit has been merged in the upstream branch:
commit 0a8ddec0ba083cb5702760ff93e22d489ee917f0
Author: Charles Plessy <plessy at debian.org>
Date:   Wed May 9 09:41:58 2012 +0900

    Imported Upstream version 2.0.0

diff --git a/Makefile.in b/Makefile.in
index bc5d3c8..601225d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -44,7 +44,8 @@ subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/ax_boost_base.m4 \
 	$(top_srcdir)/ax_boost_thread.m4 $(top_srcdir)/ax_bam.m4 \
-	$(top_srcdir)/ax_check_zlib.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/ax_check_zlib.m4 $(top_srcdir)/ax_check_eigen.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -102,7 +103,9 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+EIGEN_CPPFLAGS = @EIGEN_CPPFLAGS@
 EXEEXT = @EXEEXT@
+GREP = @GREP@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -133,8 +136,6 @@ VERSION = @VERSION@
 ZLIB = @ZLIB@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@@ -151,25 +152,32 @@ build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
 datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
 exec_prefix = @exec_prefix@
 host = @host@
 host_alias = @host_alias@
 host_cpu = @host_cpu@
 host_os = @host_os@
 host_vendor = @host_vendor@
+htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
+localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
 pkgpyexecdir = @pkgpyexecdir@
 pkgpythondir = @pkgpythondir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
+psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
 sbindir = @sbindir@
diff --git a/ax_check_eigen.m4 b/ax_check_eigen.m4
new file mode 100644
index 0000000..02234d8
--- /dev/null
+++ b/ax_check_eigen.m4
@@ -0,0 +1,94 @@
+# SYNOPSIS
+#
+#   AX_EIGEN
+#
+# DESCRIPTION
+#
+#   Test for the EIGEN libraries of a particular version (or newer)
+#
+#   If no path to the installed eigen library is given the macro searchs
+#   under /usr, /usr/local, /opt and /opt/local and evaluates the
+#   $EIGEN_ROOT environment variable. 
+#	Adapted from AX_BOOST_BASE
+#
+#   This macro calls:
+#
+#     AC_SUBST(EIGEN_CPPFLAGS) / AC_SUBST(EIGEN_LDFLAGS)
+#
+#   And sets:
+#
+#     HAVE_EIGEN
+#
+# LICENSE
+#
+#   Copyright (c) 2010 Cole Trapnell <cole at cs.umd.edu>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.
+
+AC_DEFUN([AX_EIGEN],
+[
+AC_ARG_WITH([eigen],
+AS_HELP_STRING([--with-eigen@<:@=DIR@:>@], [use EIGEN libraries (default is yes) - it is possible to specify the root directory for EIGEN (optional)]),
+[
+if test "$withval" = "no"; then
+want_eigen="no"
+elif test "$withval" = "yes"; then
+want_eigen="yes"
+ac_eigen_path=""
+else
+want_eigen="yes"
+ac_eigen_path="$withval"
+fi
+],
+[want_eigen="yes"])
+
+if test "x$want_eigen" = "xyes"; then
+AC_MSG_CHECKING(for eigenlib)
+succeeded=no
+
+dnl first we check the system location for eigen libraries
+if test "$ac_eigen_path" != ""; then
+EIGEN_CPPFLAGS="-I$ac_eigen_path/include"
+else
+for ac_eigen_path_tmp in /usr /usr/local /opt /opt/local ; do
+if test -d "$ac_eigen_path_tmp/include/eigen" && test -r "$ac_eigen_path_tmp/include/eigen"; then
+EIGEN_CPPFLAGS="-I$ac_eigen_path_tmp/include"
+break;
+fi
+done
+fi
+
+CPPFLAGS_SAVED="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $EIGEN_CPPFLAGS"
+export EIGEN_CPPFLAGS
+
+AC_LANG_PUSH(C++)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+@%:@include <Eigen/Dense>
+]], [[
+]])],[
+AC_MSG_RESULT(yes)
+succeeded=yes
+found_system=yes
+],[
+])
+AC_LANG_POP([C++])
+
+CPPFLAGS="$CPPFLAGS $EIGEN_CPPFLAGS"
+export CPPFLAGS
+LDFLAGS="$LDFLAGS $EIGEN_LDFLAGS"
+export LDFLAGS
+export EIGEN_CPPFLAGS
+
+if test "$succeeded" == "yes" ; then
+AC_SUBST(EIGEN_CPPFLAGS)
+AC_DEFINE(HAVE_EIGEN,,[define if the EIGEN library is available])
+fi
+
+CPPFLAGS="$CPPFLAGS_SAVED"
+LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+])
diff --git a/config.h.in b/config.h.in
index cf20431..5bbff76 100644
--- a/config.h.in
+++ b/config.h.in
@@ -21,6 +21,9 @@
    */
 #undef HAVE_DECL_SYSCTL
 
+/* define if the EIGEN library is available */
+#undef HAVE_EIGEN
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -99,5 +102,5 @@
 /* Define to `int' if <sys/types.h> does not define. */
 #undef pid_t
 
-/* Define to `unsigned' if <sys/types.h> does not define. */
+/* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
diff --git a/configure b/configure
index 7486fbb..97403bd 100755
--- a/configure
+++ b/configure
@@ -1,27 +1,84 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for cufflinks 1.3.0.
+# Generated by GNU Autoconf 2.63 for cufflinks 2.0.0.
 #
 # Report bugs to <cole at cs.umd.edu>.
 #
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
 ## --------------------- ##
 ## M4sh Initialization.  ##
 ## --------------------- ##
 
-# Be Bourne compatible
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
-  set -o posix
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  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=';'
+  }
 fi
-DUALCASE=1; export DUALCASE # for MKS sh
 
 # Support unset when possible.
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
@@ -31,33 +88,60 @@ else
 fi
 
 
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
 # Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
 PS1='$ '
 PS2='> '
 PS4='+ '
 
 # NLS nuisances.
-for as_var in \
-  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
-  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
-  LC_TELEPHONE LC_TIME
-do
-  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
-    eval $as_var=C; export $as_var
-  else
-    $as_unset $as_var
-  fi
-done
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
 
 # Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
 else
   as_expr=false
 fi
 
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
   as_basename=basename
 else
   as_basename=false
@@ -65,157 +149,391 @@ fi
 
 
 # Name of the executable.
-as_me=`$as_basename "$0" ||
+as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)$' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
-  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\/\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
 
+# CDPATH.
+$as_unset CDPATH
 
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
 
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  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
+if test "x$CONFIG_SHELL" = x; then
+  if (eval ":") 2>/dev/null; then
+  as_have_required=yes
+else
+  as_have_required=no
 fi
 
+  if test $as_have_required = yes &&	 (eval ":
+(as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
 
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
-  # Find who we are.  Look in the path if we contain no path at all
-  # relative or not.
-  case $0 in
-    *[\\/]* ) as_myself=$0 ;;
-    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
 
-       ;;
-  esac
-  # We did not find ourselves, most probably we were run as `sh COMMAND'
-  # in which case we are not to be found in the path.
-  if test "x$as_myself" = x; then
-    as_myself=$0
-  fi
-  if test ! -f "$as_myself"; then
-    { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
-   { (exit 1); exit 1; }; }
-  fi
-  case $CONFIG_SHELL in
-  '')
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=\$LINENO
+  as_lineno_2=\$LINENO
+  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+  :
+else
+  as_candidate_shells=
     as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for as_base in sh bash ksh sh5; do
-	 case $as_dir in
+  case $as_dir in
 	 /*)
-	   if ("$as_dir/$as_base" -c '
+	   for as_base in sh bash ksh sh5; do
+	     as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+	   done;;
+       esac
+done
+IFS=$as_save_IFS
+
+
+      for as_shell in $as_candidate_shells $SHELL; do
+	 # Try only shells that exist, to save several forks.
+	 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		{ ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+  CONFIG_SHELL=$as_shell
+	       as_have_required=yes
+	       if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+  (exit $1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
   as_lineno_1=$LINENO
   as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
   test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
-	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
-	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
-	     CONFIG_SHELL=$as_dir/$as_base
-	     export CONFIG_SHELL
-	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
-	   fi;;
-	 esac
-       done
-done
-;;
-  esac
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+  break
+fi
+
+fi
+
+      done
+
+      if test "x$CONFIG_SHELL" != x; then
+  for as_var in BASH_ENV ENV
+	do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+	done
+	export CONFIG_SHELL
+	exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+    if test $as_have_required = no; then
+  echo This script requires a shell more modern than all the
+      echo shells that I found on your system.  Please install a
+      echo modern shell, or manually run the script under such a
+      echo shell if you do have one.
+      { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+  echo No shell found that supports shell functions.
+  echo Please tell bug-autoconf at gnu.org about your system,
+  echo including any error possibly output before this message.
+  echo This can help us improve future autoconf versions.
+  echo Configuration will now proceed without shell functions.
+}
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
 
   # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
   # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line before each line; the second 'sed' does the real
-  # work.  The second script uses 'N' to pair each line-number line
-  # with the numbered line, and appends trailing '-' during
-  # substitution so that $LINENO is not a special case at line end.
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
   # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
-  sed '=' <$as_myself |
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
     sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
       N
-      s,$,-,
-      : loop
-      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
       t loop
-      s,-$,,
-      s,^['$as_cr_digits']*\n,,
+      s/-\n.*//
     ' >$as_me.lineno &&
-  chmod +x $as_me.lineno ||
-    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
    { (exit 1); exit 1; }; }
 
   # 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 sensible to this).
-  . ./$as_me.lineno
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
   # Exit status is that of the last command.
   exit
 }
 
 
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
-  *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T='	' ;;
-  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
-  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
 
-if expr a : '\(a\)' >/dev/null 2>&1; then
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
 else
   as_expr=false
 fi
 
 rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
-  # We could just check for DJGPP; but this test a) works b) is more generic
-  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
-  if test -f conf$$.exe; then
-    # Don't use ln at all; we don't have any links
-    as_ln_s='cp -p'
-  else
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
     as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
   fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
 else
   as_ln_s='cp -p'
 fi
-rm -f conf$$ conf$$.exe conf$$.file
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
 
 if mkdir -p . 2>/dev/null; then
   as_mkdir_p=:
@@ -224,7 +542,28 @@ else
   as_mkdir_p=false
 fi
 
-as_executable_p="test -f"
+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'"
@@ -233,90 +572,219 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" 	$as_nl"
-
-# CDPATH.
-$as_unset CDPATH
 
+exec 7<&0 </dev/null 6>&1
 
 # Name of the host.
 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
-exec 6>&1
-
 #
 # Initializations.
 #
 ac_default_prefix=/usr/local
+ac_clean_files=
 ac_config_libobj_dir=.
+LIBOBJS=
 cross_compiling=no
 subdirs=
 MFLAGS=
 MAKEFLAGS=
 SHELL=${CONFIG_SHELL-/bin/sh}
 
-# Maximum number of lines to put in a shell here document.
-# This variable seems obsolete.  It should probably be removed, and
-# only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
-
 # Identity of this package.
 PACKAGE_NAME='cufflinks'
 PACKAGE_TARNAME='cufflinks'
-PACKAGE_VERSION='1.3.0'
-PACKAGE_STRING='cufflinks 1.3.0'
+PACKAGE_VERSION='2.0.0'
+PACKAGE_STRING='cufflinks 2.0.0'
 PACKAGE_BUGREPORT='cole at cs.umd.edu'
 
 ac_unique_file="config.h.in"
 # Factoring default headers for most tests.
 ac_includes_default="\
 #include <stdio.h>
-#if HAVE_SYS_TYPES_H
+#ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
-#if HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
 #endif
-#if STDC_HEADERS
+#ifdef STDC_HEADERS
 # include <stdlib.h>
 # include <stddef.h>
 #else
-# if HAVE_STDLIB_H
+# ifdef HAVE_STDLIB_H
 #  include <stdlib.h>
 # endif
 #endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
 #  include <memory.h>
 # endif
 # include <string.h>
 #endif
-#if HAVE_STRINGS_H
+#ifdef HAVE_STRINGS_H
 # include <strings.h>
 #endif
-#if HAVE_INTTYPES_H
+#ifdef HAVE_INTTYPES_H
 # include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-#  include <stdint.h>
-# endif
 #endif
-#if HAVE_UNISTD_H
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar PYTHON CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CC CFLAGS ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB PYTHON_VERSION PYTHON_PREFIX PYTHON_EXEC_PREFIX PYTHON_PLATFORM pythondir pkgpythondir pyexecdir pkgpyexecdir BOOST_CPPFLAGS BOOST_LDFLAGS BAM_CPPFLAGS BAM_LDFLAGS BAM_LIB build build_cpu build_vendor build_os BOOST_THREAD_LIB CPP EGREP ZLIB host host_cpu host_vendor host_os LIBOBJS LTLIBOBJS'
+ac_subst_vars='LTLIBOBJS
+LIBOBJS
+host_os
+host_vendor
+host_cpu
+host
+EIGEN_CPPFLAGS
+ZLIB
+EGREP
+GREP
+CPP
+BOOST_THREAD_LIB
+build_os
+build_vendor
+build_cpu
+build
+BAM_LIB
+BAM_LDFLAGS
+BAM_CPPFLAGS
+BOOST_LDFLAGS
+BOOST_CPPFLAGS
+pkgpyexecdir
+pyexecdir
+pkgpythondir
+pythondir
+PYTHON_PLATFORM
+PYTHON_EXEC_PREFIX
+PYTHON_PREFIX
+PYTHON_VERSION
+RANLIB
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+ac_ct_CC
+CFLAGS
+CC
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CXX
+CPPFLAGS
+LDFLAGS
+CXXFLAGS
+CXX
+PYTHON
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
 ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_dependency_tracking
+with_boost
+with_boost_libdir
+with_bam
+with_bam_libdir
+with_boost_thread
+with_zlib
+with_eigen
+enable_vectorize
+enable_intel64
+enable_debug
+enable_optim
+enable_profiling
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+PYTHON
+CXX
+CXXFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CCC
+CC
+CFLAGS
+CPP'
+
 
 # Initialize some variables set by options.
 ac_init_help=
 ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
 # The variables have the same names as the options, with
 # dashes changed to underlines.
 cache_file=/dev/null
@@ -339,34 +807,48 @@ x_libraries=NONE
 # and all the variables that are supposed to be based on exec_prefix
 # by default will actually change.
 # Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
 bindir='${exec_prefix}/bin'
 sbindir='${exec_prefix}/sbin'
 libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
 
 ac_prev=
+ac_dashdash=
 for ac_option
 do
   # If the previous option needs an argument, assign it.
   if test -n "$ac_prev"; then
-    eval "$ac_prev=\$ac_option"
+    eval $ac_prev=\$ac_option
     ac_prev=
     continue
   fi
 
-  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+  case $ac_option in
+  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)	ac_optarg=yes ;;
+  esac
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
 
-  case $ac_option in
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
 
   -bindir | --bindir | --bindi | --bind | --bin | --bi)
     ac_prev=bindir ;;
@@ -388,33 +870,61 @@ do
   --config-cache | -C)
     cache_file=config.cache ;;
 
-  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+  -datadir | --datadir | --datadi | --datad)
     ac_prev=datadir ;;
-  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
-  | --da=*)
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
     datadir=$ac_optarg ;;
 
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
   -disable-* | --disable-*)
-    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
    { (exit 1); exit 1; }; }
-    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
-    eval "enable_$ac_feature=no" ;;
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
 
   -enable-* | --enable-*)
-    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2
    { (exit 1); exit 1; }; }
-    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
-    case $ac_option in
-      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
-      *) ac_optarg=yes ;;
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
     esac
-    eval "enable_$ac_feature='$ac_optarg'" ;;
+    eval enable_$ac_useropt=\$ac_optarg ;;
 
   -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
   | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
@@ -441,6 +951,12 @@ do
   -host=* | --host=* | --hos=* | --ho=*)
     host_alias=$ac_optarg ;;
 
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
   -includedir | --includedir | --includedi | --included | --include \
   | --includ | --inclu | --incl | --inc)
     ac_prev=includedir ;;
@@ -465,13 +981,16 @@ do
   | --libexe=* | --libex=* | --libe=*)
     libexecdir=$ac_optarg ;;
 
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
   -localstatedir | --localstatedir | --localstatedi | --localstated \
-  | --localstate | --localstat | --localsta | --localst \
-  | --locals | --local | --loca | --loc | --lo)
+  | --localstate | --localstat | --localsta | --localst | --locals)
     ac_prev=localstatedir ;;
   -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
-  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
-  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
     localstatedir=$ac_optarg ;;
 
   -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
@@ -536,6 +1055,16 @@ do
   | --progr-tra=* | --program-tr=* | --program-t=*)
     program_transform_name=$ac_optarg ;;
 
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
@@ -586,26 +1115,38 @@ do
     ac_init_version=: ;;
 
   -with-* | --with-*)
-    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid package name: $ac_package" >&2
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
    { (exit 1); exit 1; }; }
-    ac_package=`echo $ac_package| sed 's/-/_/g'`
-    case $ac_option in
-      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
-      *) ac_optarg=yes ;;
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
     esac
-    eval "with_$ac_package='$ac_optarg'" ;;
+    eval with_$ac_useropt=\$ac_optarg ;;
 
   -without-* | --without-*)
-    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
-    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid package name: $ac_package" >&2
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2
    { (exit 1); exit 1; }; }
-    ac_package=`echo $ac_package | sed 's/-/_/g'`
-    eval "with_$ac_package=no" ;;
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
 
   --x)
     # Obsolete; use --with-x.
@@ -625,7 +1166,7 @@ do
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
     x_libraries=$ac_optarg ;;
 
-  -*) { echo "$as_me: error: unrecognized option: $ac_option
+  -*) { $as_echo "$as_me: error: unrecognized option: $ac_option
 Try \`$0 --help' for more information." >&2
    { (exit 1); exit 1; }; }
     ;;
@@ -634,17 +1175,16 @@ Try \`$0 --help' for more information." >&2
     ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
     # Reject names that are not valid shell variable names.
     expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+      { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2
    { (exit 1); exit 1; }; }
-    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
-    eval "$ac_envvar='$ac_optarg'"
+    eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
 
   *)
     # FIXME: should be removed in autoconf 3.0.
-    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
     expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
     : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
     ;;
 
@@ -653,31 +1193,39 @@ done
 
 if test -n "$ac_prev"; then
   ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  { echo "$as_me: error: missing argument to $ac_option" >&2
+  { $as_echo "$as_me: error: missing argument to $ac_option" >&2
    { (exit 1); exit 1; }; }
 fi
 
-# Be sure to have absolute paths.
-for ac_var in exec_prefix prefix
-do
-  eval ac_val=$`echo $ac_var`
-  case $ac_val in
-    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
-    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
-   { (exit 1); exit 1; }; };;
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
+   { (exit 1); exit 1; }; } ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
-done
+fi
 
-# Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
-	      localstatedir libdir includedir oldincludedir infodir mandir
+# Check all directory arguments for consistency.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir
 do
-  eval ac_val=$`echo $ac_var`
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
   case $ac_val in
-    [\\/$]* | ?:[\\/]* ) ;;
-    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
-   { (exit 1); exit 1; }; };;
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
   esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; }
 done
 
 # There might be people who depend on the old broken behavior: `$host'
@@ -691,7 +1239,7 @@ target=$target_alias
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    $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
@@ -704,87 +1252,77 @@ test -n "$host_alias" && ac_tool_prefix=$host_alias-
 test "$silent" = yes && exec 6>/dev/null
 
 
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  { $as_echo "$as_me: error: working directory cannot be determined" >&2
+   { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  { $as_echo "$as_me: error: pwd does not report name of working directory" >&2
+   { (exit 1); exit 1; }; }
+
+
 # Find the source files, if location was not specified.
 if test -z "$srcdir"; then
   ac_srcdir_defaulted=yes
-  # Try the directory containing this script, then its parent.
-  ac_confdir=`(dirname "$0") 2>/dev/null ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$0" : 'X\(//\)[^/]' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$0" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_myself" : 'X\(//\)[^/]' \| \
+	 X"$as_myself" : 'X\(//\)$' \| \
+	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
   srcdir=$ac_confdir
-  if test ! -r $srcdir/$ac_unique_file; then
+  if test ! -r "$srcdir/$ac_unique_file"; then
     srcdir=..
   fi
 else
   ac_srcdir_defaulted=no
 fi
-if test ! -r $srcdir/$ac_unique_file; then
-  if test "$ac_srcdir_defaulted" = yes; then
-    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
    { (exit 1); exit 1; }; }
-  else
-    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
-   { (exit 1); exit 1; }; }
-  fi
 fi
-(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
-  { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2
    { (exit 1); exit 1; }; }
-srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
-ac_env_build_alias_set=${build_alias+set}
-ac_env_build_alias_value=$build_alias
-ac_cv_env_build_alias_set=${build_alias+set}
-ac_cv_env_build_alias_value=$build_alias
-ac_env_host_alias_set=${host_alias+set}
-ac_env_host_alias_value=$host_alias
-ac_cv_env_host_alias_set=${host_alias+set}
-ac_cv_env_host_alias_value=$host_alias
-ac_env_target_alias_set=${target_alias+set}
-ac_env_target_alias_value=$target_alias
-ac_cv_env_target_alias_set=${target_alias+set}
-ac_cv_env_target_alias_value=$target_alias
-ac_env_PYTHON_set=${PYTHON+set}
-ac_env_PYTHON_value=$PYTHON
-ac_cv_env_PYTHON_set=${PYTHON+set}
-ac_cv_env_PYTHON_value=$PYTHON
-ac_env_CXX_set=${CXX+set}
-ac_env_CXX_value=$CXX
-ac_cv_env_CXX_set=${CXX+set}
-ac_cv_env_CXX_value=$CXX
-ac_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_env_CXXFLAGS_value=$CXXFLAGS
-ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_cv_env_CXXFLAGS_value=$CXXFLAGS
-ac_env_LDFLAGS_set=${LDFLAGS+set}
-ac_env_LDFLAGS_value=$LDFLAGS
-ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
-ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
-ac_env_CC_set=${CC+set}
-ac_env_CC_value=$CC
-ac_cv_env_CC_set=${CC+set}
-ac_cv_env_CC_value=$CC
-ac_env_CFLAGS_set=${CFLAGS+set}
-ac_env_CFLAGS_value=$CFLAGS
-ac_cv_env_CFLAGS_set=${CFLAGS+set}
-ac_cv_env_CFLAGS_value=$CFLAGS
-ac_env_CPP_set=${CPP+set}
-ac_env_CPP_value=$CPP
-ac_cv_env_CPP_set=${CPP+set}
-ac_cv_env_CPP_value=$CPP
-
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
 #
 # Report the --help message.
 #
@@ -792,7 +1330,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures cufflinks 1.3.0 to adapt to many kinds of systems.
+\`configure' configures cufflinks 2.0.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -812,14 +1350,11 @@ Configuration:
   -n, --no-create         do not create output files
       --srcdir=DIR        find the sources in DIR [configure dir or \`..']
 
-_ACEOF
-
-  cat <<_ACEOF
 Installation directories:
   --prefix=PREFIX         install architecture-independent files in PREFIX
-			  [$ac_default_prefix]
+                          [$ac_default_prefix]
   --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-			  [PREFIX]
+                          [PREFIX]
 
 By default, \`make install' will install all the files in
 \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
@@ -829,18 +1364,25 @@ for instance \`--prefix=\$HOME'.
 For better control, use the options below.
 
 Fine tuning of the installation directories:
-  --bindir=DIR           user executables [EPREFIX/bin]
-  --sbindir=DIR          system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR       program executables [EPREFIX/libexec]
-  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
-  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
-  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
-  --libdir=DIR           object code libraries [EPREFIX/lib]
-  --includedir=DIR       C header files [PREFIX/include]
-  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
-  --infodir=DIR          info documentation [PREFIX/info]
-  --mandir=DIR           man documentation [PREFIX/man]
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/cufflinks]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
 _ACEOF
 
   cat <<\_ACEOF
@@ -858,11 +1400,12 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of cufflinks 1.3.0:";;
+     short | recursive ) echo "Configuration of cufflinks 2.0.0:";;
    esac
   cat <<\_ACEOF
 
 Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --disable-dependency-tracking  speeds up one-time build
@@ -877,8 +1420,7 @@ Optional Features:
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --with-boost[=DIR]
-                          use boost (default is yes) - it is possible to
+  --with-boost[=DIR]      use boost (default is yes) - it is possible to
                           specify the root directory for boost (optional)
   --with-boost-libdir=LIB_DIR
                           Force given directory for boost libraries. Note that
@@ -886,7 +1428,7 @@ Optional Packages:
                           this parameter only if default library detection
                           fails and you know exactly where your boost
                           libraries are located.
-  --with-bam[=DIR]  use BAM libraries (default is yes) - it is possible
+  --with-bam[=DIR]        use BAM libraries (default is yes) - it is possible
                           to specify the root directory for BAM (optional)
   --with-bam-libdir=LIB_DIR
                           Force given directory for bam libraries. Note that
@@ -901,6 +1443,9 @@ Optional Packages:
   --with-zlib=DIR root directory path of zlib installation defaults to
                     /usr/local or /usr if not found in /usr/local
   --without-zlib to disable zlib usage completely
+  --with-eigen[=DIR]      use EIGEN libraries (default is yes) - it is
+                          possible to specify the root directory for EIGEN
+                          (optional)
 
 Some influential environment variables:
   PYTHON      python program
@@ -908,8 +1453,9 @@ Some influential environment variables:
   CXXFLAGS    C++ compiler flags
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
               nonstandard directory <lib dir>
-  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
-              headers in a nonstandard directory <include dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
   CC          C compiler command
   CFLAGS      C compiler flags
   CPP         C preprocessor
@@ -919,120 +1465,88 @@ it to find libraries and programs with nonstandard names/locations.
 
 Report bugs to <cole at cs.umd.edu>.
 _ACEOF
+ac_status=$?
 fi
 
 if test "$ac_init_help" = "recursive"; then
   # If there are subdirs, report their specific --help.
-  ac_popdir=`pwd`
   for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
-    test -d $ac_dir || continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
     ac_builddir=.
 
-if test "$ac_dir" != .; then
-  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
-  # A "../" for each directory in $ac_dir_suffix.
-  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
-  ac_dir_suffix= ac_top_builddir=
-fi
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
 
 case $srcdir in
-  .)  # No --srcdir option.  We are building in place.
+  .)  # We are building in place.
     ac_srcdir=.
-    if test -z "$ac_top_builddir"; then
-       ac_top_srcdir=.
-    else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
-    fi ;;
-  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
     ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir ;;
-  *) # Relative path.
-    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
-  case "$ac_dir" in
-  .) ac_abs_builddir=`pwd`;;
-  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
-  *) ac_abs_builddir=`pwd`/"$ac_dir";;
-  esac;;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
 esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
-  case ${ac_top_builddir}. in
-  .) ac_abs_top_builddir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
-  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
-  case $ac_srcdir in
-  .) ac_abs_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
-  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
-  case $ac_top_srcdir in
-  .) ac_abs_top_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
-  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
-  esac;;
-esac
-
-    cd $ac_dir
-    # Check for guested configure; otherwise get Cygnus style configure.
-    if test -f $ac_srcdir/configure.gnu; then
-      echo
-      $SHELL $ac_srcdir/configure.gnu  --help=recursive
-    elif test -f $ac_srcdir/configure; then
-      echo
-      $SHELL $ac_srcdir/configure  --help=recursive
-    elif test -f $ac_srcdir/configure.ac ||
-	   test -f $ac_srcdir/configure.in; then
-      echo
-      $ac_configure --help
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
     else
-      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
-    fi
-    cd $ac_popdir
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
   done
 fi
 
-test -n "$ac_init_help" && exit 0
+test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-cufflinks configure 1.3.0
-generated by GNU Autoconf 2.59
+cufflinks configure 2.0.0
+generated by GNU Autoconf 2.63
 
-Copyright (C) 2003 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
-  exit 0
+  exit
 fi
-exec 5>config.log
-cat >&5 <<_ACEOF
+cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by cufflinks $as_me 1.3.0, which was
-generated by GNU Autoconf 2.59.  Invocation command line was
+It was created by cufflinks $as_me 2.0.0, which was
+generated by GNU Autoconf 2.63.  Invocation command line was
 
   $ $0 $@
 
 _ACEOF
+exec 5>>config.log
 {
 cat <<_ASUNAME
 ## --------- ##
@@ -1051,7 +1565,7 @@ uname -v = `(uname -v) 2>/dev/null || echo unknown`
 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
@@ -1063,8 +1577,9 @@ for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  echo "PATH: $as_dir"
+  $as_echo "PATH: $as_dir"
 done
+IFS=$as_save_IFS
 
 } >&5
 
@@ -1086,7 +1601,6 @@ _ACEOF
 ac_configure_args=
 ac_configure_args0=
 ac_configure_args1=
-ac_sep=
 ac_must_keep_next=false
 for ac_pass in 1 2
 do
@@ -1097,8 +1611,8 @@ do
     -q | -quiet | --quiet | --quie | --qui | --qu | --q \
     | -silent | --silent | --silen | --sile | --sil)
       continue ;;
-    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
-      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     case $ac_pass in
     1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
@@ -1119,9 +1633,7 @@ do
 	  -* ) ac_must_keep_next=true ;;
 	esac
       fi
-      ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
-      # Get rid of the leading space.
-      ac_sep=" "
+      ac_configure_args="$ac_configure_args '$ac_arg'"
       ;;
     esac
   done
@@ -1132,8 +1644,8 @@ $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_
 # When interrupted or exit'd, cleanup temporary files, and complete
 # config.log.  We remove comments because anyway the quotes in there
 # would cause problems or look ugly.
-# WARNING: Be sure not to use single quotes in there, as some shells,
-# such as our DU 5.0 friend, will then `close' the trap.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
 trap 'exit_status=$?
   # Save into config.log some information that might help in debugging.
   {
@@ -1146,20 +1658,35 @@ trap 'exit_status=$?
 _ASBOX
     echo
     # The following way of writing the cache mishandles newlines in values,
-{
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
   (set) 2>&1 |
-    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
-    *ac_space=\ *)
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
       sed -n \
-	"s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
-      ;;
+	"s/'\''/'\''\\\\'\'''\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
     *)
-      sed -n \
-	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
       ;;
-    esac;
-}
+    esac |
+    sort
+)
     echo
 
     cat <<\_ASBOX
@@ -1170,22 +1697,28 @@ _ASBOX
     echo
     for ac_var in $ac_subst_vars
     do
-      eval ac_val=$`echo $ac_var`
-      echo "$ac_var='"'"'$ac_val'"'"'"
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
     done | sort
     echo
 
     if test -n "$ac_subst_files"; then
       cat <<\_ASBOX
-## ------------- ##
-## Output files. ##
-## ------------- ##
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
 _ASBOX
       echo
       for ac_var in $ac_subst_files
       do
-	eval ac_val=$`echo $ac_var`
-	echo "$ac_var='"'"'$ac_val'"'"'"
+	eval ac_val=\$$ac_var
+	case $ac_val in
+	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	esac
+	$as_echo "$ac_var='\''$ac_val'\''"
       done | sort
       echo
     fi
@@ -1197,26 +1730,24 @@ _ASBOX
 ## ----------- ##
 _ASBOX
       echo
-      sed "/^$/d" confdefs.h | sort
+      cat confdefs.h
       echo
     fi
     test "$ac_signal" != 0 &&
-      echo "$as_me: caught signal $ac_signal"
-    echo "$as_me: exit $exit_status"
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
   } >&5
-  rm -f core *.core &&
-  rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
     exit $exit_status
-     ' 0
+' 0
 for ac_signal in 1 2 13 15; do
   trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
 done
 ac_signal=0
 
 # confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo >confdefs.h
+rm -f -r conftest* confdefs.h
 
 # Predefined preprocessor variables.
 
@@ -1246,18 +1777,24 @@ _ACEOF
 
 
 # Let the site file select an alternate cache file if it wants to.
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
-  if test "x$prefix" != xNONE; then
-    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
-  else
-    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
-  fi
-fi
-for ac_site_file in $CONFIG_SITE; do
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
   if test -r "$ac_site_file"; then
-    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
+    { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
     sed 's/^/| /' "$ac_site_file" >&5
     . "$ac_site_file"
   fi
@@ -1267,54 +1804,61 @@ if test -r "$cache_file"; then
   # Some versions of bash will fail to source /dev/null (special
   # files actually), so we avoid doing that.
   if test -f "$cache_file"; then
-    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
+    { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
-      [\\/]* | ?:[\\/]* ) . $cache_file;;
-      *)                      . ./$cache_file;;
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
     esac
   fi
 else
-  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
+  { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
 
 # Check that the precious variables saved in the cache have kept the same
 # value.
 ac_cache_corrupted=false
-for ac_var in `(set) 2>&1 |
-	       sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+for ac_var in $ac_precious_vars; do
   eval ac_old_set=\$ac_cv_env_${ac_var}_set
   eval ac_new_set=\$ac_env_${ac_var}_set
-  eval ac_old_val="\$ac_cv_env_${ac_var}_value"
-  eval ac_new_val="\$ac_env_${ac_var}_value"
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
   case $ac_old_set,$ac_new_set in
     set,)
-      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
-	{ echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-	{ echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
-echo "$as_me:   former value:  $ac_old_val" >&2;}
-	{ echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
-echo "$as_me:   current value: $ac_new_val" >&2;}
-	ac_cache_corrupted=:
+	# differences in whitespace do not lead to failure.
+	ac_old_val_w=`echo x $ac_old_val`
+	ac_new_val_w=`echo x $ac_new_val`
+	if test "$ac_old_val_w" != "$ac_new_val_w"; then
+	  { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	  ac_cache_corrupted=:
+	else
+	  { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+	  eval $ac_var=\$ac_old_val
+	fi
+	{ $as_echo "$as_me:$LINENO:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+	{ $as_echo "$as_me:$LINENO:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
       fi;;
   esac
   # Pass precious variables to config.status.
   if test "$ac_new_set" = set; then
     case $ac_new_val in
-    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
-      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
     *) ac_arg=$ac_var=$ac_new_val ;;
     esac
     case " $ac_configure_args " in
@@ -1324,19 +1868,15 @@ echo "$as_me:   current value: $ac_new_val" >&2;}
   fi
 done
 if $ac_cache_corrupted; then
-  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+  { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
    { (exit 1); exit 1; }; }
 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
-
 
 
 
@@ -1361,41 +1901,52 @@ 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
 
 
 
 cat >>confdefs.h <<\_ACEOF
-#define SVN_REVISION "3022"
+#define SVN_REVISION "3365"
 _ACEOF
 
 
 
-          ac_config_headers="$ac_config_headers config.h"
+ac_config_headers="$ac_config_headers config.h"
 
 ac_aux_dir=
-for ac_dir in build-aux $srcdir/build-aux; do
-  if test -f $ac_dir/install-sh; then
+for ac_dir in build-aux "$srcdir"/build-aux; do
+  if test -f "$ac_dir/install-sh"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install-sh -c"
     break
-  elif test -f $ac_dir/install.sh; then
+  elif test -f "$ac_dir/install.sh"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install.sh -c"
     break
-  elif test -f $ac_dir/shtool; then
+  elif test -f "$ac_dir/shtool"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/shtool install -c"
     break
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in build-aux $srcdir/build-aux" >&5
-echo "$as_me: error: cannot find install-sh or install.sh in build-aux $srcdir/build-aux" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in build-aux \"$srcdir\"/build-aux" >&5
+$as_echo "$as_me: error: cannot find install-sh or install.sh in build-aux \"$srcdir\"/build-aux" >&2;}
    { (exit 1); exit 1; }; }
 fi
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"
-ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
 
 am__api_version="1.9"
 # Find a good install program.  We prefer a C program (faster),
@@ -1411,11 +1962,12 @@ am__api_version="1.9"
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # OS/2's system install, which has a completely different semantic
 # ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
-echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
 if test -z "$INSTALL"; then
 if test "${ac_cv_path_install+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -1434,7 +1986,7 @@ case $as_dir/ in
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-	if $as_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.
@@ -1444,30 +1996,43 @@ case $as_dir/ in
 	    # program-specific install script used by HP pwplus--don't use.
 	    :
 	  else
-	    ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
-	    break 3
+	    rm -rf conftest.one conftest.two conftest.dir
+	    echo one > conftest.one
+	    echo two > conftest.two
+	    mkdir conftest.dir
+	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+	      test -s conftest.one && test -s conftest.two &&
+	      test -s conftest.dir/conftest.one &&
+	      test -s conftest.dir/conftest.two
+	    then
+	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+	      break 3
+	    fi
 	  fi
 	fi
       done
     done
     ;;
 esac
+
 done
+IFS=$as_save_IFS
 
+rm -rf conftest.one conftest.two conftest.dir
 
 fi
   if test "${ac_cv_path_install+set}" = set; then
     INSTALL=$ac_cv_path_install
   else
-    # As a last resort, use the slow shell script.  We don't cache a
-    # path for INSTALL within a source directory, because that will
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
     # break other packages using the cache if that directory is
-    # removed, or if the path is relative.
+    # removed, or if the value is a relative name.
     INSTALL=$ac_install_sh
   fi
 fi
-echo "$as_me:$LINENO: result: $INSTALL" >&5
-echo "${ECHO_T}$INSTALL" >&6
+{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
 # It thinks the first close brace ends the variable substitution.
@@ -1477,8 +2042,8 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
 
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
-echo "$as_me:$LINENO: checking whether build environment is sane" >&5
-echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
+{ $as_echo "$as_me:$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
@@ -1501,9 +2066,9 @@ if (
       # 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".
-      { { echo "$as_me:$LINENO: error: ls -t appears to fail.  Make sure there is not a broken
+      { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail.  Make sure there is not a broken
 alias in your environment" >&5
-echo "$as_me: error: ls -t appears to fail.  Make sure there is not a broken
+$as_echo "$as_me: error: ls -t appears to fail.  Make sure there is not a broken
 alias in your environment" >&2;}
    { (exit 1); exit 1; }; }
    fi
@@ -1514,26 +2079,23 @@ then
    # Ok.
    :
 else
-   { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
+   { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files!
 Check your system clock" >&5
-echo "$as_me: error: newly created file is older than distributed files!
+$as_echo "$as_me: error: newly created file is older than distributed files!
 Check your system clock" >&2;}
    { (exit 1); exit 1; }; }
 fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
 test "$program_prefix" != NONE &&
-  program_transform_name="s,^,$program_prefix,;$program_transform_name"
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
 # Use a double $ so make ignores it.
 test "$program_suffix" != NONE &&
-  program_transform_name="s,\$,$program_suffix,;$program_transform_name"
-# Double any \ or $.  echo might interpret backslashes.
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
 # By default was `s,x,x', remove it if useless.
-cat <<\_ACEOF >conftest.sed
-s/[\\$]/&&/g;s/;s,x,x,$//
-_ACEOF
-program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
-rm conftest.sed
+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`
@@ -1544,8 +2106,8 @@ if eval "$MISSING --run true"; then
   am_missing_run="$MISSING --run "
 else
   am_missing_run=
-  { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
-echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+  { $as_echo "$as_me:$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 mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
@@ -1585,10 +2147,10 @@ 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.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_AWK+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$AWK"; then
   ac_cv_prog_AWK="$AWK" # Let the user override the test.
@@ -1599,54 +2161,58 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 AWK=$ac_cv_prog_AWK
 if test -n "$AWK"; then
-  echo "$as_me:$LINENO: result: $AWK" >&5
-echo "${ECHO_T}$AWK" >&6
+  { $as_echo "$as_me:$LINENO: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
   test -n "$AWK" && break
 done
 
-echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
 all:
-	@echo 'ac_maketemp="$(MAKE)"'
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
 _ACEOF
 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
-if test -n "$ac_maketemp"; then
-  eval ac_cv_prog_make_${ac_make}_set=yes
-else
-  eval ac_cv_prog_make_${ac_make}_set=no
-fi
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
 rm -f conftest.make
 fi
-if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
   SET_MAKE=
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
@@ -1662,8 +2228,8 @@ rmdir .tst 2>/dev/null
 # test to see if srcdir already configured
 if test "`cd $srcdir && pwd`" != "`pwd`" &&
    test -f $srcdir/config.status; then
-  { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
-echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
@@ -1679,7 +2245,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='cufflinks'
- VERSION='1.3.0'
+ VERSION='2.0.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -1717,10 +2283,10 @@ 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.
 set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_STRIP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$STRIP"; then
   ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
@@ -1731,34 +2297,36 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 STRIP=$ac_cv_prog_STRIP
 if test -n "$STRIP"; then
-  echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
+  { $as_echo "$as_me:$LINENO: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
 fi
 if test -z "$ac_cv_prog_STRIP"; then
   ac_ct_STRIP=$STRIP
   # Extract the first word of "strip", so it can be a program name with args.
 set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_STRIP"; then
   ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
@@ -1769,27 +2337,37 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
-  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
 fi
 fi
 ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
 if test -n "$ac_ct_STRIP"; then
-  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-  STRIP=$ac_ct_STRIP
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
 else
   STRIP="$ac_cv_prog_STRIP"
 fi
@@ -1830,10 +2408,10 @@ 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.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_AWK+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$AWK"; then
   ac_cv_prog_AWK="$AWK" # Let the user override the test.
@@ -1844,42 +2422,48 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 AWK=$ac_cv_prog_AWK
 if test -n "$AWK"; then
-  echo "$as_me:$LINENO: result: $AWK" >&5
-echo "${ECHO_T}$AWK" >&6
+  { $as_echo "$as_me:$LINENO: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
   test -n "$AWK" && break
 done
 
-ac_ext=cc
+ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_CXX+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CXX"; then
   ac_cv_prog_CXX="$CXX" # Let the user override the test.
@@ -1890,38 +2474,40 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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_CXX="$ac_tool_prefix$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 CXX=$ac_cv_prog_CXX
 if test -n "$CXX"; then
-  echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
+  { $as_echo "$as_me:$LINENO: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
     test -n "$CXX" && break
   done
 fi
 if test -z "$CXX"; then
   ac_ct_CXX=$CXX
-  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CXX"; then
   ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
@@ -1932,51 +2518,81 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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_CXX="$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
 if test -n "$ac_ct_CXX"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
   test -n "$ac_ct_CXX" && break
 done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
 
-  CXX=$ac_ct_CXX
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
 fi
 
-
+  fi
+fi
 # Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
-     "checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
-  (eval $ac_compiler --version </dev/null >&5) 2>&5
+$as_echo "$as_me:$LINENO: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
-  (eval $ac_compiler -v </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
-  (eval $ac_compiler -V </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
 
 cat >conftest.$ac_ext <<_ACEOF
@@ -1995,111 +2611,150 @@ main ()
 }
 _ACEOF
 ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5
-echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" >&6
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
-  (eval $ac_link_default) 2>&5
+{ $as_echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5
+$as_echo_n "checking for C++ compiler default output file name... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link_default") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  # Find the output, starting from the most likely.  This scheme is
-# not robust to junk in `.', hence go to wildcards (a.*) only as a last
-# resort.
-
-# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
-# b.out is created by i960 compilers.
-for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
 do
   test -f "$ac_file" || continue
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
-	;;
-    conftest.$ac_ext )
-	# This is the source file.
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
 	;;
     [ab].out )
 	# We found the default executable, but exeext='' is most
 	# certainly right.
 	break;;
     *.* )
-	ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	# FIXME: I believe we export ac_cv_exeext for Libtool,
-	# but it would be cool to find out if it's true.  Does anybody
-	# maintain Libtool? --akim.
-	export ac_cv_exeext
+        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
 	break;;
     * )
 	break;;
   esac
 done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
 else
-  echo "$as_me: failed program was:" >&5
+  ac_file=''
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+if test -z "$ac_file"; then
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { echo "$as_me:$LINENO: error: C++ compiler cannot create executables
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C++ compiler cannot create executables
 See \`config.log' for more details." >&5
-echo "$as_me: error: C++ compiler cannot create executables
+$as_echo "$as_me: error: C++ compiler cannot create executables
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
 fi
 
 ac_exeext=$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6
 
-# Check the compiler produces executables we can run.  If not, either
+# Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5
-echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5
+$as_echo_n "checking whether the C++ compiler works... " >&6; }
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
   if { ac_try='./$ac_file'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { echo "$as_me:$LINENO: error: cannot run C++ compiled programs.
+	{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot run C++ compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C++ compiled programs.
+$as_echo "$as_me: error: cannot run C++ compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
     fi
   fi
 fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
 
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
 ac_clean_files=$ac_clean_files_save
-# Check the compiler produces executables we can run.  If not, either
+# Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6
-
-echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
@@ -2108,32 +2763,33 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
 for ac_file in conftest.exe conftest conftest.*; do
   test -f "$ac_file" || continue
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
     *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	  export ac_cv_exeext
 	  break;;
     * ) break;;
   esac
 done
 else
-  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
 See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 rm -f conftest$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
 if test "${ac_cv_objext+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -2151,39 +2807,48 @@ main ()
 }
 _ACEOF
 rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
        break;;
   esac
 done
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
 See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
+$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -2204,50 +2869,54 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_compiler_gnu=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_compiler_gnu=no
+	ac_compiler_gnu=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
-GXX=`test $ac_compiler_gnu = yes && echo yes`
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
+else
+  GXX=
+fi
 ac_test_CXXFLAGS=${CXXFLAGS+set}
 ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
 if test "${ac_cv_prog_cxx_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -2263,159 +2932,136 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_cxx_g=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-for ac_declaration in \
-   '' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat >conftest.$ac_ext <<_ACEOF
+	CXXFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_declaration
-#include <stdlib.h>
+
 int
 main ()
 {
-exit (42);
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   :
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
+	ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_declaration
+
 int
 main ()
 {
-exit (42);
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  break
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cxx_g=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -2423,7 +3069,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 DEPDIR="${am__leading_dot}deps"
 
-          ac_config_commands="$ac_config_commands depfiles"
+ac_config_commands="$ac_config_commands depfiles"
 
 
 am_make=${MAKE-make}
@@ -2433,8 +3079,8 @@ am__doit:
 .PHONY: am__doit
 END
 # If we don't find an include directive, just comment out the code.
-echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
-echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
 am__include="#"
 am__quote=
 _am_result=none
@@ -2461,15 +3107,15 @@ if test "$am__include" = "#"; then
 fi
 
 
-echo "$as_me:$LINENO: result: $_am_result" >&5
-echo "${ECHO_T}$_am_result" >&6
+{ $as_echo "$as_me:$LINENO: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
 rm -f confinc confmf
 
-# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given.
+# Check whether --enable-dependency-tracking was given.
 if test "${enable_dependency_tracking+set}" = set; then
-  enableval="$enable_dependency_tracking"
+  enableval=$enable_dependency_tracking;
+fi
 
-fi;
 if test "x$enable_dependency_tracking" != xno; then
   am_depcomp="$ac_aux_dir/depcomp"
   AMDEPBACKSLASH='\'
@@ -2489,10 +3135,10 @@ fi
 
 depcc="$CXX"  am_compiler_list=
 
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
 if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
   # We make a subdir and do the tests there.  Otherwise we can end up
@@ -2579,8 +3225,8 @@ else
 fi
 
 fi
-echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
 CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
 
 
@@ -2604,10 +3250,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2618,34 +3264,36 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
 fi
 if test -z "$ac_cv_prog_CC"; then
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
@@ -2656,38 +3304,49 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-  CC=$ac_ct_CC
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
 else
   CC="$ac_cv_prog_CC"
 fi
 
 if test -z "$CC"; then
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2698,76 +3357,36 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-  CC=$ac_ct_CC
-else
-  CC="$ac_cv_prog_CC"
-fi
 
+  fi
 fi
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2779,17 +3398,18 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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
      fi
     ac_cv_prog_CC="cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 if test $ac_prog_rejected = yes; then
   # We found a bogon in the path, so make sure we never use it.
@@ -2807,24 +3427,25 @@ fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
 fi
 if test -z "$CC"; then
   if test -n "$ac_tool_prefix"; then
-  for ac_prog in cl
+  for ac_prog in cl.exe
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
@@ -2835,38 +3456,40 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+  { $as_echo "$as_me:$LINENO: result: $CC" >&5
+$as_echo "$CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
     test -n "$CC" && break
   done
 fi
 if test -z "$CC"; then
   ac_ct_CC=$CC
-  for ac_prog in cl
+  for ac_prog in cl.exe
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
   ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
@@ -2877,64 +3500,96 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
   test -n "$ac_ct_CC" && break
 done
 
-  CC=$ac_ct_CC
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
 fi
 
 fi
 
 
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
 See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
+$as_echo "$as_me: error: no acceptable C compiler found in \$PATH
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 
 # Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
-     "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
-  (eval $ac_compiler --version </dev/null >&5) 2>&5
+$as_echo "$as_me:$LINENO: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
-  (eval $ac_compiler -v </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
-  (eval $ac_compiler -V </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
 
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
 if test "${ac_cv_c_compiler_gnu+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -2955,50 +3610,54 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_compiler_gnu=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_compiler_gnu=no
+	ac_compiler_gnu=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
 if test "${ac_cv_prog_cc_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -3014,59 +3673,142 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_prog_cc_g=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
-  else
-    CFLAGS="-g"
-  fi
-else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
-  else
-    CFLAGS=
+	CFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_g=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
   fi
 fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+  $as_echo_n "(cached) " >&6
 else
-  ac_cv_prog_cc_stdc=no
+  ac_cv_prog_cc_c89=no
 ac_save_CC=$CC
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -3100,12 +3842,17 @@ static char *f (char * (*g) (char **, int), char **p, ...)
 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
    function prototypes and stuff, but not '\xHH' hex character constants.
    These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std1 is added to get
+   as 'x'.  The following induces an error, until -std is added to get
    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
    array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std1.  */
+   that's true only with -std.  */
 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
 
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
 int test (int i, double x);
 struct s1 {int (*f) (int a);};
 struct s2 {int (*f) (double a);};
@@ -3120,205 +3867,58 @@ return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
   return 0;
 }
 _ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX			-qlanglvl=ansi
-# Ultrix and OSF/1	-std1
-# HP-UX 10.20 and later	-Ae
-# HP-UX older versions	-Aa -D_HPUX_SOURCE
-# SVR4			-Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
   rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_cc_stdc=$ac_arg
-break
-else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_prog_cc_c89=$ac_arg
+else
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+
 fi
-rm -f conftest.err conftest.$ac_objext
+
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
 done
-rm -f conftest.$ac_ext conftest.$ac_objext
+rm -f conftest.$ac_ext
 CC=$ac_save_CC
 
 fi
-
-case "x$ac_cv_prog_cc_stdc" in
-  x|xno)
-    echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:$LINENO: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:$LINENO: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
   *)
-    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
-    CC="$CC $ac_cv_prog_cc_stdc" ;;
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
 esac
 
-# Some people use a C++ compiler to compile C.  Since we use `exit',
-# in C++ we need to declare it.  In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
-  choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  for ac_declaration in \
-   '' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
-fi
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3327,10 +3927,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 depcc="$CC"   am_compiler_list=
 
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
 if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
   # We make a subdir and do the tests there.  Otherwise we can end up
@@ -3417,8 +4017,8 @@ else
 fi
 
 fi
-echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
 CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
 
 
@@ -3434,42 +4034,44 @@ else
 fi
 
 
-echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
 all:
-	@echo 'ac_maketemp="$(MAKE)"'
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
 _ACEOF
 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
-if test -n "$ac_maketemp"; then
-  eval ac_cv_prog_make_${ac_make}_set=yes
-else
-  eval ac_cv_prog_make_${ac_make}_set=no
-fi
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
 rm -f conftest.make
 fi
-if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
   SET_MAKE=
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
   SET_MAKE="MAKE=${MAKE-make}"
 fi
 
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
@@ -3480,34 +4082,36 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 RANLIB=$ac_cv_prog_RANLIB
 if test -n "$RANLIB"; then
-  echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
+  { $as_echo "$as_me:$LINENO: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
 fi
 if test -z "$ac_cv_prog_RANLIB"; then
   ac_ct_RANLIB=$RANLIB
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_RANLIB"; then
   ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
@@ -3518,27 +4122,37 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
-  test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
 fi
 fi
 ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
 if test -n "$ac_ct_RANLIB"; then
-  echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-  RANLIB=$ac_ct_RANLIB
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
 else
   RANLIB="$ac_cv_prog_RANLIB"
 fi
@@ -3556,11 +4170,12 @@ fi
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # OS/2's system install, which has a completely different semantic
 # ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
-echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
 if test -z "$INSTALL"; then
 if test "${ac_cv_path_install+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -3579,7 +4194,7 @@ case $as_dir/ in
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-	if $as_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.
@@ -3589,30 +4204,43 @@ case $as_dir/ in
 	    # program-specific install script used by HP pwplus--don't use.
 	    :
 	  else
-	    ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
-	    break 3
+	    rm -rf conftest.one conftest.two conftest.dir
+	    echo one > conftest.one
+	    echo two > conftest.two
+	    mkdir conftest.dir
+	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+	      test -s conftest.one && test -s conftest.two &&
+	      test -s conftest.dir/conftest.one &&
+	      test -s conftest.dir/conftest.two
+	    then
+	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+	      break 3
+	    fi
 	  fi
 	fi
       done
     done
     ;;
 esac
+
 done
+IFS=$as_save_IFS
 
+rm -rf conftest.one conftest.two conftest.dir
 
 fi
   if test "${ac_cv_path_install+set}" = set; then
     INSTALL=$ac_cv_path_install
   else
-    # As a last resort, use the slow shell script.  We don't cache a
-    # path for INSTALL within a source directory, because that will
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
     # break other packages using the cache if that directory is
-    # removed, or if the path is relative.
+    # removed, or if the value is a relative name.
     INSTALL=$ac_install_sh
   fi
 fi
-echo "$as_me:$LINENO: result: $INSTALL" >&5
-echo "${ECHO_T}$INSTALL" >&6
+{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
 # It thinks the first close brace ends the variable substitution.
@@ -3628,8 +4256,8 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
         if test -n "$PYTHON"; then
       # If the user set $PYTHON, use it and don't search something else.
-      echo "$as_me:$LINENO: checking whether $PYTHON version >= 2.4" >&5
-echo $ECHO_N "checking whether $PYTHON version >= 2.4... $ECHO_C" >&6
+      { $as_echo "$as_me:$LINENO: checking whether $PYTHON version >= 2.4" >&5
+$as_echo_n "checking whether $PYTHON version >= 2.4... " >&6; }
       prog="import sys, string
 # split strings by '.' and convert to numeric.  Append some zeros
 # because we need at least 4 digits for the hex conversion.
@@ -3642,11 +4270,11 @@ sys.exit(sys.hexversion < minverhex)"
    ac_status=$?
    echo "$as_me:$LINENO: \$? = $ac_status" >&5
    (exit $ac_status); }; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
 else
-  { { echo "$as_me:$LINENO: error: too old" >&5
-echo "$as_me: error: too old" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: too old" >&5
+$as_echo "$as_me: error: too old" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
@@ -3654,10 +4282,10 @@ fi
     else
       # Otherwise, try each interpreter until we find one that satisfies
       # VERSION.
-      echo "$as_me:$LINENO: checking for a Python interpreter with version >= 2.4" >&5
-echo $ECHO_N "checking for a Python interpreter with version >= 2.4... $ECHO_C" >&6
+      { $as_echo "$as_me:$LINENO: checking for a Python interpreter with version >= 2.4" >&5
+$as_echo_n "checking for a Python interpreter with version >= 2.4... " >&6; }
 if test "${am_cv_pathless_PYTHON+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
 
 	for am_cv_pathless_PYTHON in python python2 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 none; do
@@ -3679,18 +4307,18 @@ fi
 
 	done
 fi
-echo "$as_me:$LINENO: result: $am_cv_pathless_PYTHON" >&5
-echo "${ECHO_T}$am_cv_pathless_PYTHON" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_pathless_PYTHON" >&5
+$as_echo "$am_cv_pathless_PYTHON" >&6; }
       # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
       if test "$am_cv_pathless_PYTHON" = none; then
 	PYTHON=:
       else
         # Extract the first word of "$am_cv_pathless_PYTHON", so it can be a program name with args.
 set dummy $am_cv_pathless_PYTHON; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_path_PYTHON+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   case $PYTHON in
   [\\/]* | ?:[\\/]*)
@@ -3703,48 +4331,49 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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_PYTHON="$as_dir/$ac_word$ac_exec_ext"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 PYTHON=$ac_cv_path_PYTHON
-
 if test -n "$PYTHON"; then
-  echo "$as_me:$LINENO: result: $PYTHON" >&5
-echo "${ECHO_T}$PYTHON" >&6
+  { $as_echo "$as_me:$LINENO: result: $PYTHON" >&5
+$as_echo "$PYTHON" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
       fi
       am_display_PYTHON=$am_cv_pathless_PYTHON
     fi
 
 
   if test "$PYTHON" = :; then
-      { { echo "$as_me:$LINENO: error: no suitable Python interpreter found" >&5
-echo "$as_me: error: no suitable Python interpreter found" >&2;}
+      { { $as_echo "$as_me:$LINENO: error: no suitable Python interpreter found" >&5
+$as_echo "$as_me: error: no suitable Python interpreter found" >&2;}
    { (exit 1); exit 1; }; }
   else
 
 
-  echo "$as_me:$LINENO: checking for $am_display_PYTHON version" >&5
-echo $ECHO_N "checking for $am_display_PYTHON version... $ECHO_C" >&6
+  { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON version" >&5
+$as_echo_n "checking for $am_display_PYTHON version... " >&6; }
 if test "${am_cv_python_version+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   am_cv_python_version=`$PYTHON -c "import sys; print sys.version[:3]"`
 fi
-echo "$as_me:$LINENO: result: $am_cv_python_version" >&5
-echo "${ECHO_T}$am_cv_python_version" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_python_version" >&5
+$as_echo "$am_cv_python_version" >&6; }
   PYTHON_VERSION=$am_cv_python_version
 
 
@@ -3755,30 +4384,30 @@ echo "${ECHO_T}$am_cv_python_version" >&6
 
 
 
-  echo "$as_me:$LINENO: checking for $am_display_PYTHON platform" >&5
-echo $ECHO_N "checking for $am_display_PYTHON platform... $ECHO_C" >&6
+  { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON platform" >&5
+$as_echo_n "checking for $am_display_PYTHON platform... " >&6; }
 if test "${am_cv_python_platform+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`
 fi
-echo "$as_me:$LINENO: result: $am_cv_python_platform" >&5
-echo "${ECHO_T}$am_cv_python_platform" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_python_platform" >&5
+$as_echo "$am_cv_python_platform" >&6; }
   PYTHON_PLATFORM=$am_cv_python_platform
 
 
 
 
-                echo "$as_me:$LINENO: checking for $am_display_PYTHON script directory" >&5
-echo $ECHO_N "checking for $am_display_PYTHON script directory... $ECHO_C" >&6
+                { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON script directory" >&5
+$as_echo_n "checking for $am_display_PYTHON script directory... " >&6; }
 if test "${am_cv_python_pythondir+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
      echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
 fi
-echo "$as_me:$LINENO: result: $am_cv_python_pythondir" >&5
-echo "${ECHO_T}$am_cv_python_pythondir" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_python_pythondir" >&5
+$as_echo "$am_cv_python_pythondir" >&6; }
   pythondir=$am_cv_python_pythondir
 
 
@@ -3786,16 +4415,16 @@ echo "${ECHO_T}$am_cv_python_pythondir" >&6
   pkgpythondir=\${pythondir}/$PACKAGE
 
 
-            echo "$as_me:$LINENO: checking for $am_display_PYTHON extension module directory" >&5
-echo $ECHO_N "checking for $am_display_PYTHON extension module directory... $ECHO_C" >&6
+            { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON extension module directory" >&5
+$as_echo_n "checking for $am_display_PYTHON extension module directory... " >&6; }
 if test "${am_cv_python_pyexecdir+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
      echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`
 fi
-echo "$as_me:$LINENO: result: $am_cv_python_pyexecdir" >&5
-echo "${ECHO_T}$am_cv_python_pyexecdir" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_python_pyexecdir" >&5
+$as_echo "$am_cv_python_pyexecdir" >&6; }
   pyexecdir=$am_cv_python_pyexecdir
 
 
@@ -3810,10 +4439,9 @@ echo "${ECHO_T}$am_cv_python_pyexecdir" >&6
 
 
 
-# Check whether --with-boost or --without-boost was given.
+# Check whether --with-boost was given.
 if test "${with_boost+set}" = set; then
-  withval="$with_boost"
-
+  withval=$with_boost;
     if test "$withval" = "no"; then
 		want_boost="no"
     elif test "$withval" = "yes"; then
@@ -3826,30 +4454,31 @@ if test "${with_boost+set}" = set; then
 
 else
   want_boost="yes"
-fi;
+fi
 
 
 
-# Check whether --with-boost-libdir or --without-boost-libdir was given.
-if test "${with_boost_libdir+set}" = set; then
-  withval="$with_boost_libdir"
 
+# Check whether --with-boost-libdir was given.
+if test "${with_boost_libdir+set}" = set; then
+  withval=$with_boost_libdir;
         if test -d $withval
         then
                 ac_boost_lib_path="$withval"
         else
-                { { echo "$as_me:$LINENO: error: --with-boost-libdir expected directory name" >&5
-echo "$as_me: error: --with-boost-libdir expected directory name" >&2;}
+                { { $as_echo "$as_me:$LINENO: error: --with-boost-libdir expected directory name" >&5
+$as_echo "$as_me: error: --with-boost-libdir expected directory name" >&2;}
    { (exit 1); exit 1; }; }
         fi
 
 else
   ac_boost_lib_path=""
 
-fi;
+fi
+
 
 if test "x$want_boost" = "xyes"; then
-	boost_lib_version_req=1.38.0
+	boost_lib_version_req=1.47.0
 	boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([0-9]*\.[0-9]*\)'`
 	boost_lib_version_req_major=`expr $boost_lib_version_req : '\([0-9]*\)'`
 	boost_lib_version_req_minor=`expr $boost_lib_version_req : '[0-9]*\.\([0-9]*\)'`
@@ -3858,8 +4487,8 @@ if test "x$want_boost" = "xyes"; then
 		boost_lib_version_req_sub_minor="0"
     	fi
 	WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
-	echo "$as_me:$LINENO: checking for boostlib >= $boost_lib_version_req" >&5
-echo $ECHO_N "checking for boostlib >= $boost_lib_version_req... $ECHO_C" >&6
+	{ $as_echo "$as_me:$LINENO: checking for boostlib >= $boost_lib_version_req" >&5
+$as_echo_n "checking for boostlib >= $boost_lib_version_req... " >&6; }
 	succeeded=no
 
 				if test "$ac_boost_path" != ""; then
@@ -3887,7 +4516,7 @@ echo $ECHO_N "checking for boostlib >= $boost_lib_version_req... $ECHO_C" >&6
 	LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
 	export LDFLAGS
 
-	ac_ext=cc
+	ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -3917,41 +4546,38 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-        echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+
+        { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
 	succeeded=yes
 	found_system=yes
 
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
 
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 	ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4003,8 +4629,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 			        	stage_version_shorten=`expr $stage_version : '\([0-9]*\.[0-9]*\)'`
 					V_CHECK=`expr $stage_version_shorten \>\= $_version`
                     if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
-						{ echo "$as_me:$LINENO: We will use a staged boost library from $BOOST_ROOT" >&5
-echo "$as_me: We will use a staged boost library from $BOOST_ROOT" >&6;}
+						{ $as_echo "$as_me:$LINENO: We will use a staged boost library from $BOOST_ROOT" >&5
+$as_echo "$as_me: We will use a staged boost library from $BOOST_ROOT" >&6;}
 						BOOST_CPPFLAGS="-I$BOOST_ROOT"
 						BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
 					fi
@@ -4017,7 +4643,7 @@ echo "$as_me: We will use a staged boost library from $BOOST_ROOT" >&6;}
 		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
 		export LDFLAGS
 
-		ac_ext=cc
+		ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -4047,41 +4673,38 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-        	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+
+        	{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
 		succeeded=yes
 		found_system=yes
 
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
 
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 		ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4092,19 +4715,19 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 	if test "$succeeded" != "yes" ; then
 		if test "$_version" = "0" ; then
-			{ { echo "$as_me:$LINENO: error: We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation." >&5
-echo "$as_me: error: We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation." >&2;}
+			{ { $as_echo "$as_me:$LINENO: error: We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation." >&5
+$as_echo "$as_me: error: We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation." >&2;}
    { (exit 1); exit 1; }; }
 		else
-			{ echo "$as_me:$LINENO: Your boost libraries seems to old (version $_version)." >&5
-echo "$as_me: Your boost libraries seems to old (version $_version)." >&6;}
+			{ $as_echo "$as_me:$LINENO: Your boost libraries seems to old (version $_version)." >&5
+$as_echo "$as_me: Your boost libraries seems to old (version $_version)." >&6;}
 		fi
 	else
 
 
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_BOOST
+#define HAVE_BOOST /**/
 _ACEOF
 
 	fi
@@ -4116,10 +4739,9 @@ fi
 
 
 
-# Check whether --with-bam or --without-bam was given.
+# Check whether --with-bam was given.
 if test "${with_bam+set}" = set; then
-  withval="$with_bam"
-
+  withval=$with_bam;
     if test "$withval" = "no"; then
 		want_bam="no"
     elif test "$withval" = "yes"; then
@@ -4132,27 +4754,28 @@ if test "${with_bam+set}" = set; then
 
 else
   want_bam="yes"
-fi;
+fi
 
 
 
-# Check whether --with-bam-libdir or --without-bam-libdir was given.
-if test "${with_bam_libdir+set}" = set; then
-  withval="$with_bam_libdir"
 
+# Check whether --with-bam-libdir was given.
+if test "${with_bam_libdir+set}" = set; then
+  withval=$with_bam_libdir;
         if test -d $withval
         then
                 ac_bam_lib_path="$withval"
         else
-                { { echo "$as_me:$LINENO: error: --with-bam-libdir expected directory name" >&5
-echo "$as_me: error: --with-bam-libdir expected directory name" >&2;}
+                { { $as_echo "$as_me:$LINENO: error: --with-bam-libdir expected directory name" >&5
+$as_echo "$as_me: error: --with-bam-libdir expected directory name" >&2;}
    { (exit 1); exit 1; }; }
         fi
 
 else
   ac_bam_lib_path=""
 
-fi;
+fi
+
 
 if test "x$want_bam" = "xyes"; then
 #	bam_lib_version_req=ifelse([], ,1.20.0,)
@@ -4164,8 +4787,8 @@ if test "x$want_bam" = "xyes"; then
 #		bam_lib_version_req_sub_minor="0"
 #    	fi
 #	WANT_BAM_VERSION=`expr $bam_lib_version_req_major \* 100000 \+  $bam_lib_version_req_minor \* 100 \+ $bam_lib_version_req_sub_minor`
-	echo "$as_me:$LINENO: checking for bamlib" >&5
-echo $ECHO_N "checking for bamlib... $ECHO_C" >&6
+	{ $as_echo "$as_me:$LINENO: checking for bamlib" >&5
+$as_echo_n "checking for bamlib... " >&6; }
 	succeeded=no
 
 		if test "$ac_bam_path" != ""; then
@@ -4193,7 +4816,7 @@ echo $ECHO_N "checking for bamlib... $ECHO_C" >&6
 	LDFLAGS="$LDFLAGS $BAM_LDFLAGS"
 	export LDFLAGS
 
-	ac_ext=cc
+	ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -4218,41 +4841,38 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-        echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+
+        { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
 	succeeded=yes
 	found_system=yes
 
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
 
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 	ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4302,8 +4922,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 			        	stage_version_shorten=`expr $stage_version : '\([0-9]*\.[0-9]*\)'`
 					V_CHECK=`expr $stage_version_shorten \>\= $_version`
                     if test "$V_CHECK" = "1" -a "$ac_bam_lib_path" = "" ; then
-						{ echo "$as_me:$LINENO: We will use a staged bam library from $BAM_ROOT" >&5
-echo "$as_me: We will use a staged bam library from $BAM_ROOT" >&6;}
+						{ $as_echo "$as_me:$LINENO: We will use a staged bam library from $BAM_ROOT" >&5
+$as_echo "$as_me: We will use a staged bam library from $BAM_ROOT" >&6;}
 						BAM_CPPFLAGS="-I$BAM_ROOT"
 						BAM_LDFLAGS="-L$BAM_ROOT/stage/lib"
 					fi
@@ -4316,7 +4936,7 @@ echo "$as_me: We will use a staged bam library from $BAM_ROOT" >&6;}
 		LDFLAGS="$LDFLAGS $BAM_LDFLAGS"
 		export LDFLAGS
 
-		ac_ext=cc
+		ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -4341,41 +4961,38 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-        	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+
+        	{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
 		succeeded=yes
 		found_system=yes
 
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
 
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 		ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4386,12 +5003,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 	if test "$succeeded" != "yes" ; then
 		if test "$_version" = "0" ; then
-			{ { echo "$as_me:$LINENO: error: We could not detect the bam libraries (version $bam_lib_version_req_shorten or higher). If you have a staged bam library (still not installed) please specify \$BAM_ROOT in your environment and do not give a PATH to --with-bam option.  If you are sure you have bam installed, then check your version number looking in <bam/version.hpp>. See http://randspringer.de/bam for more documentation." >&5
-echo "$as_me: error: We could not detect the bam libraries (version $bam_lib_version_req_shorten or higher). If you have a staged bam library (still not installed) please specify \$BAM_ROOT in your environment and do not give a PATH to --with-bam option.  If you are sure you have bam installed, then check your version number looking in <bam/version.hpp>. See http://randspringer.de/bam for more documentation." >&2;}
+			{ { $as_echo "$as_me:$LINENO: error: We could not detect the bam libraries (version $bam_lib_version_req_shorten or higher). If you have a staged bam library (still not installed) please specify \$BAM_ROOT in your environment and do not give a PATH to --with-bam option.  If you are sure you have bam installed, then check your version number looking in <bam/version.hpp>. See http://randspringer.de/bam for more documentation." >&5
+$as_echo "$as_me: error: We could not detect the bam libraries (version $bam_lib_version_req_shorten or higher). If you have a staged bam library (still not installed) please specify \$BAM_ROOT in your environment and do not give a PATH to --with-bam option.  If you are sure you have bam installed, then check your version number looking in <bam/version.hpp>. See http://randspringer.de/bam for more documentation." >&2;}
    { (exit 1); exit 1; }; }
 		else
-			{ echo "$as_me:$LINENO: Your bam libraries seem too old (version $_version)." >&5
-echo "$as_me: Your bam libraries seem too old (version $_version)." >&6;}
+			{ $as_echo "$as_me:$LINENO: Your bam libraries seem too old (version $_version)." >&5
+$as_echo "$as_me: Your bam libraries seem too old (version $_version)." >&6;}
 		fi
 	else
 		BAM_LIB="-lbam"
@@ -4400,7 +5017,7 @@ echo "$as_me: Your bam libraries seem too old (version $_version)." >&6;}
 
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_BAM
+#define HAVE_BAM /**/
 _ACEOF
 
 	fi
@@ -4411,44 +5028,57 @@ fi
 
 
 # Make sure we can run config.sub.
-$ac_config_sub sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
-echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
    { (exit 1); exit 1; }; }
 
-echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
 if test "${ac_cv_build+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_build_alias=$build_alias
-test -z "$ac_cv_build_alias" &&
-  ac_cv_build_alias=`$ac_config_guess`
-test -z "$ac_cv_build_alias" &&
-  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
-echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
    { (exit 1); exit 1; }; }
-ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
-  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+$as_echo "$as_me: error: invalid value of canonical build" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
 build=$ac_cv_build
-build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
 
 
 
 
 
-# Check whether --with-boost-thread or --without-boost-thread was given.
+# Check whether --with-boost-thread was given.
 if test "${with_boost_thread+set}" = set; then
-  withval="$with_boost_thread"
-
+  withval=$with_boost_thread;
         if test "$withval" = "no"; then
 			want_boost="no"
         elif test "$withval" = "yes"; then
@@ -4463,7 +5093,8 @@ if test "${with_boost_thread+set}" = set; then
 else
   want_boost="yes"
 
-fi;
+fi
+
 
 	if test "x$want_boost" = "xyes"; then
 
@@ -4476,12 +5107,12 @@ fi;
 		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
 		export LDFLAGS
 
-        echo "$as_me:$LINENO: checking whether the Boost::Thread library is available" >&5
-echo $ECHO_N "checking whether the Boost::Thread library is available... $ECHO_C" >&6
+        { $as_echo "$as_me:$LINENO: checking whether the Boost::Thread library is available" >&5
+$as_echo_n "checking whether the Boost::Thread library is available... " >&6; }
 if test "${ax_cv_boost_thread+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
-  ac_ext=cc
+  ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -4513,35 +5144,32 @@ boost::thread_group thrds;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ax_cv_boost_thread=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ax_cv_boost_thread=no
+	ax_cv_boost_thread=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 			 CXXFLAGS=$CXXFLAGS_SAVE
              ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -4551,8 +5179,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 fi
-echo "$as_me:$LINENO: result: $ax_cv_boost_thread" >&5
-echo "${ECHO_T}$ax_cv_boost_thread" >&6
+{ $as_echo "$as_me:$LINENO: result: $ax_cv_boost_thread" >&5
+$as_echo "$ax_cv_boost_thread" >&6; }
 		if test "x$ax_cv_boost_thread" = "xyes"; then
            if test "x$build_os" = "xsolaris" ; then
 			  BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS"
@@ -4566,7 +5194,7 @@ echo "${ECHO_T}$ax_cv_boost_thread" >&6
 
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_BOOST_THREAD
+#define HAVE_BOOST_THREAD /**/
 _ACEOF
 
             BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/[^\/]*//'`
@@ -4581,11 +5209,11 @@ _ACEOF
             if test "x$ax_boost_user_thread_lib" = "x"; then
                 for libextension in `ls $BOOSTLIBDIR/libboost_thread*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_thread.*\)\.a*$;\1;'`; do
                      ax_lib=${libextension}
-				    as_ac_Lib=`echo "ac_cv_lib_$ax_lib''_exit" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for exit in -l$ax_lib" >&5
-echo $ECHO_N "checking for exit in -l$ax_lib... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+				    as_ac_Lib=`$as_echo "ac_cv_lib_$ax_lib''_exit" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for exit in -l$ax_lib" >&5
+$as_echo_n "checking for exit in -l$ax_lib... " >&6; }
+if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-l$ax_lib  $LIBS"
@@ -4596,57 +5224,62 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-/* Override any gcc2 internal prototype to avoid an error.  */
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
 char exit ();
 int
 main ()
 {
-exit ();
+return exit ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
   eval "$as_ac_Lib=yes"
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-eval "$as_ac_Lib=no"
+	eval "$as_ac_Lib=no"
 fi
-rm -f conftest.err conftest.$ac_objext \
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+ac_res=`eval 'as_val=${'$as_ac_Lib'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_Lib'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   BOOST_THREAD_LIB="-l$ax_lib";  link_thread="yes"; break
 else
   link_thread="no"
@@ -4656,11 +5289,11 @@ fi
                 if test "x$link_thread" != "xyes"; then
                 for libextension in `ls $BOOSTLIBDIR/boost_thread*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_thread*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_thread.*\)\.a*$;\1;'` ; do
                      ax_lib=${libextension}
-				    as_ac_Lib=`echo "ac_cv_lib_$ax_lib''_exit" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for exit in -l$ax_lib" >&5
-echo $ECHO_N "checking for exit in -l$ax_lib... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+				    as_ac_Lib=`$as_echo "ac_cv_lib_$ax_lib''_exit" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for exit in -l$ax_lib" >&5
+$as_echo_n "checking for exit in -l$ax_lib... " >&6; }
+if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-l$ax_lib  $LIBS"
@@ -4671,57 +5304,62 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-/* Override any gcc2 internal prototype to avoid an error.  */
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
 char exit ();
 int
 main ()
 {
-exit ();
+return exit ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
   eval "$as_ac_Lib=yes"
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-eval "$as_ac_Lib=no"
+	eval "$as_ac_Lib=no"
 fi
-rm -f conftest.err conftest.$ac_objext \
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+ac_res=`eval 'as_val=${'$as_ac_Lib'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_Lib'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   BOOST_THREAD_LIB="-l$ax_lib";  link_thread="yes"; break
 else
   link_thread="no"
@@ -4738,8 +5376,8 @@ fi
 
             fi
 			if test "x$link_thread" = "xno"; then
-				{ { echo "$as_me:$LINENO: error: Could not link against $ax_lib !" >&5
-echo "$as_me: error: Could not link against $ax_lib !" >&2;}
+				{ { $as_echo "$as_me:$LINENO: error: Could not link against $ax_lib !" >&5
+$as_echo "$as_me: error: Could not link against $ax_lib !" >&2;}
    { (exit 1); exit 1; }; }
                         else
                            case "x$build_os" in
@@ -4761,15 +5399,15 @@ 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
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
   if test "${ac_cv_prog_CPP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
       # Double quotes because CPP needs to be expanded
     for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
@@ -4796,35 +5434,35 @@ cat >>conftest.$ac_ext <<_ACEOF
 #endif
 		     Syntax error
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
   :
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
   # Broken: fails on valid input.
 continue
 fi
+
 rm -f conftest.err conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether non-existent headers
+  # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -4834,34 +5472,34 @@ cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
   # Broken: success on invalid input.
 continue
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
   # Passes both tests.
 ac_preproc_ok=:
 break
 fi
+
 rm -f conftest.err conftest.$ac_ext
 
 done
@@ -4879,8 +5517,8 @@ fi
 else
   ac_cv_prog_CPP=$CPP
 fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
+{ $as_echo "$as_me:$LINENO: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
 ac_preproc_ok=false
 for ac_c_preproc_warn_flag in '' yes
 do
@@ -4903,35 +5541,35 @@ cat >>conftest.$ac_ext <<_ACEOF
 #endif
 		     Syntax error
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
   :
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
   # Broken: fails on valid input.
 continue
 fi
+
 rm -f conftest.err conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether non-existent headers
+  # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -4941,34 +5579,34 @@ cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
   # Broken: success on invalid input.
 continue
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
   # Passes both tests.
 ac_preproc_ok=:
 break
 fi
+
 rm -f conftest.err conftest.$ac_ext
 
 done
@@ -4977,11 +5615,13 @@ rm -f conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
 See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 ac_ext=c
@@ -4991,25 +5631,144 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
+  $as_echo_n "(cached) " >&6
 else
-  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
-    then ac_cv_prog_egrep='grep -E'
-    else ac_cv_prog_egrep='egrep'
-    fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
-
-
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# 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
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:$LINENO: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# 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
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -5031,35 +5790,32 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_header_stdc=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_header_stdc=no
+	ac_cv_header_stdc=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
@@ -5115,6 +5871,7 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <ctype.h>
+#include <stdlib.h>
 #if ((' ' & 0x0FF) == 0x020)
 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
@@ -5134,36 +5891,50 @@ main ()
   for (i = 0; i < 256; i++)
     if (XOR (islower (i), ISLOWER (i))
 	|| toupper (i) != TOUPPER (i))
-      exit(2);
-  exit (0);
+      return 2;
+  return 0;
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
 ac_cv_header_stdc=no
 fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
+
+
 fi
 fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
 if test $ac_cv_header_stdc = yes; then
 
 cat >>confdefs.h <<\_ACEOF
@@ -5185,11 +5956,11 @@ fi
 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
 		  inttypes.h stdint.h unistd.h
 do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -5202,41 +5973,42 @@ $ac_includes_default
 #include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   eval "$as_ac_Header=yes"
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-eval "$as_ac_Header=no"
+	eval "$as_ac_Header=no"
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -5247,30 +6019,30 @@ done
 #
 # Handle user hints
 #
-echo "$as_me:$LINENO: checking if zlib is wanted" >&5
-echo $ECHO_N "checking if zlib is wanted... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking if zlib is wanted" >&5
+$as_echo_n "checking if zlib is wanted... " >&6; }
 
-# Check whether --with-zlib or --without-zlib was given.
+# Check whether --with-zlib was given.
 if test "${with_zlib+set}" = set; then
-  withval="$with_zlib"
-  if test "$withval" != no ; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  withval=$with_zlib; if test "$withval" != no ; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
   if test -d "$withval"
   then
     ZLIB_HOME="$withval"
   else
-    { echo "$as_me:$LINENO: WARNING: Sorry, $withval does not exist, checking usual places" >&5
-echo "$as_me: WARNING: Sorry, $withval does not exist, checking usual places" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: Sorry, $withval does not exist, checking usual places" >&5
+$as_echo "$as_me: WARNING: Sorry, $withval does not exist, checking usual places" >&2;}
   fi
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 else
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-fi;
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+
 
 ZLIB_HOME=/usr/local
 if test ! -f "${ZLIB_HOME}/include/zlib.h"
@@ -5288,17 +6060,16 @@ then
         LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
         CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
 
-
         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
 
-        echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5
-echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6
+        { $as_echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5
+$as_echo_n "checking for inflateEnd in -lz... " >&6; }
 if test "${ac_cv_lib_z_inflateEnd+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lz  $LIBS"
@@ -5309,74 +6080,75 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-/* Override any gcc2 internal prototype to avoid an error.  */
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
 char inflateEnd ();
 int
 main ()
 {
-inflateEnd ();
+return inflateEnd ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
   ac_cv_lib_z_inflateEnd=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_z_inflateEnd=no
+	ac_cv_lib_z_inflateEnd=no
 fi
-rm -f conftest.err conftest.$ac_objext \
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5
-echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6
-if test $ac_cv_lib_z_inflateEnd = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5
+$as_echo "$ac_cv_lib_z_inflateEnd" >&6; }
+if test "x$ac_cv_lib_z_inflateEnd" = x""yes; then
   zlib_cv_libz=yes
 else
   zlib_cv_libz=no
 fi
 
         if test "${ac_cv_header_zlib_h+set}" = set; then
-  echo "$as_me:$LINENO: checking for zlib.h" >&5
-echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6
+  { $as_echo "$as_me:$LINENO: checking for zlib.h" >&5
+$as_echo_n "checking for zlib.h... " >&6; }
 if test "${ac_cv_header_zlib_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 fi
-echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
-echo "${ECHO_T}$ac_cv_header_zlib_h" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
+$as_echo "$ac_cv_header_zlib_h" >&6; }
 else
   # Is the header compilable?
-echo "$as_me:$LINENO: checking zlib.h usability" >&5
-echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking zlib.h usability" >&5
+$as_echo_n "checking zlib.h usability... " >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -5387,41 +6159,38 @@ $ac_includes_default
 #include <zlib.h>
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_header_compiler=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_header_compiler=no
+	ac_header_compiler=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
 
 # Is the header present?
-echo "$as_me:$LINENO: checking zlib.h presence" >&5
-echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking zlib.h presence" >&5
+$as_echo_n "checking zlib.h presence... " >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -5430,79 +6199,77 @@ cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <zlib.h>
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
   ac_header_preproc=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
   ac_header_preproc=no
 fi
+
 rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
 
 # So?  What about this header?
 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
   yes:no: )
-    { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;}
     ac_header_preproc=yes
     ;;
   no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zlib.h:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: zlib.h:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zlib.h:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: zlib.h:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;}
-    (
-      cat <<\_ASBOX
+    { $as_echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: zlib.h:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: zlib.h:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: zlib.h:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: zlib.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
 ## ------------------------------ ##
 ## Report this to cole at cs.umd.edu ##
 ## ------------------------------ ##
 _ASBOX
-    ) |
-      sed "s/^/$as_me: WARNING:     /" >&2
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
-echo "$as_me:$LINENO: checking for zlib.h" >&5
-echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for zlib.h" >&5
+$as_echo_n "checking for zlib.h... " >&6; }
 if test "${ac_cv_header_zlib_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   ac_cv_header_zlib_h=$ac_header_preproc
 fi
-echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
-echo "${ECHO_T}$ac_cv_header_zlib_h" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
+$as_echo "$ac_cv_header_zlib_h" >&6; }
 
 fi
-if test $ac_cv_header_zlib_h = yes; then
+if test "x$ac_cv_header_zlib_h" = x""yes; then
   zlib_cv_zlib_h=yes
 else
   zlib_cv_zlib_h=no
@@ -5521,10 +6288,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
                 # If both library and header were found, use them
                 #
 
-echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5
-echo $ECHO_N "checking for inflateEnd in -lz... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for inflateEnd in -lz" >&5
+$as_echo_n "checking for inflateEnd in -lz... " >&6; }
 if test "${ac_cv_lib_z_inflateEnd+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lz  $LIBS"
@@ -5535,57 +6302,58 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-/* Override any gcc2 internal prototype to avoid an error.  */
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
 char inflateEnd ();
 int
 main ()
 {
-inflateEnd ();
+return inflateEnd ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
   ac_cv_lib_z_inflateEnd=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_z_inflateEnd=no
+	ac_cv_lib_z_inflateEnd=no
 fi
-rm -f conftest.err conftest.$ac_objext \
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5
-echo "${ECHO_T}$ac_cv_lib_z_inflateEnd" >&6
-if test $ac_cv_lib_z_inflateEnd = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_z_inflateEnd" >&5
+$as_echo "$ac_cv_lib_z_inflateEnd" >&6; }
+if test "x$ac_cv_lib_z_inflateEnd" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBZ 1
 _ACEOF
@@ -5594,49 +6362,174 @@ _ACEOF
 
 fi
 
-                echo "$as_me:$LINENO: checking zlib in ${ZLIB_HOME}" >&5
-echo $ECHO_N "checking zlib in ${ZLIB_HOME}... $ECHO_C" >&6
-                echo "$as_me:$LINENO: result: ok" >&5
-echo "${ECHO_T}ok" >&6
+                { $as_echo "$as_me:$LINENO: checking zlib in ${ZLIB_HOME}" >&5
+$as_echo_n "checking zlib in ${ZLIB_HOME}... " >&6; }
+                { $as_echo "$as_me:$LINENO: result: ok" >&5
+$as_echo "ok" >&6; }
 				ZLIB="-lz"
 
         else
                 #
                 # If either header or library was not found, revert and bomb
                 #
-                echo "$as_me:$LINENO: checking zlib in ${ZLIB_HOME}" >&5
-echo $ECHO_N "checking zlib in ${ZLIB_HOME}... $ECHO_C" >&6
+                { $as_echo "$as_me:$LINENO: checking zlib in ${ZLIB_HOME}" >&5
+$as_echo_n "checking zlib in ${ZLIB_HOME}... " >&6; }
                 LDFLAGS="$ZLIB_OLD_LDFLAGS"
                 CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
-                echo "$as_me:$LINENO: result: failed" >&5
-echo "${ECHO_T}failed" >&6
-                { { echo "$as_me:$LINENO: error: either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib" >&5
-echo "$as_me: error: either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib" >&2;}
+                { $as_echo "$as_me:$LINENO: result: failed" >&5
+$as_echo "failed" >&6; }
+                { { $as_echo "$as_me:$LINENO: error: either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib" >&5
+$as_echo "$as_me: error: either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib" >&2;}
    { (exit 1); exit 1; }; }
         fi
 fi
 
 
 
+
+# Check whether --with-eigen was given.
+if test "${with_eigen+set}" = set; then
+  withval=$with_eigen;
+if test "$withval" = "no"; then
+want_eigen="no"
+elif test "$withval" = "yes"; then
+want_eigen="yes"
+ac_eigen_path=""
+else
+want_eigen="yes"
+ac_eigen_path="$withval"
+fi
+
+else
+  want_eigen="yes"
+fi
+
+
+if test "x$want_eigen" = "xyes"; then
+{ $as_echo "$as_me:$LINENO: checking for eigenlib" >&5
+$as_echo_n "checking for eigenlib... " >&6; }
+succeeded=no
+
+if test "$ac_eigen_path" != ""; then
+EIGEN_CPPFLAGS="-I$ac_eigen_path/include"
+else
+for ac_eigen_path_tmp in /usr /usr/local /opt /opt/local ; do
+if test -d "$ac_eigen_path_tmp/include/eigen" && test -r "$ac_eigen_path_tmp/include/eigen"; then
+EIGEN_CPPFLAGS="-I$ac_eigen_path_tmp/include"
+break;
+fi
+done
+fi
+
+CPPFLAGS_SAVED="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $EIGEN_CPPFLAGS"
+export EIGEN_CPPFLAGS
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <Eigen/Dense>
+
+int
+main ()
+{
+
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+
+{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+succeeded=yes
+found_system=yes
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+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
+
+
+CPPFLAGS="$CPPFLAGS $EIGEN_CPPFLAGS"
+export CPPFLAGS
+LDFLAGS="$LDFLAGS $EIGEN_LDFLAGS"
+export LDFLAGS
+export EIGEN_CPPFLAGS
+
+if test "$succeeded" == "yes" ; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_EIGEN /**/
+_ACEOF
+
+fi
+
+CPPFLAGS="$CPPFLAGS_SAVED"
+LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+
 # Checks for header files.
 
 
 
 for ac_header in stdlib.h string.h unistd.h
 do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
 else
   # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5
+$as_echo_n "checking $ac_header usability... " >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -5647,41 +6540,38 @@ $ac_includes_default
 #include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_header_compiler=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_header_compiler=no
+	ac_header_compiler=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
 
 # Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5
+$as_echo_n "checking $ac_header presence... " >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -5690,81 +6580,83 @@ cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
   ac_header_preproc=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
   ac_header_preproc=no
 fi
+
 rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
 
 # So?  What about this header?
 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
   yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
     ac_header_preproc=yes
     ;;
   no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    (
-      cat <<\_ASBOX
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
 ## ------------------------------ ##
 ## Report this to cole at cs.umd.edu ##
 ## ------------------------------ ##
 _ASBOX
-    ) |
-      sed "s/^/$as_me: WARNING:     /" >&2
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
 else
   eval "$as_ac_Header=\$ac_header_preproc"
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
 
 fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -5773,10 +6665,10 @@ done
 
 
 # Checks for typedefs, structures, and compiler characteristics.
-echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5
-echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5
+$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
 if test "${ac_cv_header_stdbool_h+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -5787,22 +6679,22 @@ cat >>conftest.$ac_ext <<_ACEOF
 
 #include <stdbool.h>
 #ifndef bool
-# error bool is not defined
+ "error: bool is not defined"
 #endif
 #ifndef false
-# error false is not defined
+ "error: false is not defined"
 #endif
 #if false
-# error false is not 0
+ "error: false is not 0"
 #endif
 #ifndef true
-# error true is not defined
+ "error: true is not defined"
 #endif
 #if true != 1
-# error true is not 1
+ "error: true is not 1"
 #endif
 #ifndef __bool_true_false_are_defined
-# error __bool_true_false_are_defined is not defined
+ "error: __bool_true_false_are_defined is not defined"
 #endif
 
 	struct s { _Bool s: 1; _Bool t; } s;
@@ -5810,60 +6702,95 @@ cat >>conftest.$ac_ext <<_ACEOF
 	char a[true == 1 ? 1 : -1];
 	char b[false == 0 ? 1 : -1];
 	char c[__bool_true_false_are_defined == 1 ? 1 : -1];
-	char d[(bool) -0.5 == true ? 1 : -1];
+	char d[(bool) 0.5 == true ? 1 : -1];
 	bool e = &s;
-	char f[(_Bool) -0.0 == false ? 1 : -1];
+	char f[(_Bool) 0.0 == false ? 1 : -1];
 	char g[true];
 	char h[sizeof (_Bool)];
 	char i[sizeof s.t];
+	enum { j = false, k = true, l = false * true, m = true * 256 };
+	/* The following fails for
+	   HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+	_Bool n[m];
+	char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+	char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+#	if defined __xlc__ || defined __GNUC__
+	 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+	    reported by James Lemley on 2005-10-05; see
+	    http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+	    This test is not quite right, since xlc is allowed to
+	    reject this program, as the initializer for xlcbug is
+	    not one of the forms that C requires support for.
+	    However, doing the test right would require a runtime
+	    test, and that would make cross-compilation harder.
+	    Let us hope that IBM fixes the xlc bug, and also adds
+	    support for this kind of constant expression.  In the
+	    meantime, this test will reject xlc, which is OK, since
+	    our stdbool.h substitute should suffice.  We also test
+	    this with GCC, where it should work, to detect more
+	    quickly whether someone messes up the test in the
+	    future.  */
+	 char digs[] = "0123456789";
+	 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+#	endif
+	/* Catch a bug in an HP-UX C compiler.  See
+	   http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+	   http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+	 */
+	_Bool q = true;
+	_Bool *pq = &q;
 
 int
 main ()
 {
- return !a + !b + !c + !d + !e + !f + !g + !h + !i;
+
+	*pq |= q;
+	*pq |= ! q;
+	/* Refer to every declared value, to avoid compiler optimizations.  */
+	return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+		+ !m + !n + !o + !p + !q + !pq);
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_header_stdbool_h=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_header_stdbool_h=no
+	ac_cv_header_stdbool_h=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5
-echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6
-echo "$as_me:$LINENO: checking for _Bool" >&5
-echo $ECHO_N "checking for _Bool... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5
+$as_echo "$ac_cv_header_stdbool_h" >&6; }
+{ $as_echo "$as_me:$LINENO: checking for _Bool" >&5
+$as_echo_n "checking for _Bool... " >&6; }
 if test "${ac_cv_type__Bool+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_cv_type__Bool=no
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -5873,48 +6800,85 @@ $ac_includes_default
 int
 main ()
 {
-if ((_Bool *) 0)
-  return 0;
 if (sizeof (_Bool))
-  return 0;
+       return 0;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof ((_Bool)))
+	  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type__Bool=yes
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_type__Bool=no
+	ac_cv_type__Bool=yes
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5
-echo "${ECHO_T}$ac_cv_type__Bool" >&6
-if test $ac_cv_type__Bool = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5
+$as_echo "$ac_cv_type__Bool" >&6; }
+if test "x$ac_cv_type__Bool" = x""yes; then
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE__BOOL 1
@@ -5931,10 +6895,10 @@ _ACEOF
 
 fi
 
-echo "$as_me:$LINENO: checking for inline" >&5
-echo $ECHO_N "checking for inline... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
 if test "${ac_cv_c_inline+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
@@ -5952,39 +6916,38 @@ $ac_kw foo_t foo () {return 0; }
 
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_c_inline=$ac_kw; break
-else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_inline=$ac_kw
+else
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
 done
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
-echo "${ECHO_T}$ac_cv_c_inline" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
 
 
 case $ac_cv_c_inline in
@@ -6002,12 +6965,13 @@ _ACEOF
     ;;
 esac
 
-echo "$as_me:$LINENO: checking for pid_t" >&5
-echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for pid_t" >&5
+$as_echo_n "checking for pid_t... " >&6; }
 if test "${ac_cv_type_pid_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_cv_type_pid_t=no
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -6017,62 +6981,30 @@ $ac_includes_default
 int
 main ()
 {
-if ((pid_t *) 0)
-  return 0;
 if (sizeof (pid_t))
-  return 0;
+       return 0;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type_pid_t=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_pid_t=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
-echo "${ECHO_T}$ac_cv_type_pid_t" >&6
-if test $ac_cv_type_pid_t = yes; then
-  :
-else
-
-cat >>confdefs.h <<_ACEOF
-#define pid_t int
-_ACEOF
-
-fi
-
-echo "$as_me:$LINENO: checking for size_t" >&5
-echo $ECHO_N "checking for size_t... $ECHO_C" >&6
-if test "${ac_cv_type_size_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -6083,62 +7015,100 @@ $ac_includes_default
 int
 main ()
 {
-if ((size_t *) 0)
-  return 0;
-if (sizeof (size_t))
-  return 0;
+if (sizeof ((pid_t)))
+	  return 0;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type_size_t=yes
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_type_size_t=no
+	ac_cv_type_pid_t=yes
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
-echo "${ECHO_T}$ac_cv_type_size_t" >&6
-if test $ac_cv_type_size_t = yes; then
-  :
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
+$as_echo "$ac_cv_type_pid_t" >&6; }
+if test "x$ac_cv_type_pid_t" = x""yes; then
+  :
 else
 
 cat >>confdefs.h <<_ACEOF
-#define size_t unsigned
+#define pid_t int
 _ACEOF
 
 fi
 
-echo "$as_me:$LINENO: checking for ptrdiff_t" >&5
-echo $ECHO_N "checking for ptrdiff_t... $ECHO_C" >&6
-if test "${ac_cv_type_ptrdiff_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for size_t" >&5
+$as_echo_n "checking for size_t... " >&6; }
+if test "${ac_cv_type_size_t+set}" = set; then
+  $as_echo_n "(cached) " >&6
 else
+  ac_cv_type_size_t=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof (size_t))
+       return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -6149,48 +7119,155 @@ $ac_includes_default
 int
 main ()
 {
-if ((ptrdiff_t *) 0)
+if (sizeof ((size_t)))
+	  return 0;
+  ;
   return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_size_t=yes
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+$as_echo "$ac_cv_type_size_t" >&6; }
+if test "x$ac_cv_type_size_t" = x""yes; then
+  :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
+{ $as_echo "$as_me:$LINENO: checking for ptrdiff_t" >&5
+$as_echo_n "checking for ptrdiff_t... " >&6; }
+if test "${ac_cv_type_ptrdiff_t+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_type_ptrdiff_t=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
 if (sizeof (ptrdiff_t))
-  return 0;
+       return 0;
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if (sizeof ((ptrdiff_t)))
+	  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type_ptrdiff_t=yes
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  :
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_ptrdiff_t=yes
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_type_ptrdiff_t=no
+
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_type_ptrdiff_t" >&5
-echo "${ECHO_T}$ac_cv_type_ptrdiff_t" >&6
-if test $ac_cv_type_ptrdiff_t = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_ptrdiff_t" >&5
+$as_echo "$ac_cv_type_ptrdiff_t" >&6; }
+if test "x$ac_cv_type_ptrdiff_t" = x""yes; then
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_PTRDIFF_T 1
@@ -6200,37 +7277,53 @@ _ACEOF
 fi
 
 
+
 # Checks for library functions.
 #AC_FUNC_FORK
 #AC_CHECK_FUNCS([floor memmove pow regcomp sqrt strchr strcspn strspn strstr])
 
 # check the platform
-echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
 if test "${ac_cv_host+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_host_alias=$host_alias
-test -z "$ac_cv_host_alias" &&
-  ac_cv_host_alias=$ac_cv_build_alias
-ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
-  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
    { (exit 1); exit 1; }; }
+fi
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+$as_echo "$as_me: error: invalid value of canonical host" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
 host=$ac_cv_host
-host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
 
 
 
 # set CFLAGS and CXXFLAGS
 user_CFLAGS=${CFLAGS}
-generic_CFLAGS="-Wall -Wno-strict-aliasing -g -gdwarf-2 -Wuninitialized"
+generic_CFLAGS="-Wall -Wno-strict-aliasing -g -gdwarf-2 -Wunused -Wuninitialized"
 ext_CFLAGS=""
 debug_CFLAGS=""
 #echo "${host_cpu}-${host_os}"
@@ -6255,37 +7348,35 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ext_CFLAGS="-arch x86_64"
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext;;
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext;;
   *)
-    echo "$as_me:$LINENO: checking if gcc accepts -m64" >&5
-echo $ECHO_N "checking if gcc accepts -m64... $ECHO_C" >&6
+    { $as_echo "$as_me:$LINENO: checking if gcc accepts -m64" >&5
+$as_echo_n "checking if gcc accepts -m64... " >&6; }
     CFLAGS="-m64"
     cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -6303,67 +7394,64 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ext_CFLAGS="-m64"; echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ext_CFLAGS="-m64"; { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ext_CFLAGS="-D_FILE_OFFSET_BITS=64"; echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+	ext_CFLAGS="-D_FILE_OFFSET_BITS=64"; { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext;;
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext;;
 esac
 
-# Check whether --enable-vectorize or --disable-vectorize was given.
+# Check whether --enable-vectorize was given.
 if test "${enable_vectorize+set}" = set; then
-  enableval="$enable_vectorize"
-  ext_CFLAGS="${ext_CFLAGS} -ftree-vectorize -msse3 -ffast-math -ftree-vectorizer-verbose=99"
-fi;
+  enableval=$enable_vectorize; ext_CFLAGS="${ext_CFLAGS} -ftree-vectorize -msse3 -ffast-math -ftree-vectorizer-verbose=99"
+fi
+
 
-# Check whether --enable-intel64 or --disable-intel64 was given.
+# Check whether --enable-intel64 was given.
 if test "${enable_intel64+set}" = set; then
-  enableval="$enable_intel64"
-  ext_CFLAGS="${ext_CFLAGS} -march=nocona"
-fi;
+  enableval=$enable_intel64; ext_CFLAGS="${ext_CFLAGS} -march=nocona"
+fi
 
-# Check whether --enable-debug or --disable-debug was given.
-if test "${enable_debug+set}" = set; then
-  enableval="$enable_debug"
 
+# Check whether --enable-debug was given.
+if test "${enable_debug+set}" = set; then
+  enableval=$enable_debug;
 else
   enable_debug=no
-fi;
+fi
 
 
-# Check whether --enable-optim or --disable-optim was given.
+
+# Check whether --enable-optim was given.
 if test "${enable_optim+set}" = set; then
-  enableval="$enable_optim"
-  if test "x$enable_optim" = xyes; then enable_optim=3; fi
+  enableval=$enable_optim; if test "x$enable_optim" = xyes; then enable_optim=3; fi
 else
   enable_optim=3
-fi;
+fi
+
 
 if test "x$enable_optim" != xno; then
   ext_CFLAGS="$ext_CFLAGS -O$enable_optim"
@@ -6377,22 +7465,22 @@ else
 fi
 
 
-# Check whether --enable-profiling or --disable-profiling was given.
+# Check whether --enable-profiling was given.
 if test "${enable_profiling+set}" = set; then
-  enableval="$enable_profiling"
-  ext_LDFLAGS="-lprofiler -ltcmalloc"
-fi;
+  enableval=$enable_profiling; ext_LDFLAGS="-lprofiler -ltcmalloc"
+fi
+
 
 CFLAGS="${generic_CFLAGS} ${ext_CFLAGS} ${user_CFLAGS} ${debug_CFLAGS} ${OPENMP_CFLAGS}"
 CXXFLAGS="$CFLAGS"
-CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $BAM_CPPFLAGS"
+CXXFLAGS="${CXXFLAGS} ${BOOST_CPPFLAGS} ${BAM_CPPFLAGS} ${EIGEN_CPPFLAGS}"
 LDFLAGS="$ext_LDFLAGS"
 
 # Checks for structures/functions that can be used to determine system memory
-echo "$as_me:$LINENO: checking for struct sysinfo.totalram" >&5
-echo $ECHO_N "checking for struct sysinfo.totalram... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for struct sysinfo.totalram" >&5
+$as_echo_n "checking for struct sysinfo.totalram... " >&6; }
 if test "${ac_cv_member_struct_sysinfo_totalram+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -6413,33 +7501,29 @@ return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_member_struct_sysinfo_totalram=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-cat >conftest.$ac_ext <<_ACEOF
+	cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -6458,41 +7542,39 @@ return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_member_struct_sysinfo_totalram=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_member_struct_sysinfo_totalram=no
+	ac_cv_member_struct_sysinfo_totalram=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_member_struct_sysinfo_totalram" >&5
-echo "${ECHO_T}$ac_cv_member_struct_sysinfo_totalram" >&6
-if test $ac_cv_member_struct_sysinfo_totalram = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_member_struct_sysinfo_totalram" >&5
+$as_echo "$ac_cv_member_struct_sysinfo_totalram" >&6; }
+if test "x$ac_cv_member_struct_sysinfo_totalram" = x""yes; then
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_STRUCT_SYSINFO_TOTALRAM 1
@@ -6501,10 +7583,10 @@ _ACEOF
 
 fi
 
-echo "$as_me:$LINENO: checking whether sysctl is declared" >&5
-echo $ECHO_N "checking whether sysctl is declared... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether sysctl is declared" >&5
+$as_echo_n "checking whether sysctl is declared... " >&6; }
 if test "${ac_cv_have_decl_sysctl+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -6518,7 +7600,7 @@ int
 main ()
 {
 #ifndef sysctl
-  char *p = (char *) sysctl;
+  (void) sysctl;
 #endif
 
   ;
@@ -6526,39 +7608,36 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_have_decl_sysctl=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_have_decl_sysctl=no
+	ac_cv_have_decl_sysctl=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_have_decl_sysctl" >&5
-echo "${ECHO_T}$ac_cv_have_decl_sysctl" >&6
-if test $ac_cv_have_decl_sysctl = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_sysctl" >&5
+$as_echo "$ac_cv_have_decl_sysctl" >&6; }
+if test "x$ac_cv_have_decl_sysctl" = x""yes; then
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_SYSCTL 1
@@ -6572,10 +7651,10 @@ _ACEOF
 
 
 fi
-echo "$as_me:$LINENO: checking whether CTL_HW is declared" >&5
-echo $ECHO_N "checking whether CTL_HW is declared... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether CTL_HW is declared" >&5
+$as_echo_n "checking whether CTL_HW is declared... " >&6; }
 if test "${ac_cv_have_decl_CTL_HW+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -6589,7 +7668,7 @@ int
 main ()
 {
 #ifndef CTL_HW
-  char *p = (char *) CTL_HW;
+  (void) CTL_HW;
 #endif
 
   ;
@@ -6597,39 +7676,36 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_have_decl_CTL_HW=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_have_decl_CTL_HW=no
+	ac_cv_have_decl_CTL_HW=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_have_decl_CTL_HW" >&5
-echo "${ECHO_T}$ac_cv_have_decl_CTL_HW" >&6
-if test $ac_cv_have_decl_CTL_HW = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_CTL_HW" >&5
+$as_echo "$ac_cv_have_decl_CTL_HW" >&6; }
+if test "x$ac_cv_have_decl_CTL_HW" = x""yes; then
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_CTL_HW 1
@@ -6643,10 +7719,10 @@ _ACEOF
 
 
 fi
-echo "$as_me:$LINENO: checking whether HW_PHYSMEM is declared" >&5
-echo $ECHO_N "checking whether HW_PHYSMEM is declared... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking whether HW_PHYSMEM is declared" >&5
+$as_echo_n "checking whether HW_PHYSMEM is declared... " >&6; }
 if test "${ac_cv_have_decl_HW_PHYSMEM+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -6660,7 +7736,7 @@ int
 main ()
 {
 #ifndef HW_PHYSMEM
-  char *p = (char *) HW_PHYSMEM;
+  (void) HW_PHYSMEM;
 #endif
 
   ;
@@ -6668,39 +7744,36 @@ main ()
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
   ac_cv_have_decl_HW_PHYSMEM=yes
 else
-  echo "$as_me: failed program was:" >&5
+  $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_have_decl_HW_PHYSMEM=no
+	ac_cv_have_decl_HW_PHYSMEM=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_have_decl_HW_PHYSMEM" >&5
-echo "${ECHO_T}$ac_cv_have_decl_HW_PHYSMEM" >&6
-if test $ac_cv_have_decl_HW_PHYSMEM = yes; then
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_have_decl_HW_PHYSMEM" >&5
+$as_echo "$ac_cv_have_decl_HW_PHYSMEM" >&6; }
+if test "x$ac_cv_have_decl_HW_PHYSMEM" = x""yes; then
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_HW_PHYSMEM 1
@@ -6720,8 +7793,8 @@ fi
 # test to see if srcdir already configured
 if test "`cd $srcdir && pwd`" != "`pwd`" &&
    test -f $srcdir/config.status; then
-  { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
-echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
+  { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
+$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
@@ -6737,7 +7810,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='cufflinks'
- VERSION='1.3.0'
+ VERSION='2.0.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -6775,10 +7848,10 @@ 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.
 set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_STRIP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$STRIP"; then
   ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
@@ -6789,34 +7862,36 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 STRIP=$ac_cv_prog_STRIP
 if test -n "$STRIP"; then
-  echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
+  { $as_echo "$as_me:$LINENO: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+
 fi
 if test -z "$ac_cv_prog_STRIP"; then
   ac_ct_STRIP=$STRIP
   # Extract the first word of "strip", so it can be a program name with args.
 set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_STRIP"; then
   ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
@@ -6827,27 +7902,37 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_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"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
-  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
 fi
 fi
 ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
 if test -n "$ac_ct_STRIP"; then
-  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
+  { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-  STRIP=$ac_ct_STRIP
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
 else
   STRIP="$ac_cv_prog_STRIP"
 fi
@@ -6862,8 +7947,8 @@ INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
 AMTAR=${AMTAR-"${am_missing_run}tar"}
 
 
-echo "$as_me:$LINENO: checking how to create a pax tar archive" >&5
-echo $ECHO_N "checking how to create a pax tar archive... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking how to create a pax tar archive" >&5
+$as_echo_n "checking how to create a pax tar archive... " >&6; }
 # Loop over all known methods to create a tar archive until one works.
 _am_tools='gnutar  pax cpio none'
 _am_tools=${am_cv_prog_tar_pax-$_am_tools}
@@ -6936,23 +8021,23 @@ done
 rm -rf conftest.dir
 
 if test "${am_cv_prog_tar_pax+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   am_cv_prog_tar_pax=$_am_tool
 fi
 
-echo "$as_me:$LINENO: result: $am_cv_prog_tar_pax" >&5
-echo "${ECHO_T}$am_cv_prog_tar_pax" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_prog_tar_pax" >&5
+$as_echo "$am_cv_prog_tar_pax" >&6; }
 
 
 
 
 depcc="$CC"   am_compiler_list=
 
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
 if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
   # We make a subdir and do the tests there.  Otherwise we can end up
@@ -7039,8 +8124,8 @@ else
 fi
 
 fi
-echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
 CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
 
 
@@ -7058,10 +8143,10 @@ fi
 
 depcc="$CXX"  am_compiler_list=
 
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
 if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  $as_echo_n "(cached) " >&6
 else
   if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
   # We make a subdir and do the tests there.  Otherwise we can end up
@@ -7148,8 +8233,8 @@ else
 fi
 
 fi
-echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6
+{ $as_echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
 CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
 
 
@@ -7167,7 +8252,7 @@ fi
 
 
 
-                    ac_config_files="$ac_config_files Makefile src/Makefile"
+ac_config_files="$ac_config_files Makefile src/Makefile"
 
 
 cat >confcache <<\_ACEOF
@@ -7188,39 +8273,59 @@ _ACEOF
 
 # The following way of writing the cache mishandles newlines in values,
 # but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
+# So, we kill variables containing newlines.
 # Ultrix sh set writes to stderr and can't be redirected directly,
 # and sets the high bit in the cache file unless we assign to the vars.
-{
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+
   (set) 2>&1 |
-    case `(ac_space=' '; set | grep ac_space) 2>&1` in
-    *ac_space=\ *)
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
       # `set' does not quote correctly, so add quotes (double-quote
       # substitution turns \\\\ into \\, and sed turns \\ into \).
       sed -n \
 	"s/'/'\\\\''/g;
 	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;;
+      ;; #(
     *)
       # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n \
-	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
       ;;
-    esac;
-} |
+    esac |
+    sort
+) |
   sed '
+     /^ac_cv_env_/b end
      t clear
-     : clear
+     :clear
      s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
      t end
-     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
-  if test -w $cache_file; then
-    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
     cat confcache >$cache_file
   else
-    echo "not updating unwritable cache $cache_file"
+    { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
 rm -f confcache
@@ -7229,32 +8334,18 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix
 # Let make expand exec_prefix.
 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[	 ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[	 ]*$//;
-}'
-fi
-
 DEFS=-DHAVE_CONFIG_H
 
 ac_libobjs=
 ac_ltlibobjs=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
-  ac_i=`echo "$ac_i" |
-	 sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
-  # 2. Add them.
-  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
-  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
 done
 LIBOBJS=$ac_libobjs
 
@@ -7262,47 +8353,48 @@ LTLIBOBJS=$ac_ltlibobjs
 
 
 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
+  { { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"AMDEP\" was never defined.
+$as_echo "$as_me: error: conditional \"AMDEP\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
 if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
+  { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
+$as_echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+  { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+  { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
 if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
+  { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
+$as_echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 : ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
+{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 #! $SHELL
 # Generated by $as_me.
 # Run this file to recreate the current configuration.
@@ -7315,22 +8407,78 @@ ac_cs_silent=false
 SHELL=\${CONFIG_SHELL-$SHELL}
 _ACEOF
 
-cat >>$CONFIG_STATUS <<\_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 ## --------------------- ##
 ## M4sh Initialization.  ##
 ## --------------------- ##
 
-# Be Bourne compatible
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
   emulate sh
   NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
-  set -o posix
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in
+  *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  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=';'
+  }
 fi
-DUALCASE=1; export DUALCASE # for MKS sh
 
 # Support unset when possible.
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
@@ -7340,33 +8488,60 @@ else
 fi
 
 
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
 # Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
 PS1='$ '
 PS2='> '
 PS4='+ '
 
 # NLS nuisances.
-for as_var in \
-  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
-  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
-  LC_TELEPHONE LC_TIME
-do
-  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
-    eval $as_var=C; export $as_var
-  else
-    $as_unset $as_var
-  fi
-done
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
 
 # Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
 else
   as_expr=false
 fi
 
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
   as_basename=basename
 else
   as_basename=false
@@ -7374,159 +8549,122 @@ fi
 
 
 # Name of the executable.
-as_me=`$as_basename "$0" ||
+as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)$' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
-  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\/\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
 
+# CDPATH.
+$as_unset CDPATH
 
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  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
 
 
   as_lineno_1=$LINENO
   as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
   test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
-  # Find who we are.  Look in the path if we contain no path at all
-  # relative or not.
-  case $0 in
-    *[\\/]* ) as_myself=$0 ;;
-    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
 
-       ;;
-  esac
-  # We did not find ourselves, most probably we were run as `sh COMMAND'
-  # in which case we are not to be found in the path.
-  if test "x$as_myself" = x; then
-    as_myself=$0
-  fi
-  if test ! -f "$as_myself"; then
-    { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
-   { (exit 1); exit 1; }; }
-  fi
-  case $CONFIG_SHELL in
-  '')
-    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for as_base in sh bash ksh sh5; do
-	 case $as_dir in
-	 /*)
-	   if ("$as_dir/$as_base" -c '
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
-	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
-	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
-	     CONFIG_SHELL=$as_dir/$as_base
-	     export CONFIG_SHELL
-	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
-	   fi;;
-	 esac
-       done
-done
-;;
-  esac
-
-  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
-  # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line before each line; the second 'sed' does the real
-  # work.  The second script uses 'N' to pair each line-number line
-  # with the numbered line, and appends trailing '-' during
-  # substitution so that $LINENO is not a special case at line end.
-  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
-  sed '=' <$as_myself |
-    sed '
-      N
-      s,$,-,
-      : loop
-      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
-      t loop
-      s,-$,,
-      s,^['$as_cr_digits']*\n,,
-    ' >$as_me.lineno &&
-  chmod +x $as_me.lineno ||
-    { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.  The first 'sed' inserts a
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
    { (exit 1); exit 1; }; }
 
   # 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 sensible to this).
-  . ./$as_me.lineno
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
   # Exit status is that of the last command.
   exit
 }
 
 
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
-  *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T='	' ;;
-  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
-  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
 
-if expr a : '\(a\)' >/dev/null 2>&1; then
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
 else
   as_expr=false
 fi
 
 rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
-  # We could just check for DJGPP; but this test a) works b) is more generic
-  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
-  if test -f conf$$.exe; then
-    # Don't use ln at all; we don't have any links
-    as_ln_s='cp -p'
-  else
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
     as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
   fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
 else
   as_ln_s='cp -p'
 fi
-rm -f conf$$ conf$$.exe conf$$.file
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
 
 if mkdir -p . 2>/dev/null; then
   as_mkdir_p=:
@@ -7535,7 +8673,28 @@ else
   as_mkdir_p=false
 fi
 
-as_executable_p="test -f"
+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'"
@@ -7544,31 +8703,14 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" 	$as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
 exec 6>&1
 
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# Save the log message, to keep $[0] and so on meaningful, and to
 # report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.  Logging --version etc. is OK.
-exec 5>>config.log
-{
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
-This file was extended by cufflinks $as_me 1.3.0, which was
-generated by GNU Autoconf 2.59.  Invocation command line was
+# values after options handling.
+ac_log="
+This file was extended by cufflinks $as_me 2.0.0, which was
+generated by GNU Autoconf 2.63.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -7576,45 +8718,45 @@ generated by GNU Autoconf 2.59.  Invocation command line was
   CONFIG_COMMANDS = $CONFIG_COMMANDS
   $ $0 $@
 
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
 _ACEOF
 
-# Files that config.status was made for.
-if test -n "$ac_config_files"; then
-  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
 
-if test -n "$ac_config_headers"; then
-  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
 
-if test -n "$ac_config_links"; then
-  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
 
-if test -n "$ac_config_commands"; then
-  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
 
-cat >>$CONFIG_STATUS <<\_ACEOF
+_ACEOF
 
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 ac_cs_usage="\
 \`$as_me' instantiates files from templates according to the
 current configuration.
 
-Usage: $0 [OPTIONS] [FILE]...
+Usage: $0 [OPTION]... [FILE]...
 
   -h, --help       print this help, then exit
-  -V, --version    print version number, then exit
-  -q, --quiet      do not print progress messages
+  -V, --version    print version number and configuration settings, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
   -d, --debug      don't remove temporary files
       --recheck    update $as_me by reconfiguring in the same conditions
-  --file=FILE[:TEMPLATE]
-		   instantiate the configuration file FILE
-  --header=FILE[:TEMPLATE]
-		   instantiate the configuration header FILE
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
 
 Configuration files:
 $config_files
@@ -7626,83 +8768,83 @@ Configuration commands:
 $config_commands
 
 Report bugs to <bug-autoconf at gnu.org>."
-_ACEOF
 
-cat >>$CONFIG_STATUS <<_ACEOF
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-cufflinks config.status 1.3.0
-configured by $0, generated by GNU Autoconf 2.59,
-  with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+cufflinks config.status 2.0.0
+configured by $0, generated by GNU Autoconf 2.63,
+  with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
-Copyright (C) 2003 Free Software Foundation, Inc.
+Copyright (C) 2008 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
-INSTALL="$INSTALL"
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
 _ACEOF
 
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value.  By we need to know if files were specified by the user.
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
 ac_need_defaults=:
 while test $# != 0
 do
   case $1 in
   --*=*)
-    ac_option=`expr "x$1" : 'x\([^=]*\)='`
-    ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
     ac_shift=:
     ;;
-  -*)
+  *)
     ac_option=$1
     ac_optarg=$2
     ac_shift=shift
     ;;
-  *) # This is not an option, so the user has probably given explicit
-     # arguments.
-     ac_option=$1
-     ac_need_defaults=false;;
   esac
 
   case $ac_option in
   # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
     ac_cs_recheck=: ;;
-  --version | --vers* | -V )
-    echo "$ac_cs_version"; exit 0 ;;
-  --he | --h)
-    # Conflict between --help and --header
-    { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
-   { (exit 1); exit 1; }; };;
-  --help | --hel | -h )
-    echo "$ac_cs_usage"; exit 0 ;;
-  --debug | --d* | -d )
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
     debug=: ;;
   --file | --fil | --fi | --f )
     $ac_shift
-    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
     ac_need_defaults=false;;
   --header | --heade | --head | --hea )
     $ac_shift
-    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'"
     ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    { $as_echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil | --si | --s)
     ac_cs_silent=: ;;
 
   # This is an error.
-  -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
+  -*) { $as_echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
    { (exit 1); exit 1; }; } ;;
 
-  *) ac_config_targets="$ac_config_targets $1" ;;
+  *) ac_config_targets="$ac_config_targets $1"
+     ac_need_defaults=false ;;
 
   esac
   shift
@@ -7716,40 +8858,54 @@ if $ac_cs_silent; then
 fi
 
 _ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
-  exec $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'
+  export CONFIG_SHELL
+  exec "\$@"
 fi
 
 _ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
 
-cat >>$CONFIG_STATUS <<_ACEOF
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 #
-# INIT-COMMANDS section.
+# INIT-COMMANDS
 #
-
 AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
 
 _ACEOF
 
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 
-
-cat >>$CONFIG_STATUS <<\_ACEOF
+# Handling of arguments.
 for ac_config_target in $ac_config_targets
 do
-  case "$ac_config_target" in
-  # Handling of arguments.
-  "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
-  "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
-  "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
-  "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
-  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
+
+  *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
 done
 
+
 # If the user did not use the arguments to specify the items to instantiate,
 # then the envvar interface is used.  Set only those that are not.
 # We use the long form for the default assignment because of an extremely
@@ -7761,746 +8917,635 @@ if $ac_need_defaults; then
 fi
 
 # Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
+# simply because there is no reason against having it here, and in addition,
 # creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
 $debug ||
 {
-  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
   trap '{ (exit 1); exit 1; }' 1 2 13 15
 }
-
 # Create a (secure) tmp directory for tmp files.
 
 {
-  tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
   test -n "$tmp" && test -d "$tmp"
 }  ||
 {
-  tmp=./confstat$$-$RANDOM
-  (umask 077 && mkdir $tmp)
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
 } ||
 {
-   echo "$me: cannot create a temporary directory in ." >&2
+   $as_echo "$as_me: cannot create a temporary directory in ." >&2
    { (exit 1); exit 1; }
 }
 
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr='
'
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
 _ACEOF
 
-cat >>$CONFIG_STATUS <<_ACEOF
 
-#
-# CONFIG_FILES section.
-#
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
 
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
-  # Protect against being on the right side of a sed subst in config.status.
-  sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
-   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s, at SHELL@,$SHELL,;t t
-s, at PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s, at PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s, at PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s, at PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s, at PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s, at PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s, at exec_prefix@,$exec_prefix,;t t
-s, at prefix@,$prefix,;t t
-s, at program_transform_name@,$program_transform_name,;t t
-s, at bindir@,$bindir,;t t
-s, at sbindir@,$sbindir,;t t
-s, at libexecdir@,$libexecdir,;t t
-s, at datadir@,$datadir,;t t
-s, at sysconfdir@,$sysconfdir,;t t
-s, at sharedstatedir@,$sharedstatedir,;t t
-s, at localstatedir@,$localstatedir,;t t
-s, at libdir@,$libdir,;t t
-s, at includedir@,$includedir,;t t
-s, at oldincludedir@,$oldincludedir,;t t
-s, at infodir@,$infodir,;t t
-s, at mandir@,$mandir,;t t
-s, at build_alias@,$build_alias,;t t
-s, at host_alias@,$host_alias,;t t
-s, at target_alias@,$target_alias,;t t
-s, at DEFS@,$DEFS,;t t
-s, at ECHO_C@,$ECHO_C,;t t
-s, at ECHO_N@,$ECHO_N,;t t
-s, at ECHO_T@,$ECHO_T,;t t
-s, at LIBS@,$LIBS,;t t
-s, at INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
-s, at INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
-s, at INSTALL_DATA@,$INSTALL_DATA,;t t
-s, at CYGPATH_W@,$CYGPATH_W,;t t
-s, at PACKAGE@,$PACKAGE,;t t
-s, at VERSION@,$VERSION,;t t
-s, at ACLOCAL@,$ACLOCAL,;t t
-s, at AUTOCONF@,$AUTOCONF,;t t
-s, at AUTOMAKE@,$AUTOMAKE,;t t
-s, at AUTOHEADER@,$AUTOHEADER,;t t
-s, at MAKEINFO@,$MAKEINFO,;t t
-s, at install_sh@,$install_sh,;t t
-s, at STRIP@,$STRIP,;t t
-s, at ac_ct_STRIP@,$ac_ct_STRIP,;t t
-s, at INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
-s, at mkdir_p@,$mkdir_p,;t t
-s, at AWK@,$AWK,;t t
-s, at SET_MAKE@,$SET_MAKE,;t t
-s, at am__leading_dot@,$am__leading_dot,;t t
-s, at AMTAR@,$AMTAR,;t t
-s, at am__tar@,$am__tar,;t t
-s, at am__untar@,$am__untar,;t t
-s, at PYTHON@,$PYTHON,;t t
-s, at CXX@,$CXX,;t t
-s, at CXXFLAGS@,$CXXFLAGS,;t t
-s, at LDFLAGS@,$LDFLAGS,;t t
-s, at CPPFLAGS@,$CPPFLAGS,;t t
-s, at ac_ct_CXX@,$ac_ct_CXX,;t t
-s, at EXEEXT@,$EXEEXT,;t t
-s, at OBJEXT@,$OBJEXT,;t t
-s, at DEPDIR@,$DEPDIR,;t t
-s, at am__include@,$am__include,;t t
-s, at am__quote@,$am__quote,;t t
-s, at AMDEP_TRUE@,$AMDEP_TRUE,;t t
-s, at AMDEP_FALSE@,$AMDEP_FALSE,;t t
-s, at AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
-s, at CXXDEPMODE@,$CXXDEPMODE,;t t
-s, at am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t
-s, at am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t
-s, at CC@,$CC,;t t
-s, at CFLAGS@,$CFLAGS,;t t
-s, at ac_ct_CC@,$ac_ct_CC,;t t
-s, at CCDEPMODE@,$CCDEPMODE,;t t
-s, at am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
-s, at am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
-s, at RANLIB@,$RANLIB,;t t
-s, at ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
-s, at PYTHON_VERSION@,$PYTHON_VERSION,;t t
-s, at PYTHON_PREFIX@,$PYTHON_PREFIX,;t t
-s, at PYTHON_EXEC_PREFIX@,$PYTHON_EXEC_PREFIX,;t t
-s, at PYTHON_PLATFORM@,$PYTHON_PLATFORM,;t t
-s, at pythondir@,$pythondir,;t t
-s, at pkgpythondir@,$pkgpythondir,;t t
-s, at pyexecdir@,$pyexecdir,;t t
-s, at pkgpyexecdir@,$pkgpyexecdir,;t t
-s, at BOOST_CPPFLAGS@,$BOOST_CPPFLAGS,;t t
-s, at BOOST_LDFLAGS@,$BOOST_LDFLAGS,;t t
-s, at BAM_CPPFLAGS@,$BAM_CPPFLAGS,;t t
-s, at BAM_LDFLAGS@,$BAM_LDFLAGS,;t t
-s, at BAM_LIB@,$BAM_LIB,;t t
-s, at build@,$build,;t t
-s, at build_cpu@,$build_cpu,;t t
-s, at build_vendor@,$build_vendor,;t t
-s, at build_os@,$build_os,;t t
-s, at BOOST_THREAD_LIB@,$BOOST_THREAD_LIB,;t t
-s, at CPP@,$CPP,;t t
-s, at EGREP@,$EGREP,;t t
-s, at ZLIB@,$ZLIB,;t t
-s, at host@,$host,;t t
-s, at host_cpu@,$host_cpu,;t t
-s, at host_vendor@,$host_vendor,;t t
-s, at host_os@,$host_os,;t t
-s, at LIBOBJS@,$LIBOBJS,;t t
-s, at LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
-
-_ACEOF
-
-  cat >>$CONFIG_STATUS <<\_ACEOF
-  # Split the substitutions into bite-sized pieces for seds with
-  # small command number limits, like on Digital OSF/1 and HP-UX.
-  ac_max_sed_lines=48
-  ac_sed_frag=1 # Number of current file.
-  ac_beg=1 # First line for current file.
-  ac_end=$ac_max_sed_lines # Line after last line for current file.
-  ac_more_lines=:
-  ac_sed_cmds=
-  while $ac_more_lines; do
-    if test $ac_beg -gt 1; then
-      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
-    else
-      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
-    fi
-    if test ! -s $tmp/subs.frag; then
-      ac_more_lines=false
-    else
-      # The purpose of the label and of the branching condition is to
-      # speed up the sed processing (if there are no `@' at all, there
-      # is no need to browse any of the substitutions).
-      # These are the two extra sed commands mentioned above.
-      (echo ':t
-  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
-      if test -z "$ac_sed_cmds"; then
-	ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
-      else
-	ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
-      fi
-      ac_sed_frag=`expr $ac_sed_frag + 1`
-      ac_beg=$ac_end
-      ac_end=`expr $ac_end + $ac_max_sed_lines`
-    fi
-  done
-  if test -z "$ac_sed_cmds"; then
-    ac_sed_cmds=cat
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\).*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\).*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = ""
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5
+$as_echo "$as_me: error: could not setup config files machinery" >&2;}
+   { (exit 1); exit 1; }; }
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[	 ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[	 ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 fi # test -n "$CONFIG_FILES"
 
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
 _ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case $ac_file in
-  - | *:- | *:-:* ) # input from stdin
-	cat >$tmp/stdin
-	ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  * )   ac_file_in=$ac_file.in ;;
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_t"; then
+    break
+  elif $ac_last_try; then
+    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5
+$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5
+$as_echo "$as_me: error: could not setup config headers machinery" >&2;}
+   { (exit 1); exit 1; }; }
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
   esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
+$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
+   { (exit 1); exit 1; }; };;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
 
-  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
-  ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+   { (exit 1); exit 1; }; };;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      ac_file_inputs="$ac_file_inputs '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	`' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:$LINENO: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; } ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$ac_file" : 'X\(//\)[^/]' \| \
 	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-  { if $as_mkdir_p; then
-    mkdir -p "$ac_dir"
-  else
-    as_dir="$ac_dir"
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  { as_dir="$ac_dir"
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
     as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_dir" : 'X\(//\)[^/]' \| \
 	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
     done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
    { (exit 1); exit 1; }; }; }
-
   ac_builddir=.
 
-if test "$ac_dir" != .; then
-  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
-  # A "../" for each directory in $ac_dir_suffix.
-  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
-  ac_dir_suffix= ac_top_builddir=
-fi
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
 
 case $srcdir in
-  .)  # No --srcdir option.  We are building in place.
+  .)  # We are building in place.
     ac_srcdir=.
-    if test -z "$ac_top_builddir"; then
-       ac_top_srcdir=.
-    else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
-    fi ;;
-  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
     ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir ;;
-  *) # Relative path.
-    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
 esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
 
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
-  case "$ac_dir" in
-  .) ac_abs_builddir=`pwd`;;
-  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
-  *) ac_abs_builddir=`pwd`/"$ac_dir";;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
-  case ${ac_top_builddir}. in
-  .) ac_abs_top_builddir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
-  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
-  case $ac_srcdir in
-  .) ac_abs_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
-  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
-  case $ac_top_srcdir in
-  .) ac_abs_top_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
-  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
-  esac;;
-esac
 
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
 
   case $INSTALL in
   [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
-  *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
   esac
+_ACEOF
 
-  if test x"$ac_file" != x-; then
-    { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-    rm -f "$ac_file"
-  fi
-  # Let's still pretend it is `configure' which instantiates (i.e., don't
-  # use $as_me), people would be surprised to read:
-  #    /* config.h.  Generated by config.status.  */
-  if test x"$ac_file" = x-; then
-    configure_input=
-  else
-    configure_input="$ac_file.  "
-  fi
-  configure_input=$configure_input"Generated from `echo $ac_file_in |
-				     sed 's,.*/,,'` by configure."
-
-  # First look for the input files in the build tree, otherwise in the
-  # src tree.
-  ac_file_inputs=`IFS=:
-    for f in $ac_file_in; do
-      case $f in
-      -) echo $tmp/stdin ;;
-      [\\/$]*)
-	 # Absolute (can't be DOS-style, as IFS=:)
-	 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 echo "$f";;
-      *) # Relative
-	 if test -f "$f"; then
-	   # Build tree
-	   echo "$f"
-	 elif test -f "$srcdir/$f"; then
-	   # Source tree
-	   echo "$srcdir/$f"
-	 else
-	   # /dev/null tree
-	   { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 fi;;
-      esac
-    done` || { (exit 1); exit 1; }
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+    s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
 _ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-  sed "$ac_vpsub
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
 $extrasub
 _ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 :t
 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s, at configure_input@,$configure_input,;t t
-s, at srcdir@,$ac_srcdir,;t t
-s, at abs_srcdir@,$ac_abs_srcdir,;t t
-s, at top_srcdir@,$ac_top_srcdir,;t t
-s, at abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s, at builddir@,$ac_builddir,;t t
-s, at abs_builddir@,$ac_abs_builddir,;t t
-s, at top_builddir@,$ac_top_builddir,;t t
-s, at abs_top_builddir@,$ac_abs_top_builddir,;t t
-s, at INSTALL@,$ac_INSTALL,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
-  rm -f $tmp/stdin
-  if test x"$ac_file" != x-; then
-    mv $tmp/out $ac_file
-  else
-    cat $tmp/out
-    rm -f $tmp/out
-  fi
-
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
 
-#
-# CONFIG_HEADER section.
-#
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
 
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([	 ]*\)#\([	 ]*define[	 ][	 ]*\)'
-ac_dB='[	 ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([	 ]*\)#\([	 ]*\)undef\([	 ][	 ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  rm -f "$tmp/stdin"
   case $ac_file in
-  - | *:- | *:-:* ) # input from stdin
-	cat >$tmp/stdin
-	ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  * )   ac_file_in=$ac_file.in ;;
-  esac
-
-  test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-
-  # First look for the input files in the build tree, otherwise in the
-  # src tree.
-  ac_file_inputs=`IFS=:
-    for f in $ac_file_in; do
-      case $f in
-      -) echo $tmp/stdin ;;
-      [\\/$]*)
-	 # Absolute (can't be DOS-style, as IFS=:)
-	 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  esac \
+  || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
    { (exit 1); exit 1; }; }
-	 # Do quote $f, to prevent DOS paths from being IFS'd.
-	 echo "$f";;
-      *) # Relative
-	 if test -f "$f"; then
-	   # Build tree
-	   echo "$f"
-	 elif test -f "$srcdir/$f"; then
-	   # Source tree
-	   echo "$srcdir/$f"
-	 else
-	   # /dev/null tree
-	   { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 fi;;
-      esac
-    done` || { (exit 1); exit 1; }
-  # Remove the trailing spaces.
-  sed 's/[	 ]*$//' $ac_file_inputs >$tmp/in
-
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h.  The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status.  Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 (][^	 (]*\)\(([^)]*)\)[	 ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 ][^	 ]*\)[	 ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless.  Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments.  This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[	 ]*#[	 ]*undef[	 ][	 ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
-
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo '  if grep "^[	 ]*#[	 ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo '  :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
-do
-  # Write a limited-size here document to $tmp/defines.sed.
-  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
-  # Speed up: don't consider the non `#define' lines.
-  echo '/^[	 ]*#[	 ]*define/!b' >>$CONFIG_STATUS
-  # Work around the forget-to-reset-the-flag bug.
-  echo 't clr' >>$CONFIG_STATUS
-  echo ': clr' >>$CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
-  echo 'CEOF
-  sed -f $tmp/defines.sed $tmp/in >$tmp/out
-  rm -f $tmp/in
-  mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
-  rm -f conftest.defines
-  mv conftest.tail conftest.defines
-done
-rm -f conftest.defines
-echo '  fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
-
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
-  # Write a limited-size here document to $tmp/undefs.sed.
-  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
-  # Speed up: don't consider the non `#undef'
-  echo '/^[	 ]*#[	 ]*undef/!b' >>$CONFIG_STATUS
-  # Work around the forget-to-reset-the-flag bug.
-  echo 't clr' >>$CONFIG_STATUS
-  echo ': clr' >>$CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
-  echo 'CEOF
-  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
-  rm -f $tmp/in
-  mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
-  rm -f conftest.undefs
-  mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-  # Let's still pretend it is `configure' which instantiates (i.e., don't
-  # use $as_me), people would be surprised to read:
-  #    /* config.h.  Generated by config.status.  */
-  if test x"$ac_file" = x-; then
-    echo "/* Generated by configure.  */" >$tmp/config.h
-  else
-    echo "/* $ac_file.  Generated by configure.  */" >$tmp/config.h
-  fi
-  cat $tmp/in >>$tmp/config.h
-  rm -f $tmp/in
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
   if test x"$ac_file" != x-; then
-    if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
-      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+    } >"$tmp/config.h" \
+      || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
+    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
     else
-      ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-      { if $as_mkdir_p; then
-    mkdir -p "$ac_dir"
-  else
-    as_dir="$ac_dir"
-    as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-    done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
-   { (exit 1); exit 1; }; }; }
-
-      rm -f $ac_file
-      mv $tmp/config.h $ac_file
+      rm -f "$ac_file"
+      mv "$tmp/config.h" "$ac_file" \
+	|| { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
+$as_echo "$as_me: error: could not create $ac_file" >&2;}
+   { (exit 1); exit 1; }; }
     fi
   else
-    cat $tmp/config.h
-    rm -f $tmp/config.h
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+      || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5
+$as_echo "$as_me: error: could not create -" >&2;}
+   { (exit 1); exit 1; }; }
   fi
-# Compute $ac_file's index in $config_headers.
+# Compute "$ac_file"'s index in $config_headers.
 _am_stamp_count=1
 for _am_header in $config_headers :; do
   case $_am_header in
-    $ac_file | $ac_file:* )
+    "$ac_file" | "$ac_file":* )
       break ;;
     * )
       _am_stamp_count=`expr $_am_stamp_count + 1` ;;
   esac
 done
-echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null ||
-$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X$ac_file : 'X\(//\)[^/]' \| \
-	 X$ac_file : 'X\(//\)$' \| \
-	 X$ac_file : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X$ac_file |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`/stamp-h$_am_stamp_count
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_COMMANDS section.
-#
-for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
-  ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
-  ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
-  ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
-$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_dest" : 'X\(//\)[^/]' \| \
-	 X"$ac_dest" : 'X\(//\)$' \| \
-	 X"$ac_dest" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$ac_dest" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-  { if $as_mkdir_p; then
-    mkdir -p "$ac_dir"
-  else
-    as_dir="$ac_dir"
-    as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-    done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
-   { (exit 1); exit 1; }; }; }
-
-  ac_builddir=.
-
-if test "$ac_dir" != .; then
-  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
-  # A "../" for each directory in $ac_dir_suffix.
-  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
-  ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
-  .)  # No --srcdir option.  We are building in place.
-    ac_srcdir=.
-    if test -z "$ac_top_builddir"; then
-       ac_top_srcdir=.
-    else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
-    fi ;;
-  [\\/]* | ?:[\\/]* )  # Absolute path.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir ;;
-  *) # Relative path.
-    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
+echo "timestamp for "$ac_file"" >`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
 
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
-  case "$ac_dir" in
-  .) ac_abs_builddir=`pwd`;;
-  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
-  *) ac_abs_builddir=`pwd`/"$ac_dir";;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
-  case ${ac_top_builddir}. in
-  .) ac_abs_top_builddir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
-  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
-  case $ac_srcdir in
-  .) ac_abs_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
-  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
-  case $ac_top_srcdir in
-  .) ac_abs_top_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
-  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
-  esac;;
-esac
+  :C)  { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
 
 
-  { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
-echo "$as_me: executing $ac_dest commands" >&6;}
-  case $ac_dest in
-    depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
   # 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.
@@ -8510,18 +9555,29 @@ echo "$as_me: executing $ac_dest commands" >&6;}
   # each Makefile.in and add a new line on top of each file to say so.
   # So let's grep whole file.
   if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
-    dirpart=`(dirname "$mf") 2>/dev/null ||
+    dirpart=`$as_dirname -- "$mf" ||
 $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$mf" : 'X\(//\)[^/]' \| \
 	 X"$mf" : 'X\(//\)$' \| \
-	 X"$mf" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$mf" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+	 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
   else
     continue
   fi
@@ -8543,59 +9599,90 @@ echo X"$mf" |
        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
     # Make sure the directory exists.
     test -f "$dirpart/$file" && continue
-    fdir=`(dirname "$file") 2>/dev/null ||
+    fdir=`$as_dirname -- "$file" ||
 $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$file" : 'X\(//\)[^/]' \| \
 	 X"$file" : 'X\(//\)$' \| \
-	 X"$file" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-    { if $as_mkdir_p; then
-    mkdir -p $dirpart/$fdir
-  else
-    as_dir=$dirpart/$fdir
+	 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+    { as_dir=$dirpart/$fdir
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
     as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_dir" : 'X\(//\)[^/]' \| \
 	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
     done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5
-echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+$as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
    { (exit 1); exit 1; }; }; }
-
     # echo "creating $dirpart/$file"
     echo '# dummy' > "$dirpart/$file"
   done
 done
  ;;
+
   esac
-done
-_ACEOF
+done # for ac_tag
 
-cat >>$CONFIG_STATUS <<\_ACEOF
 
 { (exit 0); exit 0; }
 _ACEOF
 chmod +x $CONFIG_STATUS
 ac_clean_files=$ac_clean_files_save
 
+test $ac_write_fail = 0 ||
+  { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+
 
 # configure is writing to config.log, and then calls config.status.
 # config.status does its own redirection, appending to config.log.
@@ -8617,6 +9704,10 @@ if test "$no_create" != yes; then
   # would make configure fail if this is the last instruction.
   $ac_cs_success || { (exit 1); exit 1; }
 fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
 
 # dump some configuration confirmations
 echo \
diff --git a/configure.ac b/configure.ac
index b8a0b9b..b9aa5de 100755
--- a/configure.ac
+++ b/configure.ac
@@ -2,9 +2,10 @@ m4_include([ax_boost_base.m4])
 m4_include([ax_boost_thread.m4])
 m4_include([ax_bam.m4])
 m4_include([ax_check_zlib.m4])
+m4_include([ax_check_eigen.m4])
 
 define([svnversion], esyscmd([sh -c "svnversion|tr -d '\n'"]))dnl
-AC_INIT([cufflinks], [1.3.0], [cole at cs.umd.edu])
+AC_INIT([cufflinks], [2.0.0], [cole at cs.umd.edu])
 AC_DEFINE(SVN_REVISION, "svnversion", [SVN Revision])
 
 AC_CONFIG_SRCDIR([config.h.in])
@@ -30,11 +31,11 @@ AC_PROG_MAKE_SET
 AC_PROG_RANLIB
 AC_PROG_INSTALL
 AM_PATH_PYTHON([2.4])
-AX_BOOST_BASE([1.38.0])
+AX_BOOST_BASE([1.47.0])
 AX_BAM
 AX_BOOST_THREAD
 AX_CHECK_ZLIB()
-
+AX_EIGEN
 # Checks for header files.
 AC_CHECK_HEADERS([stdlib.h string.h unistd.h])
 
@@ -45,6 +46,7 @@ AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_CHECK_TYPES([ptrdiff_t])
 
+
 # Checks for library functions.
 #AC_FUNC_FORK
 #AC_CHECK_FUNCS([floor memmove pow regcomp sqrt strchr strcspn strspn strstr])
@@ -54,7 +56,7 @@ AC_CANONICAL_HOST
 
 # set CFLAGS and CXXFLAGS
 user_CFLAGS=${CFLAGS}
-generic_CFLAGS="-Wall -Wno-strict-aliasing -g -gdwarf-2 -Wuninitialized"
+generic_CFLAGS="-Wall -Wno-strict-aliasing -g -gdwarf-2 -Wunused -Wuninitialized"
 ext_CFLAGS=""
 debug_CFLAGS=""
 #echo "${host_cpu}-${host_os}"
@@ -100,7 +102,7 @@ AC_ARG_ENABLE(profiling,      [  --enable-profiling        enable profiling with
 	  
 CFLAGS="${generic_CFLAGS} ${ext_CFLAGS} ${user_CFLAGS} ${debug_CFLAGS} ${OPENMP_CFLAGS}"
 CXXFLAGS="$CFLAGS"
-CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS $BAM_CPPFLAGS"
+CXXFLAGS="${CXXFLAGS} ${BOOST_CPPFLAGS} ${BAM_CPPFLAGS} ${EIGEN_CPPFLAGS}"
 LDFLAGS="$ext_LDFLAGS"
 
 # Checks for structures/functions that can be used to determine system memory
diff --git a/make_bin.sh b/make_bin.sh
index 61ba726..3ac7bda 100755
--- a/make_bin.sh
+++ b/make_bin.sh
@@ -3,10 +3,10 @@
 #simple script to pack up a precompiled binary package, with the boost thread
 # library statically linked in.
 
-echo "packing up $1.tar.gz, using boost in $2, linking against $3 and using BAM in $4"
+echo "packing up $1.tar.gz, using boost in $2, linking against $3 and using BAM in $4, using Eigen in $5"
 mkdir $1
 make clean
-./configure --enable-intel64 --with-boost=$2 --with-boost-thread=$3 --with-bam=$4
+./configure --enable-intel64 --with-boost=$2 --with-boost-thread=$3 --with-bam=$4 --with-eigen=$5
 make
 cp src/cufflinks $1
 cp src/cuffcompare $1
diff --git a/src/GBase.cpp b/src/GBase.cpp
index efbebea..b54cecb 100644
--- a/src/GBase.cpp
+++ b/src/GBase.cpp
@@ -3,12 +3,12 @@
 #include <ctype.h>
 #include <sys/stat.h>
 
-#ifndef S_ISDIR
-#define S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)
-#endif
-
-#ifndef S_ISREG
-#define S_ISREG(mode)  (((mode) & S_IFMT) == S_IFREG)
+#ifndef S_ISDIR
+#define S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(mode)  (((mode) & S_IFMT) == S_IFREG)
 #endif
 
 static char msg[4069];
@@ -163,23 +163,40 @@ char* Gstrdup(const char* sfrom, const char* sto) {
   return copy;
   }
 
-int Gstrcmp(char* a, char* b) {
+int Gstrcmp(const char* a, const char* b, int n) {
  if (a==NULL || b==NULL) {
    return a==NULL ? -1 : 1;
    }
- else return strcmp(a,b);
+ else {
+   if (n<0) return strcmp(a,b);
+       else return strncmp(a,b,n);
+ }
+
 }
 
-int Gstricmp(const char* a, const char* b) {
+int Gstricmp(const char* a, const char* b, int n) {
  if (a==NULL || b==NULL) return a==NULL ? -1 : 1;
  register int ua, ub;
- while ((*a!=0) && (*b!=0)) {
-  ua=tolower((unsigned char)*a);
-  ub=tolower((unsigned char)*b);
-  a++;b++;
-  if (ua!=ub) return ua < ub ? -1 : 1;
+ if (n<0) {
+   while ((*a!=0) && (*b!=0)) {
+    ua=tolower((unsigned char)*a);
+    ub=tolower((unsigned char)*b);
+    a++;b++;
+    if (ua!=ub) return ua < ub ? -1 : 1;
+    }
+    return (*a == 0) ? ( (*b == 0) ? 0 : -1 ) : 1 ;
+  }
+ else {
+   while (n && (*a!=0) && (*b!=0)) {
+    ua=tolower((unsigned char)*a);
+    ub=tolower((unsigned char)*b);
+    a++;b++;n--;
+    if (ua!=ub) return ua < ub ? -1 : 1;
+    }
+    //return (*a == 0) ? ( (*b == 0) ? 0 : -1 ) : 1 ;
+   if (n==0) return 0;
+   else { return (*a == 0) ? ( (*b == 0) ? 0 : -1 ) : 1 ; }
   }
-  return (*a == 0) ? ( (*b == 0) ? 0 : -1 ) : 1 ;
 }
 
 int strsplit(char* str, char** fields, int maxfields, const char* delim) {
diff --git a/src/GBase.h b/src/GBase.h
index 5e5dacf..2fc8f19 100644
--- a/src/GBase.h
+++ b/src/GBase.h
@@ -25,6 +25,9 @@
   #define CHPATHSEP '\\'
   #undef off_t
   #define off_t int64_t
+  #ifndef popen
+   #define popen _popen
+  #endif
   #ifdef _fseeki64
     #define fseeko(stream, offset, origin) _fseeki64(stream, offset, origin)
   #else
@@ -61,6 +64,8 @@
 
 typedef int32_t int32;
 typedef uint32_t uint32;
+typedef int16_t int16;
+typedef uint16_t uint16;
 
 typedef unsigned char uchar;
 typedef unsigned char byte;
@@ -167,59 +172,19 @@ inline int Gintcmp(int a, int b) {
   return a-b;
 }
 
-int Gstrcmp(char* a, char* b);
+int Gstrcmp(const char* a, const char* b, int n=-1);
 //same as strcmp but doesn't crash on NULL pointers
 
-int Gstricmp(const char* a, const char* b);
-
-inline void swap(int &arg1, int &arg2){
- //arg1 ^= arg2;
- //arg2 ^= arg1;
- //arg1 ^= arg2;
- register int swp=arg1;
- arg1=arg2; arg2=swp;
- }
-
-inline void swap(char* &arg1, char* &arg2){ //swap pointers!
- register char* swp=arg1;
- arg1=arg2; arg2=swp;
- }
-
-inline void swap(uint &arg1, uint &arg2) {
-  register uint swp=arg1;
-  arg1=arg2; arg2=swp;
-  }
-
-inline void swap(short &arg1, short &arg2) {
-  register short swp=arg1;
-  arg1=arg2; arg2=swp;
-  }
-
-inline void swap(unsigned short &arg1, unsigned short &arg2) {
-  register unsigned short swp=arg1;
-  arg1=arg2; arg2=swp;
-  }
-
-inline void swap(long &arg1, long &arg2) {
-  register long swp=arg1;
-  arg1=arg2; arg2=swp;
-  }
-
-inline void swap(unsigned long &arg1, unsigned long &arg2) {
-  register unsigned long swp=arg1;
-  arg1=arg2; arg2=swp;
-  }
-
-
-inline void swap(char &arg1, char &arg2) {
-  register char swp=arg1;
-  arg1=arg2; arg2=swp;
-  }
-
-inline void swap(unsigned char &arg1, unsigned char &arg2) {
-  register unsigned char swp=arg1;
-  arg1=arg2; arg2=swp;
-  }
+int Gstricmp(const char* a, const char* b, int n=-1);
+
+//basic swap template function
+template<class T> void Gswap(T& lhs, T& rhs) {
+ //register T tmp=lhs;
+ T tmp=lhs; //requires copy operator
+ lhs=rhs;
+ rhs=tmp;
+}
+
 
 /**************** Memory management ***************************/
 
@@ -330,7 +295,7 @@ class GSeg {
      }
 
   bool overlap(uint s, uint e) {
-     if (s>e) { swap(s,e); }
+     if (s>e) { Gswap(s,e); }
      //return start<s ? (s<=end) : (start<=e);
      return (start<=e && end>=s);
      }
@@ -347,7 +312,7 @@ class GSeg {
         }
      }
   int overlapLen(uint rstart, uint rend) {
-     if (rstart>rend) { swap(rstart,rend); }
+     if (rstart>rend) { Gswap(rstart,rend); }
      if (start<rstart) {
         if (rstart>end) return 0;
         return (rend>end) ? end-rstart+1 : rend-rstart+1;
@@ -369,9 +334,6 @@ class GSeg {
   bool operator==(GSeg& d){
       return (start==d.start && end==d.end);
       }
-  bool operator>(GSeg& d){
-     return (start==d.start)?(end>d.end):(start>d.start);
-     }
   bool operator<(GSeg& d){
      return (start==d.start)?(end<d.end):(start<d.start);
      }
diff --git a/src/GFaSeqGet.cpp b/src/GFaSeqGet.cpp
index 6070667..ca722ca 100644
--- a/src/GFaSeqGet.cpp
+++ b/src/GFaSeqGet.cpp
@@ -50,11 +50,13 @@ GFaSeqGet::GFaSeqGet(const char* faname, uint seqlen, off_t fseqofs, int l_len,
 }
 
 GFaSeqGet::GFaSeqGet(FILE* f, off_t fofs, bool validate) {
- if (f==NULL) GError("Error (GFaSeqGet) : null file handle!\n");
- seq_len=0;
- fh=f;
- initialParse(fofs, validate);
- lastsub=new GSubSeq();
+  fname=NULL;
+  fseqstart=0;
+  if (f==NULL) GError("Error (GFaSeqGet) : null file handle!\n");
+  seq_len=0;
+  fh=f;
+  initialParse(fofs, validate);
+  lastsub=new GSubSeq();
 }
 
 void GFaSeqGet::initialParse(off_t fofs, bool checkall) {
@@ -228,7 +230,7 @@ const char* GFaSeqGet::subseq(uint cstart, int& clen) {
 }
 
 char* GFaSeqGet::copyRange(uint cstart, uint cend, bool revCmpl, bool upCase) {
-  if (cstart>cend) { swap(cstart, cend); }
+  if (cstart>cend) { Gswap(cstart, cend); }
   int clen=cend-cstart+1;
   const char* gs=subseq(cstart, clen);
   if (gs==NULL) return NULL;
@@ -256,7 +258,7 @@ const char* GFaSeqGet::loadsubseq(uint cstart, int& clen) {
   int lineofs = seqofs % line_len;
   off_t fstart=fseqstart + (startlno*line_blen);
   fstart+=lineofs;
-  
+
   fseeko(fh, fstart, SEEK_SET);
   int toread=clen;
   int maxlen=(seq_len>0)? seq_len-cstart+1 : MAX_FASUBSEQ ;
@@ -310,7 +312,7 @@ const char* GFaSeqGet::loadsubseq(uint cstart, int& clen) {
     }
   //lastsub->sqlen+=sublen;
   clen=sublen;
-  
+
   return (const char*)seqp;
   }
 
diff --git a/src/GFaSeqGet.h b/src/GFaSeqGet.h
index b9ad618..2ecdbb7 100644
--- a/src/GFaSeqGet.h
+++ b/src/GFaSeqGet.h
@@ -1,6 +1,5 @@
 #ifndef GFASEQGET_H
 #define GFASEQGET_H
-
 #include "GList.hh"
 
 #define MAX_FASUBSEQ 0x20000000
@@ -81,7 +80,7 @@ class GFaSeqGet {
   const char* subseq(uint cstart, int& clen);
   const char* getRange(uint cstart=1, uint cend=0) {
       if (cend==0) cend=(seq_len>0)?seq_len : MAX_FASUBSEQ;
-      if (cstart>cend) { swap(cstart, cend); }
+      if (cstart>cend) { Gswap(cstart, cend); }
       int clen=cend-cstart+1;
       //int rdlen=clen;
       return subseq(cstart, clen);
diff --git a/src/GHash.hh b/src/GHash.hh
index 4d7fc51..333c67e 100644
--- a/src/GHash.hh
+++ b/src/GHash.hh
@@ -5,6 +5,7 @@
 #ifndef GHash_HH
 #define GHash_HH
 #include "GBase.h"
+
 /**
 * This class maintains a fast-access hash table of entities
 * indexed by a character string (essentially, maps strings to pointers)
@@ -132,7 +133,9 @@ public:
 // Construct empty hash
 template <class OBJ> GHash<OBJ>::GHash(GFreeProc* freeProc) {
   GMALLOC(hash, sizeof(GHashEntry)*DEF_HASH_SIZE);
+  fCurrentEntry=-1;
   fFreeProc=freeProc;
+  lastkeyptr=NULL;
   for (uint i=0; i<DEF_HASH_SIZE; i++)
          hash[i].hash=-1; //this will be an indicator for 'empty' entries
   fCapacity=DEF_HASH_SIZE;
@@ -141,6 +144,8 @@ template <class OBJ> GHash<OBJ>::GHash(GFreeProc* freeProc) {
 
 template <class OBJ> GHash<OBJ>::GHash(bool doFree) {
   GMALLOC(hash, sizeof(GHashEntry)*DEF_HASH_SIZE);
+  fCurrentEntry=-1;
+  lastkeyptr=NULL;
   fFreeProc = (doFree)?&DefaultFreeProc : NULL;
   for (uint i=0; i<DEF_HASH_SIZE; i++)
          hash[i].hash=-1; //this will be an indicator for 'empty' entries
diff --git a/src/GList.hh b/src/GList.hh
index 2622725..3a4521d 100644
--- a/src/GList.hh
+++ b/src/GList.hh
@@ -45,9 +45,9 @@ template <class OBJ> class GVec {
     int fCount;
     int fCapacity;
   public:
-    GVec(int init_capacity=20);
+    GVec(int init_capacity=2);
     GVec(GVec<OBJ>& array); //copy constructor
-    const GVec<OBJ>& operator=(GVec& array); //copy operator
+    const GVec<OBJ>& operator=(GVec<OBJ>& array); //copy operator
     virtual ~GVec();
     void idxInsert(int idx, OBJ& item);
     void Grow();
@@ -65,6 +65,14 @@ template <class OBJ> class GVec {
           TEST_INDEX(i);
           return fArray[i];
           }
+    OBJ& Last() {
+         TEST_INDEX(fCount-1);
+         return fArray[fCount-1];
+         }
+    OBJ& First() {
+         TEST_INDEX(0);
+         return fArray[0];
+         }
     void Clear();
     void Insert(int idx, OBJ* item);
     void Delete(int index);
@@ -85,8 +93,8 @@ template <class OBJ> class GArray:public GVec<OBJ> {
     bool fUnique;
     static int DefaultCompareProc(OBJ& item1, OBJ& item2) {
       //the comparison operators MUST be defined for OBJ class!
-      if ( item1 > item2) return 1;
-        else return (item2 > item1) ? -1 : 0 ;
+      if ( item2 < item1) return 1;
+        else return (item1 < item2) ? -1 : 0 ;
       }
   public:
     typedef int CompareProc(OBJ& item1, OBJ& item2);
@@ -98,7 +106,7 @@ template <class OBJ> class GArray:public GVec<OBJ> {
     GArray(bool sorted, bool unique=false);
     GArray(int init_capacity, bool sorted, bool unique=false);
     GArray(GArray<OBJ>& array); //copy constructor
-    const GArray<OBJ>& operator=(GArray& array);
+    const GArray<OBJ>& operator=(GArray<OBJ>& array);
     //~GArray();
     //assignment operator
     void setSorted(CompareProc* cmpFunc);
@@ -142,10 +150,10 @@ template <class OBJ> class GPVec {
       delete (OBJ*)item;
       }
     virtual ~GPVec();
-    GPVec(int init_capacity=10, bool free_elements=true); //also the default constructor
+    GPVec(int init_capacity=2, bool free_elements=true); //also the default constructor
     GPVec(GPVec<OBJ>& list); //copy constructor?
     GPVec(GPVec<OBJ>* list); //kind of a copy constructor
-    const GPVec<OBJ>& operator=(GPVec& list);
+    const GPVec<OBJ>& operator=(GPVec<OBJ>& list);
     OBJ* Get(int i);
     OBJ* operator[](int i) { return this->Get(i); }
     void Reverse(); //reverse pointer array; WARNING: will break the sort order if sorted!
@@ -188,9 +196,9 @@ template <class OBJ> class GList:public GPVec<OBJ> {
     bool fUnique;
     GCompareProc* fCompareProc; //a pointer to a Compare function
     static int DefaultCompareProc(const pointer item1, const pointer item2) {
-      //the comparison operators MUST be defined for OBJ class!
-      if (*((OBJ*)item1) > *((OBJ*)item2)) return 1;
-        else if (*((OBJ*)item2) > *((OBJ*)item1)) return -1;
+      //operator< MUST be defined for OBJ class!
+      if (*((OBJ*)item2) < *((OBJ*)item1)) return 1;
+        else if (*((OBJ*)item1) < *((OBJ*)item2)) return -1;
                                              else return  0;
       }
     void QuickSort(int L, int R);
@@ -204,7 +212,7 @@ template <class OBJ> class GList:public GPVec<OBJ> {
     GList(int init_capacity, bool sorted, bool free_elements=true, bool beUnique=false);
     GList(GList<OBJ>& list); //copy constructor?
     GList(GList<OBJ>* list); //kind of a copy constructor
-    const GList<OBJ>& operator=(GList& list);
+    const GList<OBJ>& operator=(GList<OBJ>& list);
     //void Clear();
     //~GList();
     void setSorted(GCompareProc* compareProc);
@@ -440,10 +448,13 @@ template <class OBJ> void GArray<OBJ>::setSorted(CompareProc* cmpFunc) {
 
 template <class OBJ> void GVec<OBJ>::Grow() {
  int delta;
- if (fCapacity > 64) delta = fCapacity/4;
-   else if (fCapacity > 8) delta = 16;
-                      else delta = 4;
-  setCapacity(fCapacity + delta);
+ if (fCapacity > 64 ) {
+   delta = (fCapacity > 0xFFF) ? 0x100 : (fCapacity>>4);
+ }
+ else {
+   delta = (fCapacity>8) ? (fCapacity>>2) : 1 ;
+ }
+ setCapacity(fCapacity + delta);
 }
 
 template <class OBJ> void GVec<OBJ>::Reverse() {
@@ -459,9 +470,17 @@ template <class OBJ> void GVec<OBJ>::Reverse() {
 
 template <class OBJ> void GVec<OBJ>::Grow(int idx, OBJ& item) {
  int delta;
+ /*
  if (fCapacity > 64) delta = fCapacity/4;
    else if (fCapacity > 8) delta = 16;
                       else delta = 4;
+ */
+ if (fCapacity > 64 ) {
+   delta = (fCapacity > 0xFFF) ? 0x100 : (fCapacity>>4);
+ }
+ else {
+   delta = (fCapacity>8) ? (fCapacity>>2) : 1 ;
+ }
  int NewCapacity=fCapacity+delta;
   if (NewCapacity <= fCount || NewCapacity >= MAXLISTSIZE)
     GError(SLISTCAPACITY_ERR, NewCapacity);
@@ -984,17 +1003,23 @@ template <class OBJ> void GList<OBJ>::setSorted(GCompareProc* compareProc) {
 
 template <class OBJ> void GPVec<OBJ>::Grow() {
  int delta;
- if (fCapacity > 64) delta = fCapacity/4;
-   else if (fCapacity > 8) delta = 16;
-                      else delta = 4;
+ if (fCapacity > 64 ) {
+   delta = (fCapacity > 0xFFF) ? 0x100 : (fCapacity>>4);
+ }
+ else {
+   delta = (fCapacity>8) ? (fCapacity>>2) : 1 ;
+ }
   setCapacity(fCapacity + delta);
 }
 
 template <class OBJ> void GPVec<OBJ>::Grow(int idx, OBJ* newitem) {
  int delta;
- if (fCapacity > 64) delta = fCapacity/4;
-   else if (fCapacity > 8) delta = 16;
-                      else delta = 4;
+ if (fCapacity > 64 ) {
+   delta = (fCapacity > 0xFFF) ? 0x100 : (fCapacity>>4);
+ }
+ else {
+   delta = (fCapacity>8) ? (fCapacity>>2) : 1 ;
+ }
  // setCapacity(fCapacity + delta);
  int NewCapacity=fCapacity+delta;
   if (NewCapacity <= fCount || NewCapacity > MAXLISTSIZE)
diff --git a/src/GStr.cpp b/src/GStr.cpp
index f7ab2ec..4613fa2 100644
--- a/src/GStr.cpp
+++ b/src/GStr.cpp
@@ -106,29 +106,37 @@ bool operator>(const char *s1, const GStr& s2) {
 
 GStr::GStr():my_data(&null_data) {
  fTokenDelimiter=NULL;
+ fTokenizeMode=tkCharSet;
  fLastTokenStart=0;
  readbuf=NULL;
+ readbufsize=0;
  }
 
 GStr::GStr(const GStr& s): my_data(&null_data){
  fTokenDelimiter=NULL;
+ fTokenizeMode=tkCharSet;
  fLastTokenStart=0;
  readbuf=NULL;
+ readbufsize=0;
  replace_data(s.my_data);
  }
 
 GStr::GStr(const char *s): my_data(&null_data) {
   fTokenDelimiter=NULL;
+  fTokenizeMode=tkCharSet;
   fLastTokenStart=0;
   readbuf=NULL;
+  readbufsize=0;
   my_data=new_data(s);
   my_data->ref_count = 1;
  }
 
 GStr::GStr(const int i): my_data(&null_data) {
  fTokenDelimiter=NULL;
+ fTokenizeMode=tkCharSet;
  fLastTokenStart=0;
  readbuf=NULL;
+ readbufsize=0;
  char buf[20];
  sprintf(buf,"%d",i);
  const int len = ::strlen(buf);
@@ -138,8 +146,10 @@ GStr::GStr(const int i): my_data(&null_data) {
 
 GStr::GStr(const double f): my_data(&null_data) {
  fTokenDelimiter=NULL;
+ fTokenizeMode=tkCharSet;
  fLastTokenStart=0;
  readbuf=NULL;
+ readbufsize=0;
  char buf[20];
  sprintf(buf,"%f",f);
  const int len = ::strlen(buf);
@@ -149,8 +159,10 @@ GStr::GStr(const double f): my_data(&null_data) {
 
 GStr::GStr(char c, int n): my_data(&null_data) {
   fTokenDelimiter=NULL;
+  fTokenizeMode=tkCharSet;
   fLastTokenStart=0;
   readbuf=NULL;
+  readbufsize=0;
   replace_data(n); ::memset(chrs(), c, n);
   }
 
@@ -1089,8 +1101,10 @@ GStr GStr::splitr(char c) {
 
 void GStr::startTokenize(const char* delimiter, enTokenizeMode tokenizemode) {
  GFREE(fTokenDelimiter);
- GMALLOC(fTokenDelimiter,strlen(delimiter)+1);
- strcpy(fTokenDelimiter, delimiter);
+ if (delimiter) {
+    GMALLOC(fTokenDelimiter,strlen(delimiter)+1);
+    strcpy(fTokenDelimiter, delimiter);
+    }
  fLastTokenStart=0;
  fTokenizeMode=tokenizemode;
 }
diff --git a/src/GStr.h b/src/GStr.h
index 5a6d8fa..e2a89e7 100644
--- a/src/GStr.h
+++ b/src/GStr.h
@@ -26,7 +26,7 @@ class GStr {
         friend bool operator>(const char* s1, const GStr& s2);
         friend bool operator>=(const char* s1, const GStr& s2);
         friend bool operator!=(const char* s1, const GStr& s2);
-        friend void swap(GStr& s1, GStr& s2);
+        friend void Gswap(GStr& s1, GStr& s2);
     public:
         GStr();
         GStr(const GStr& s);
@@ -97,7 +97,7 @@ class GStr {
         GStr& tr(const char* from, const char* to=NULL);
         //number of occurences of a char in the string:
         int count(char c);
-        void startTokenize(const char* delimiter, enTokenizeMode tokenizemode=tkCharSet);
+        void startTokenize(const char* delimiter=" \t\n", enTokenizeMode tokenizemode=tkCharSet);
         bool nextToken(GStr& token);
         int asInt(int base=10);
         double asReal();
@@ -197,7 +197,6 @@ inline const char *GStr::text() const {
  return my_data->chars;
  }
 
-
 inline bool operator>=(const char *s1, const GStr& s2) {
  return (strcmp(s1, s2.chars()) >= 0);
  }
@@ -206,10 +205,9 @@ inline bool operator!=(const char *s1, const GStr& s2) {
  return (strcmp(s1, s2.chars()) != 0);
  }
 
-inline void swap(GStr& s1, GStr& s2) {
+inline void Gswap(GStr& s1, GStr& s2) {
  GStr::Data *tmp = s1.my_data; s1.my_data = s2.my_data;
  s2.my_data = tmp;
  }
 
-
 #endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 88ded9b..5e817f9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -100,6 +100,7 @@ noinst_HEADERS = \
     locfit/vari.hpp \
     replicates.h \
     multireads.h \
+    rounding.h \
 	common.h 
 
 noinst_LIBRARIES = libcufflinks.a libgc.a
diff --git a/src/Makefile.in b/src/Makefile.in
index 362d5c1..dfc85f4 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -50,7 +50,8 @@ DIST_COMMON = $(dist_bin_SCRIPTS) $(noinst_HEADERS) \
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/ax_boost_base.m4 \
 	$(top_srcdir)/ax_boost_thread.m4 $(top_srcdir)/ax_bam.m4 \
-	$(top_srcdir)/ax_check_zlib.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/ax_check_zlib.m4 $(top_srcdir)/ax_check_eigen.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -175,7 +176,9 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+EIGEN_CPPFLAGS = @EIGEN_CPPFLAGS@
 EXEEXT = @EXEEXT@
+GREP = @GREP@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -206,8 +209,6 @@ VERSION = @VERSION@
 ZLIB = @ZLIB@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
@@ -224,25 +225,32 @@ build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
 datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
 exec_prefix = @exec_prefix@
 host = @host@
 host_alias = @host_alias@
 host_cpu = @host_cpu@
 host_os = @host_os@
 host_vendor = @host_vendor@
+htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
+localedir = @localedir@
 localstatedir = @localstatedir@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
 pkgpyexecdir = @pkgpyexecdir@
 pkgpythondir = @pkgpythondir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
+psdir = @psdir@
 pyexecdir = @pyexecdir@
 pythondir = @pythondir@
 sbindir = @sbindir@
@@ -339,6 +347,7 @@ noinst_HEADERS = \
     locfit/vari.hpp \
     replicates.h \
     multireads.h \
+    rounding.h \
 	common.h 
 
 noinst_LIBRARIES = libcufflinks.a libgc.a
diff --git a/src/abundances.cpp b/src/abundances.cpp
index d8f81d0..eb784da 100644
--- a/src/abundances.cpp
+++ b/src/abundances.cpp
@@ -35,15 +35,20 @@
 #include "replicates.h"
 #include "sampling.h"
 #include "jensen_shannon.h"
+#include "rounding.h"
 
 
+#include <boost/random/negative_binomial_distribution.hpp>
 
 
+#include <Eigen/Dense>
+//using Eigen::MatrixXd;
+
 
 //#define USE_LOG_CACHE
 
-void compute_compatibilities(vector<shared_ptr<Abundance> >& transcripts,
-						 const vector<MateHit>& alignments,
+void compute_compatibilities(const vector<shared_ptr<Abundance> >& transcripts,
+                             const vector<MateHit>& alignments,
 							 vector<vector<char> >& compatibilities)
 {
 	int M = alignments.size();
@@ -73,22 +78,22 @@ void compute_compatibilities(vector<shared_ptr<Abundance> >& transcripts,
 
 AbundanceGroup::AbundanceGroup(const vector<shared_ptr<Abundance> >& abundances,
                                const ublas::matrix<double>& gamma_covariance,
-                               const ublas::matrix<double>& gamma_bootstrap_covariance,
                                const ublas::matrix<double>& iterated_exp_count_covariance,
                                const ublas::matrix<double>& count_covariance,
                                const ublas::matrix<double>& fpkm_covariance,
                                const long double max_mass_variance,
-                               const set<shared_ptr<ReadGroupProperties const> >& rg_props) :
+                               const set<shared_ptr<ReadGroupProperties const> >& rg_props,
+                               const vector<Eigen::VectorXd>& assigned_count_samples) :
     _abundances(abundances), 
     _iterated_exp_count_covariance(iterated_exp_count_covariance),
     _count_covariance(count_covariance),
     _fpkm_covariance(fpkm_covariance),
     _gamma_covariance(gamma_covariance),
-    _gamma_bootstrap_covariance(gamma_bootstrap_covariance),
     _max_mass_variance(max_mass_variance),
     _salient_frags(0.0),
     _total_frags(0.0),
-    _read_group_props(rg_props)
+    _read_group_props(rg_props),
+    _assigned_count_samples(assigned_count_samples)
 {
     // Calling calculate_FPKM_covariance() also estimates cross-replicate
     // count variances
@@ -98,38 +103,36 @@ AbundanceGroup::AbundanceGroup(const vector<shared_ptr<Abundance> >& abundances,
     {
         for (size_t j = 0; j < _fpkm_covariance.size2(); ++j)
         {
+            assert (!isnan(_fpkm_covariance(i,j)) && !isinf(_fpkm_covariance(i,j)));
             fpkm_var += _fpkm_covariance(i,j);
         }
     }
     
-    ublas::matrix<double> test = _count_covariance;
-    double ret = cholesky_factorize(test);
-    if (ret != 0)
-    {
-        //fprintf(stderr, "Warning: total count covariance is not positive definite!\n");
-        for (size_t j = 0; j < _abundances.size(); ++j)
-        {
-            _abundances[j]->status(NUMERIC_FAIL);
-        }
-    }
-
     _FPKM_variance = fpkm_var;
     
-    if (final_est_run && library_type != "transfrags")
+    if (FPKM() > 0 && final_est_run && library_type != "transfrags")
     {
-        test = _fpkm_covariance;
-        ret = cholesky_factorize(test);
+        
+        ublas::matrix<double> test = _fpkm_covariance;
+        double ret = cholesky_factorize(test);
         if (ret != 0 || (_FPKM_variance < 0 && status() == NUMERIC_OK))
         {
-            //fprintf(stderr, "Warning: total count covariance is not positive definite!\n");
+            //fprintf(stderr, "Warning: total FPKM covariance is not positive definite (ret = %lg)!\n", ret);
             for (size_t j = 0; j < _abundances.size(); ++j)
             {
                 _abundances[j]->status(NUMERIC_FAIL);
             }
         }
+        
+       if(!(FPKM() == 0 || fpkm_var > 0 || status() != NUMERIC_OK))
+       {
+           //cerr << _count_covariance << endl;
+           //cerr << _fpkm_covariance << endl;
+       }
+        
         assert (FPKM() == 0 || fpkm_var > 0 || status() != NUMERIC_OK);
     }
-
+    
     
     
     calculate_conf_intervals();
@@ -164,35 +167,6 @@ AbundanceStatus AbundanceGroup::status() const
     if (has_ok_member == false)
         return NUMERIC_LOW_DATA;
     
-    
-    
-    // check that the variance of the group is stable (w.r.t to bootstrap)
-    double total_cov = 0.0;
-    double total_gamma = 0.0;
-    for (size_t i = 0; i < _gamma_covariance.size1(); ++i)
-    {
-        for (size_t j = 0; j < _gamma_covariance.size2(); ++j)
-        {
-            total_cov += _gamma_covariance(i,j);
-            //total_bootstrap_cov += _gamma_bootstrap_covariance(i,j);
-        }
-        
-        
-        total_gamma = _abundances[i]->gamma();
-        //total_cov += _gamma_covariance(i,i);
-        //total_gamma += _gamma_bootstrap_covariance(i,i);
-        
-    }
-//    if (total_cov > 0 && total_gamma > 0)
-//    {
-//        double bootstrap_gamma_delta = total_cov/total_gamma;
-//        //double gap = bootstrap_delta_gap * total_cov;
-//        if (bootstrap_gamma_delta > bootstrap_delta_gap)
-//        {
-//            return NUMERIC_LOW_DATA;
-//        }
-//    }
-    
 	return NUMERIC_OK;
 }
 
@@ -203,7 +177,7 @@ void TranscriptAbundance::FPKM_variance(double v)
     _FPKM_variance = v; 
 }
 
-bool AbundanceGroup::has_member_with_status(AbundanceStatus member_status)
+bool AbundanceGroup::has_member_with_status(AbundanceStatus member_status) const
 {
     foreach(shared_ptr<Abundance> ab, _abundances)
 	{
@@ -227,6 +201,108 @@ double AbundanceGroup::num_fragments() const
 	return num_f;
 }
 
+CountPerReplicateTable AbundanceGroup::num_fragments_by_replicate() const
+{
+	CountPerReplicateTable cpr;
+	
+	foreach(shared_ptr<Abundance> ab, _abundances)
+	{
+		if (cpr.empty())
+        {
+            cpr = ab->num_fragments_by_replicate();
+        }
+        else
+        {
+            CountPerReplicateTable ab_cpr = ab->num_fragments_by_replicate();
+            for (CountPerReplicateTable::const_iterator itr = ab_cpr.begin(); 
+                 itr != ab_cpr.end();
+                 ++itr)
+            {
+                CountPerReplicateTable::iterator cpr_itr = cpr.find(itr->first);
+                assert (cpr_itr != cpr.end());
+                cpr_itr->second += itr->second;
+            }
+        }
+	}
+    
+    //assert (cpr.empty() != false);
+	return cpr;
+}
+
+FPKMPerReplicateTable AbundanceGroup::FPKM_by_replicate() const
+{
+	FPKMPerReplicateTable fpr;
+	
+	foreach(shared_ptr<Abundance> ab, _abundances)
+	{
+		if (fpr.empty())
+        {
+            fpr = ab->FPKM_by_replicate();
+        }
+        else
+        {
+            FPKMPerReplicateTable ab_fpr = ab->FPKM_by_replicate();
+            for (FPKMPerReplicateTable::const_iterator itr = ab_fpr.begin(); 
+                 itr != ab_fpr.end();
+                 ++itr)
+            {
+                FPKMPerReplicateTable::iterator fpr_itr = fpr.find(itr->first);
+                assert (fpr_itr != fpr.end());
+                fpr_itr->second += itr->second;
+            }
+        }
+	}
+    
+    //assert (cpr.empty() != false);
+	return fpr;
+}
+
+StatusPerReplicateTable AbundanceGroup::status_by_replicate() const
+{
+	StatusPerReplicateTable fpr;
+	
+	foreach(shared_ptr<Abundance> ab, _abundances)
+	{
+		if (fpr.empty())
+        {
+            fpr = ab->status_by_replicate();
+        }
+        else
+        {
+            StatusPerReplicateTable ab_fpr = ab->status_by_replicate();
+            for (StatusPerReplicateTable::const_iterator itr = ab_fpr.begin(); 
+                 itr != ab_fpr.end();
+                 ++itr)
+            {
+                StatusPerReplicateTable::iterator fpr_itr = fpr.find(itr->first);
+                assert (fpr_itr != fpr.end());
+                
+                AbundanceStatus s = itr->second;
+                
+                if (s == NUMERIC_FAIL)
+                {
+                    fpr_itr->second = NUMERIC_FAIL;
+                }
+                else if (s == NUMERIC_LOW_DATA && (fpr_itr->second != NUMERIC_HI_DATA && fpr_itr->second != NUMERIC_FAIL && fpr_itr->second != NUMERIC_OK))
+                {
+                    fpr_itr->second = NUMERIC_LOW_DATA;
+                }
+                else if (s == NUMERIC_HI_DATA)
+                {
+                    fpr_itr->second = NUMERIC_HI_DATA;
+                }
+                else if (s == NUMERIC_OK && (fpr_itr->second != NUMERIC_HI_DATA && fpr_itr->second != NUMERIC_FAIL))
+                {
+                    fpr_itr->second = NUMERIC_OK;
+                }
+            }
+        }
+	}
+    
+    //assert (cpr.empty() != false);
+	return fpr;
+}
+
 double AbundanceGroup::mass_fraction() const
 {
 	double mass = 0;
@@ -249,6 +325,34 @@ double AbundanceGroup::mass_variance() const
 	return mass_var;
 }
 
+// This tracks the final modeled variance in the assigned counts.
+double AbundanceGroup::num_fragment_var() const			
+{ 
+    double frag_var = 0.0;
+    for (size_t i = 0; i < _abundances.size(); ++i)
+    {
+        for (size_t j = 0; j < _abundances.size(); ++j)
+        {
+            frag_var += _count_covariance(i,j);
+        }
+    }
+    return frag_var;
+}
+
+// This tracks the final modeled variance in the assigned counts.
+double AbundanceGroup::num_fragment_uncertainty_var() const			
+{ 
+    double frag_var = 0.0;
+    for (size_t i = 0; i < _abundances.size(); ++i)
+    {
+        for (size_t j = 0; j < _abundances.size(); ++j)
+        {
+            frag_var += _iterated_exp_count_covariance(i,j);
+        }
+    }
+    return frag_var;
+}
+
 double AbundanceGroup::FPKM() const
 {
 	double fpkm = 0;
@@ -290,10 +394,12 @@ void AbundanceGroup::filter_group(const vector<bool>& to_keep,
     ublas::matrix<double> new_iterated_em_count_cov = ublas::zero_matrix<double>(num_kept,num_kept);
     ublas::matrix<double> new_count_cov = ublas::zero_matrix<double>(num_kept,num_kept);
     ublas::matrix<double> new_fpkm_cov = ublas::zero_matrix<double>(num_kept,num_kept);
-    ublas::matrix<double> new_boot_cov = ublas::zero_matrix<double>(num_kept,num_kept);
+    
 	vector<shared_ptr<Abundance> > new_ab;
+    
+	vector<Eigen::VectorXd> new_assigned_count_samples(_assigned_count_samples.size(), Eigen::VectorXd::Zero(num_kept));;
 	
-	// rebuild covariance matrix and abundance vector after filtration
+    // rebuild covariance matrix and abundance vector after filtration
 	
 	size_t next_cov_row = 0;
 	for (size_t i = 0; i < _abundances.size(); ++i)
@@ -310,22 +416,37 @@ void AbundanceGroup::filter_group(const vector<bool>& to_keep,
                     new_iterated_em_count_cov(next_cov_row,next_cov_col) = _iterated_exp_count_covariance(i, j);
                     new_count_cov(next_cov_row,next_cov_col) = _count_covariance(i, j);
                     new_fpkm_cov(next_cov_row,next_cov_col) = _fpkm_covariance(i, j);
-                    new_boot_cov(next_cov_row,next_cov_col) = _gamma_bootstrap_covariance(i, j);
 					next_cov_col++;
 				}
 			}
 			next_cov_row++;
 		}
 	}
+    
+    
+    size_t curr_abundance_idx = 0;
+    for (size_t i = 0; i < _abundances.size(); ++i)
+    {
+        if (to_keep[i])
+		{
+            for (size_t j = 0; j < _assigned_count_samples.size(); ++j)
+            {
+                new_assigned_count_samples[j](curr_abundance_idx) = _assigned_count_samples[j](i);
+            }
+            curr_abundance_idx++;
+        }
+        
+    }
 
 	filtered_group = AbundanceGroup(new_ab, 
                                     new_cov, 
-                                    new_boot_cov, 
                                     new_iterated_em_count_cov, 
                                     new_count_cov, 
                                     new_fpkm_cov,
                                     _max_mass_variance,
-                                    _read_group_props);
+                                    _read_group_props,
+                                    new_assigned_count_samples);
+    filtered_group.description(_description);
 }
 
 void AbundanceGroup::get_transfrags(vector<shared_ptr<Abundance> >& transfrags) const
@@ -469,16 +590,28 @@ double AbundanceGroup::effective_length() const
 //    }
 //}
 
-void AbundanceGroup::calculate_locus_scaled_mass_and_variance(const vector<MateHit>& alignments,
-                                                              const vector<shared_ptr<Abundance> >& transcripts)
+void AbundanceGroup::collect_per_replicate_mass(const vector<MateHit>& alignments,
+                                                vector<shared_ptr<Abundance> >& transcripts)
 {
-	size_t M = alignments.size();
+    size_t M = alignments.size();
 	size_t N = transcripts.size();
 	
+    //_count_per_replicate.clear();
+    
+    for (map<shared_ptr<ReadGroupProperties const>, double>::iterator itr = _count_per_replicate.begin(); 
+         itr != _count_per_replicate.end();
+         ++itr)
+    {
+        itr->second = 0.0;
+    }
+    
 	if (transcripts.empty())
 		return;
     
-    map<shared_ptr<ReadGroupProperties const>, double> count_per_replicate;
+    //map<shared_ptr<ReadGroupProperties const>, double> count_per_replicate;
+
+    vector<shared_ptr<Abundance> > mapped_transcripts; // This collects the transcripts that have alignments mapping to them
+	compute_cond_probs_and_effective_lengths(alignments, transcripts, mapped_transcripts);
     
 	for (size_t i = 0; i < M; ++i)
 	{	
@@ -499,13 +632,23 @@ void AbundanceGroup::calculate_locus_scaled_mass_and_variance(const vector<MateH
             shared_ptr<ReadGroupProperties const> rg_props = alignments[i].read_group_props();
             //assert (parent != NULL);
             pair<map<shared_ptr<ReadGroupProperties const>, double>::iterator, bool> inserted;
-            inserted = count_per_replicate.insert(make_pair(rg_props, 0.0));
+            inserted = _count_per_replicate.insert(make_pair(rg_props, 0.0));
             _read_group_props.insert(rg_props);
             
+            // these are the *internally* scaled masses.
             double more_mass = alignments[i].collapse_mass();
             inserted.first->second += more_mass;
         }
     }
+}
+
+void AbundanceGroup::calculate_locus_scaled_mass_and_variance(const vector<MateHit>& alignments,
+                                                              const vector<shared_ptr<Abundance> >& transcripts)
+{
+	size_t N = transcripts.size();
+	
+	if (transcripts.empty())
+		return;
     
     double avg_X_g = 0.0;
     double avg_mass_fraction = 0.0;
@@ -517,19 +660,36 @@ void AbundanceGroup::calculate_locus_scaled_mass_and_variance(const vector<MateH
     vector<double> avg_mass_variances(N, 0.0);
     
     double max_mass_var = 0.0;
-    for (map<shared_ptr<ReadGroupProperties const>, double>::iterator itr = count_per_replicate.begin();
-         itr != count_per_replicate.end();
+    
+    double external_scale_factor = -1.0;
+    for (map<shared_ptr<ReadGroupProperties const>, double>::iterator itr = _count_per_replicate.begin();
+         itr != _count_per_replicate.end();
          ++itr)
     {
         shared_ptr<ReadGroupProperties const> rg_props = itr->first;
-        double scaled_mass = itr->second; //rg_props->scale_mass(itr->second);
-        double scaled_total_mass = rg_props->scale_mass(rg_props->normalized_map_mass());
+        
+        if (external_scale_factor < 0)
+        {
+            external_scale_factor = rg_props->external_scale_factor();
+        }
+        else
+        {
+            assert (external_scale_factor == rg_props->external_scale_factor());
+        }
+        
+        // Since the _count_per_replicate table stores internally scaled
+        // fragment counts, we need to scale the fragment counts up so we 
+        // can compare between conditions, rather than just between replicates
+        // of this condition.
+        double scaled_mass = itr->second;
+        double scaled_total_mass = rg_props->normalized_map_mass();
         avg_X_g += scaled_mass;
         shared_ptr<MassDispersionModel const> disperser = rg_props->mass_dispersion_model();
         for (size_t j = 0; j < N; ++j)
         {
             double scaled_variance;
-            scaled_variance = disperser->scale_mass_variance(scaled_mass * _abundances[j]->gamma());   
+            //scaled_variance = disperser->scale_mass_variance(scaled_mass * _abundances[j]->gamma());
+            scaled_variance = _abundances[j]->gamma() * disperser->scale_mass_variance(scaled_mass);
             avg_mass_variances[j] += scaled_variance;
         }
         assert (disperser->scale_mass_variance(scaled_mass) != 0 || scaled_mass == 0); 
@@ -540,11 +700,11 @@ void AbundanceGroup::calculate_locus_scaled_mass_and_variance(const vector<MateH
     
     // Set the maximum mass variance in case we get an identifiability failure
     // and need to bound the group expression.
-    if (!count_per_replicate.empty())
-        max_mass_var /= count_per_replicate.size();
+    if (!_count_per_replicate.empty())
+        max_mass_var /= _count_per_replicate.size();
     
     
-    double num_replicates = count_per_replicate.size();
+    double num_replicates = _count_per_replicate.size();
     
     if (num_replicates)
     {
@@ -570,6 +730,8 @@ void AbundanceGroup::calculate_locus_scaled_mass_and_variance(const vector<MateH
         if (j_avg_mass_fraction > 0)
         {
             double FPKM = j_avg_mass_fraction * 1000000000/ _abundances[j]->effective_length();
+            FPKM *= 1.0 / external_scale_factor;
+            
             _abundances[j]->FPKM(FPKM);
         }
         else 
@@ -641,14 +803,14 @@ void collapse_equivalent_hits(const vector<MateHit>& alignments,
         curr_align = &nr_alignments.back();
         log_conv_factors.push_back(0);
         
-        if (alignments[i].is_multi()) // don't reduce other hits into multihits
+        if (corr_multi && alignments[i].is_multi()) // don't reduce other hits into multihits
             continue;
         
         bool seen_olap = false;
         
         for(int k = i + 1 ; k < M; ++k)
         {
-            if (replaced[k] || alignments[k].is_multi() || alignments[i].read_group_props() != alignments[k].read_group_props())
+            if (replaced[k] || (corr_multi && alignments[k].is_multi()) || alignments[i].read_group_props() != alignments[k].read_group_props())
                 continue;
             if (require_overlap && !::overlap_in_genome(curr_align->left(), curr_align->right(),
                                      alignments[k].left(), alignments[k].right()))
@@ -694,7 +856,9 @@ void collapse_equivalent_hits(const vector<MateHit>& alignments,
             {
                 if ((*cond_probs_k)[j] != 0 && cond_probs_i[j] != 0)
                 {
-                    double ratio =  (*cond_probs_k)[j] / cond_probs_i[j];
+                    double cp_j = (*cond_probs_k)[j];
+                    double cp_i = cond_probs_i[j];
+                    double ratio =  cp_j / cp_i;
                     if (last_cond_prob == -1)
                     {
                         //assert(ratio < 5);
@@ -703,6 +867,7 @@ void collapse_equivalent_hits(const vector<MateHit>& alignments,
                     else
                     {
                         if (last_cond_prob != ratio)
+                        //if (abs(last_cond_prob - ratio) > 0.001)
                         {
                             equiv = false;
                             break;
@@ -723,27 +888,33 @@ void collapse_equivalent_hits(const vector<MateHit>& alignments,
             
             // cond_prob_i vector is a scalar multiple of cond_prob_k, so we
             // can collapse k into i via the mass.
-            if (equiv && last_cond_prob > 0.0)
+            if (equiv)
             {
-                assert(curr_align->read_group_props() == alignments[k].read_group_props());
-                assert (last_cond_prob > 0);
-                //double mass_muliplier = sqrt(last_cond_prob);
-                double mass_multiplier = log(last_cond_prob);
-                //assert(last_cond_prob < 5);
-                assert (!isinf(mass_multiplier) && !isnan(mass_multiplier));
-                log_conv_factors[log_conv_factors.size() - 1] += mass_multiplier; 
-                replaced[k] = true;
-                cached_cond_probs[k].clear();
-                vector<double>(cached_cond_probs[k]).swap(cached_cond_probs[k]);
-                num_replaced++;
-                
-                //double scale_factor = alignments[k].common_scale_mass();
-                //double curr_align_mass = curr_align->collapse_mass();
-                
-                //double more_mass = alignments[k].common_scale_mass() * alignments[k].collapse_mass() ;
-                double more_mass = alignments[k].collapse_mass();
-                curr_align->incr_collapse_mass(more_mass);
+                if (last_cond_prob > 0.0)
+                {
+                    //assert(curr_align->read_group_props() == alignments[k].read_group_props());
+                    assert (last_cond_prob > 0);
+                    //double mass_muliplier = sqrt(last_cond_prob);
+                    double mass_multiplier = log(last_cond_prob);
+                    //assert(last_cond_prob < 5);
+                    assert (!isinf(mass_multiplier) && !isnan(mass_multiplier));
+                    log_conv_factors[log_conv_factors.size() - 1] += mass_multiplier; 
+                    replaced[k] = true;
+                    cached_cond_probs[k].clear();
+                    vector<double>(cached_cond_probs[k]).swap(cached_cond_probs[k]);
+                    num_replaced++;
+                    double more_mass = alignments[k].collapse_mass();
+                    curr_align->incr_collapse_mass(more_mass);
+                }
+                else
+                {
+                    replaced[k] = true;
+                    num_replaced++;
+                    cached_cond_probs[k].clear();
+                    vector<double>(cached_cond_probs[k]).swap(cached_cond_probs[k]);
+                }
             }
+            
         }
     }
     
@@ -781,7 +952,7 @@ void collapse_equivalent_hits(const vector<MateHit>& alignments,
 	}
     if (nr_alignments.size())
     {
-        verbose_msg("\nReduced %lu frags to %lu (%lf percent)\n", alignments.size(), nr_alignments.size(), 100.0 * nr_alignments.size()/(double)alignments.size());
+        verbose_msg("\nReduced %lu frags to %lu (%lf percent)\n", alignments.size(), nr_alignments.size(), 100.0 * (1 - nr_alignments.size()/(double)alignments.size()));
     }
 }
 
@@ -794,6 +965,14 @@ void collapse_equivalent_hits_helper(const vector<MateHit>& alignments,
     int N = transcripts.size();
 	int M = alignments.size();
     
+    if (N == 1)
+    {
+        nr_alignments = alignments;
+        log_conv_factors = vector<double>(M, 0.0);
+        return;
+    }
+    // TODO: Remove this short cut after verifying that it doesn't really make sense
+    // for large bundles.  The collapse is almost certainly more efficient.
     // If there's a lot of transcripts, just use the old, overlap constrained 
     // version of the equivalence collapse.
     if (N > 24)
@@ -852,7 +1031,7 @@ void AbundanceGroup::calculate_abundance(const vector<MateHit>& alignments)
 	vector<shared_ptr<Abundance> > transcripts;
 	get_transfrags(transcripts);
 	vector<shared_ptr<Abundance> > mapped_transcripts; // This collects the transcripts that have alignments mapping to them
-	
+    
 	vector<MateHit> nr_alignments;
     
     if (cond_prob_collapse)
@@ -864,6 +1043,8 @@ void AbundanceGroup::calculate_abundance(const vector<MateHit>& alignments)
         nr_alignments = alignments;
     }
     
+    collect_per_replicate_mass(nr_alignments, transcripts);
+    
     vector<MateHit> non_equiv_alignments;
     vector<double> log_conv_factors;
     if (cond_prob_collapse)
@@ -880,20 +1061,93 @@ void AbundanceGroup::calculate_abundance(const vector<MateHit>& alignments)
         non_equiv_alignments = nr_alignments;
         compute_cond_probs_and_effective_lengths(non_equiv_alignments, transcripts, mapped_transcripts);
     }
+       
+    if (final_est_run || corr_multi || corr_bias) // don't do the pooled estimation run if we're just getting the replicate mles for dispersion modeling
+    {
+        calculate_gammas(non_equiv_alignments, log_conv_factors, transcripts, mapped_transcripts);
+    }
+    
+    ublas::vector<double> mean_per_rep_gammas;
+    ublas::matrix<double> gamma_covariance;
+    std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> > mles_for_read_groups;
+    std::map<shared_ptr<ReadGroupProperties const >, AbundanceStatus > status_per_replicate;
+    
+	for (std::map<shared_ptr<ReadGroupProperties const >, double >::const_iterator itr =_count_per_replicate.begin(); itr != _count_per_replicate.end(); ++itr)
+	{
+        mles_for_read_groups.insert(make_pair(itr->first, ublas::vector<double>(_abundances.size(), 0)));
+	}
+    
+    if (final_est_run || (!corr_multi && !corr_bias))
+    {
+        empirical_mean_replicate_gamma_mle(transcripts,
+                                           non_equiv_alignments,
+                                           log_conv_factors,
+                                           mean_per_rep_gammas,
+                                           gamma_covariance,
+                                           mles_for_read_groups,
+                                           _count_per_replicate,
+                                           status_per_replicate);
         
-	calculate_gammas(non_equiv_alignments, log_conv_factors, transcripts, mapped_transcripts);
+        for (size_t i = 0; i < _abundances.size(); ++i)
+        {
+            CountPerReplicateTable cpr;
+            FPKMPerReplicateTable fpr;
+            StatusPerReplicateTable spr;
+            for (std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> >::const_iterator itr = mles_for_read_groups.begin();
+                 itr != mles_for_read_groups.end();
+                 ++itr)
+            {
+                const ublas::vector<double>& mles_for_rep = itr->second;
+                std::map<shared_ptr<ReadGroupProperties const >, double>::const_iterator rep_itr = _count_per_replicate.find(itr->first);
+                assert (rep_itr != _count_per_replicate.end());
+                double count_for_rep = rep_itr->second;
+                ublas::vector<double> trans_counts = mles_for_rep * count_for_rep;
+                ublas::vector<double> trans_fpkms = trans_counts;
+                std::vector<AbundanceStatus> trans_status(trans_fpkms.size(), NUMERIC_OK);
+                for (size_t j = 0; j < trans_fpkms.size(); ++j)
+                {
+                    if (_abundances[i]->effective_length() && (itr->first)->normalized_map_mass())
+                    {
+                        trans_fpkms(j) /= (itr->first)->normalized_map_mass();
+                        trans_fpkms(j) *= 1000000000;
+                        trans_fpkms(j) /= _abundances[i]->effective_length();
+                        trans_fpkms(j) /= (itr->first)->external_scale_factor();
+                    }
+                    else
+                    {
+                        trans_fpkms(j) = 0;
+                    }
+                    
+                }
+                
+                std::map<shared_ptr<ReadGroupProperties const >, AbundanceStatus>::const_iterator status_rep_itr = status_per_replicate.find(itr->first);
+                assert (status_rep_itr != status_per_replicate.end());
+                cpr[itr->first] = trans_counts[i];
+                fpr[itr->first] = trans_fpkms[i];
+                spr[itr->first] = status_rep_itr->second;
+            }
+            _abundances[i]->num_fragments_by_replicate(cpr);
+            _abundances[i]->FPKM_by_replicate(fpr);
+            _abundances[i]->status_by_replicate(spr);
+        }
+    }
+    
+    mapped_transcripts.clear();
+    compute_cond_probs_and_effective_lengths(non_equiv_alignments, transcripts, mapped_transcripts);
     
     //non_equiv_alignments.clear();
 	//collapse_hits(alignments, nr_alignments);
     //This will also compute the transcript level FPKMs
-    calculate_locus_scaled_mass_and_variance(non_equiv_alignments, transcripts);  
     
     calculate_iterated_exp_count_covariance(non_equiv_alignments, transcripts);
     
-    // Refresh the variances to match the new gammas computed during iterated
-    // expectation
+    // Calculate the initial estimates for the number of fragments originating
+    // from each transcript, and set the NB variances
     calculate_locus_scaled_mass_and_variance(non_equiv_alignments, transcripts);  
     
+    // Refresh the variances to match the new gammas computed during iterated
+    // expectation
+    // calculate_locus_scaled_mass_and_variance(non_equiv_alignments, transcripts);  
     
 	if(corr_multi && !final_est_run)
 	{
@@ -902,6 +1156,10 @@ void AbundanceGroup::calculate_abundance(const vector<MateHit>& alignments)
 	
 	if (final_est_run) // Only on last estimation run
 	{
+        // Simulate NB draws and fragment assignment under uncertainty to sample
+        // from the BNBs.
+        simulate_count_covariance(non_equiv_alignments, transcripts);
+    
         // Calling calculate_FPKM_covariance() also estimates cross-replicate
         // count variances
         calculate_FPKM_covariance();
@@ -919,6 +1177,7 @@ void AbundanceGroup::calculate_abundance(const vector<MateHit>& alignments)
         {
             if (i != j)
             {
+                assert(!isinf(_fpkm_covariance(i,j)) && !isnan(_fpkm_covariance(i,j)));
                 if (_abundances[i]->transfrag()->contains(*_abundances[j]->transfrag()) &&
                     Scaffold::compatible(*_abundances[i]->transfrag(),*_abundances[j]->transfrag()))
                 {
@@ -994,12 +1253,11 @@ bool estimate_count_variance(long double& variance,
                              double psi_t_count_var, 
                              double X_g, 
                              double V_X_g_t,
-                             double l_t,
-                             double M)
+                             double l_t)
 {
     if (l_t == 0)
     {
-        return 0;
+        return true;
     }
 
     long double A = X_g * gamma_t;
@@ -1054,7 +1312,8 @@ bool estimate_count_variance(long double& variance,
             beta = solve_beta(A,B,C);
             alpha = 1.0 - (A/(A-B)) * beta;
 
-            if (beta <= 2 || alpha <= 1)
+            //if (beta <= 2 || alpha <= 1)
+            if (alpha <= 2)
             {
                 //printf ("Warning: beta for is %Lg\n", beta);
                 numeric_ok = false;
@@ -1160,147 +1419,272 @@ bool estimate_count_variance(long double& variance,
 //    return numeric_ok;
 //}
 
-void AbundanceGroup::estimate_count_covariance()
+void AbundanceGroup::simulate_count_covariance(const vector<MateHit>& nr_alignments,
+                                               const vector<shared_ptr<Abundance> >& transcripts)
 {
-    vector<double> gammas;
-    vector<double> ls;
-    vector<double> V_X_gs;
+    _count_covariance = ublas::zero_matrix<double>(_abundances.size(), _abundances.size());
     
-    for (size_t j = 0; j < _abundances.size(); ++j)
+    if (_abundances.size() <= 1)
     {
-        gammas.push_back(_abundances[j]->gamma());
-        ls.push_back(_abundances[j]->effective_length());
-        V_X_gs.push_back(_abundances[j]->mass_variance());
+        _count_covariance(0,0) = _abundances[0]->mass_variance();
+        return;
     }
     
-    _count_covariance = ublas::zero_matrix<double>(_abundances.size(), _abundances.size());
+    if (num_fragments() == 0)
+    {
+        return;
+    }
     
-    AbundanceStatus group_status = status();
+    //size_t num_frag_count_draws = 1000;
+    //const int num_multinomial_samples = 1;
     
-    if (group_status == NUMERIC_OK || group_status == NUMERIC_LOW_DATA)
-	{
-		// This will compute the transcript level cross-replicate counts
-		for (size_t j = 0; j < _abundances.size(); ++j)
-		{
-			if (_abundances[j]->effective_length() > 0.0 && mass_fraction() > 0)
-			{
-                assert (!isnan(_gamma_covariance(j,j)));
-                
-                long double count_var = 0.0;
+    boost::mt19937 rng;
+    
+    vector<boost::random::negative_binomial_distribution<int, double> > nb_gens;
+    vector<Eigen::VectorXd > generated_counts (num_frag_count_draws, Eigen::VectorXd::Zero(_abundances.size()));
+    
+    for (size_t j = 0; j < _abundances.size(); ++j)
+    {
+        double r = _abundances[j]->num_fragments();
+        if (r > 0)
+        {
+            double fit_var = _abundances[j]->mass_variance();
+            if (fit_var - _abundances[j]->num_fragments() > 1e-1)
+            {
+                r *= r;
+                double over_disp_scale = fit_var - _abundances[j]->num_fragments();
+                r /= over_disp_scale;
+                r = rounding::roundhalfeven(r);
                 
-                bool numerics_ok = estimate_count_variance(count_var,
-                                                           _abundances[j]->gamma(),
-                                                           _iterated_exp_count_covariance(j,j),
-                                                           num_fragments(),
-                                                           _abundances[j]->mass_variance(),
-                                                           _abundances[j]->effective_length(),
-                                                           num_fragments()/mass_fraction());
-                if (numerics_ok == false)
+                if (r == 0)
                 {
-                    _abundances[j]->status(NUMERIC_LOW_DATA);
+                    for (size_t i = 0; i < num_frag_count_draws; ++i)
+                    {
+                        generated_counts[i](j) = 0;
+                    }
+                    continue;
                 }
-                else
+                
+                double p = _abundances[j]->num_fragments() / fit_var;
+                
+                boost::random::negative_binomial_distribution<int, double> nb_j(r, p);
+                for (size_t i = 0; i < num_frag_count_draws; ++i)
                 {
-                    assert (!isinf(count_var) && !isnan(count_var));
-                    _count_covariance(j,j) = count_var;
+                    generated_counts[i](j) = nb_j(rng);
                 }
-   			}
-			else
-			{
-				// nothing to do here, variances and covariances should be zero.
-                //assert(false);
-			}
-		}
-        
-        if (group_status == NUMERIC_LOW_DATA)
-        {
-            // if the entire group is unstable, then set LOWDATA on all members of 
-            // it to reduce false positives in differential expression analysis.
-            foreach(shared_ptr<Abundance> ab, _abundances)
-            {
-                ab->status(NUMERIC_LOW_DATA);
             }
-        }
-        
-        if (_abundances.size() > 1)
-        {
-            for (size_t j = 0; j < _abundances.size(); ++j)
+            else
             {
-                double scale_j = 0.0;
-                double poisson_variance_j = _abundances[j]->num_fragments();
-                if (poisson_variance_j == 0)
-                {
-                    scale_j = 0.0;
-                }
-                else
-                {
-                    
-                    scale_j = _abundances[j]->mass_variance() / poisson_variance_j;
-//                    if (-scale_j * _iterated_exp_count_covariance(i,j) > _abundances[j]->mass_variance())
-//                        scale_j = -_abundances[j]->mass_variance() / _iterated_exp_count_covariance(i,j);
-                }
-                for (size_t i = 0; i < _abundances.size(); ++i)
+                r = rounding::roundhalfeven(r);
+                if (r == 0)
                 {
-                    if (i != j)
+                    for (size_t i = 0; i < num_frag_count_draws; ++i)
                     {
-                        double scale_i = 0.0;
-                        double poisson_variance_i = _abundances[i]->num_fragments();
-                        if (poisson_variance_i == 0)
-                        {
-                            scale_i = 0.0;
-                        }
-                        else
-                        {
-                            scale_i = _abundances[i]->mass_variance() / poisson_variance_i;
-                        }
-                        if (scale_i != 0 && scale_j != 0)
-                        {
-                            double poisson_scale = sqrt(scale_j) * sqrt(scale_i);
-                            
-                            double before = _iterated_exp_count_covariance(i,j);
-                            
-                            long double scale = poisson_scale;
-                            
-                            assert (!isinf(scale) && !isnan(scale));
-                            if (scale < 1.0)
-                                scale = 1.0;
-                            
-                            double after = scale * before;
-                            //assert (after <=  _abundances[i]->mass_variance() + _abundances[j]->mass_variance());
-                            
-                            assert (_iterated_exp_count_covariance(i,j) <= 0);
-                            assert (before >= after);
-                            _count_covariance(i,j) = after;
-                        }
-                        else
-                        {
-                            _count_covariance(i,j) = 0;
-                        }
-                        assert (!isinf(_count_covariance(i,j)) && !isnan(_count_covariance(i,j)));
-                        // TODO: attach per-transcript cross-replicate count variance here?
+                        generated_counts[i](j) = 0;
                     }
+                    continue;
+                }
+                
+                boost::random::poisson_distribution<int, double> nb_j(r);
+                for (size_t i = 0; i < num_frag_count_draws; ++i)
+                {
+                    generated_counts[i](j) = nb_j(rng);
                 }
             }
         }
-	}
-	else
-	{
-        // if we get here, there was an EM or IS failure, and the covariances can't be reliably calculated.
-        // assert(false);
-	}
+        else
+        {
+            for (size_t i = 0; i < num_frag_count_draws; ++i)
+            {
+                generated_counts[i](j) = 0;
+            }
+        }
+           
+    }
     
-    ublas::matrix<double> test = _count_covariance;
-    double ret = cholesky_factorize(test);
-    if (ret != 0)
+    ublas::matrix<double> assign_probs_transpose = ublas::trans(_assign_probs);
+    vector<Eigen::VectorXd > assigned_counts (num_frag_count_draws * num_frag_assignments, Eigen::VectorXd::Zero(_abundances.size()));
+    
+    Eigen::MatrixXd transcript_cond_probs(_abundances.size(), nr_alignments.size());
+    for (int j = 0; j < transcript_cond_probs.rows(); ++j)
     {
-        //fprintf(stderr, "Warning: total count covariance is not positive definite!\n");
-        for (size_t j = 0; j < _abundances.size(); ++j)
+        for (int i = 0; i < transcript_cond_probs.cols(); ++i)
         {
-            _abundances[j]->status(NUMERIC_FAIL);
+            transcript_cond_probs(j,i) = (*(transcripts[j]->cond_probs()))[i];
         }
     }
     
-//    cerr << "full count: " << endl;
+    Eigen::VectorXd aligment_multiplicities(nr_alignments.size());
+    for (int i = 0; i < aligment_multiplicities.size(); ++i)
+    {
+        aligment_multiplicities[i] = nr_alignments[i].collapse_mass();
+    }
+    
+    boost::uniform_01<> uniform_dist;
+    boost::mt19937 null_rng; 
+    boost::variate_generator<boost::mt19937&, boost::uniform_01<> > uniform_gen(null_rng, uniform_dist); 
+    
+    vector< vector<double> > selector_variates (num_frag_assignments, vector<double>(transcript_cond_probs.cols(), 0.0));
+    for (size_t i = 0; i < num_frag_assignments; ++i)
+    {
+        vector<double>& selector = selector_variates[i];
+        for (int frag_idx = 0; frag_idx < transcript_cond_probs.cols(); ++frag_idx)
+        {
+            selector[frag_idx] = uniform_gen();
+        }
+    }
+    
+    Eigen::VectorXd expected_generated_counts = Eigen::VectorXd::Zero(_abundances.size());
+    
+    for (size_t i = 0; i < num_frag_count_draws; ++i)
+    {
+        //ublas::vector<double> proposed_gammas = generated_counts[i];
+        Eigen::VectorXd proposed_gammas = generated_counts[i];
+        
+        double total_sample_frags = generated_counts[i].sum();
+        double total_true_frags = aligment_multiplicities.sum();
+        
+        if (total_sample_frags == 0)
+            continue;
+        
+        proposed_gammas /= total_sample_frags;
+        
+        Eigen::MatrixXd assign_probs;
+        calculate_assignment_probs(aligment_multiplicities, transcript_cond_probs, proposed_gammas, assign_probs);
+        
+        expected_generated_counts += generated_counts[i];
+        
+        for (size_t j = 0; j < num_frag_assignments; ++j)
+        {
+            Eigen::VectorXd assigned_frag_counts = Eigen::VectorXd::Zero(_abundances.size());
+            vector<double>& selector = selector_variates[j];
+            for (int frag_idx = 0; frag_idx < assign_probs.cols(); ++frag_idx)
+            {
+               
+                double s = 0.0;
+                double p = selector[frag_idx];
+                for (size_t a_idx = 0; a_idx < _abundances.size(); ++a_idx)
+                {
+                    if (p < s + assign_probs(a_idx, frag_idx))
+                    {
+                        assigned_frag_counts(a_idx) += (aligment_multiplicities[frag_idx] / total_true_frags) * total_sample_frags;
+                        break;
+                    }
+                    s += assign_probs(a_idx, frag_idx);
+                }
+            }
+            assigned_counts[i*num_frag_assignments + j] = assigned_frag_counts;
+        }
+    }
+    
+    Eigen::VectorXd expected_counts = Eigen::VectorXd::Zero(_abundances.size());
+    Eigen::VectorXd expected_relative_abundances = Eigen::VectorXd::Zero(_abundances.size());
+    
+    for (size_t i = 0; i < assigned_counts.size(); ++i)
+    {
+        for (int j = 0; j < assigned_counts[i].size(); ++j)
+        {
+            assert (!isnan(assigned_counts[i](j)) && !isinf(assigned_counts[i](j)));
+        }
+        expected_counts += assigned_counts[i];
+        //
+        //expected_relative_abundances += relative_abundances[i];
+    }
+    if (assigned_counts.size() > 0)
+    {
+        expected_counts /= assigned_counts.size();
+        //expected_generated_counts /= assigned_counts.size();
+        //expected_relative_abundances /= assigned_counts.size();
+    }
+    
+    if (num_frag_assignments > 0)
+    {
+        expected_generated_counts /= num_frag_assignments;
+        //expected_relative_abundances /= assigned_counts.size();
+    }
+    
+      
+//    cerr << "======" << endl;
+//    cerr << "updated expected counts #1: " << endl;
+//    std::cerr << expected_counts << std::endl;
+//    cerr << "updated expected generated counts #1: " << endl;
+//    std::cerr << expected_generated_counts << std::endl;
+//    cerr << "======" << endl;
+    
+    for (size_t i = 0; i < _abundances.size(); ++i)
+    {
+        for (size_t j = 0; j < _abundances.size(); ++j)
+        {
+            for (size_t k = 0 ; k < assigned_counts.size(); ++k)
+            {
+                double c = (assigned_counts[k](i) - expected_counts(i)) * (assigned_counts[k](j) - expected_counts(j));
+                _count_covariance(i,j) += c;
+                
+                assert (!isinf(_count_covariance(i,j)) && !isnan(_count_covariance(i,j)));
+                //double r = (relative_abundances[k](i) - expected_relative_abundances(i)) * (relative_abundances[k](j) - expected_relative_abundances(j));
+                //_kappa_covariance(i,j) += 
+            }
+        }
+    }
+    
+    _count_covariance /= assigned_counts.size();
+    
+//    double total_counts = expected_counts.sum();
+//    for (size_t i = 0; i < _abundances.size(); ++i)
+//    {
+//        if (total_counts > 0)
+//        {
+//            _abundances[i]->gamma(expected_counts(i) / total_counts);
+//        }
+//        else
+//        {
+//            _abundances[i]->gamma(0);
+//        }
+//    }
+    
+    for (size_t i = 0; i < _abundances.size(); ++i)
+    {
+        // Make sure we aren't below the fit for the single isoform case
+        if (_count_covariance(i,i) < ceil(_abundances[i]->mass_variance()))
+        {
+            //fprintf(stderr, "Counts for %d (var = %lg) are underdispersed, reverting to fitted variance model (%lg)\n", i, _count_covariance(i,i), ceil(_abundances[i]->mass_variance()));
+            _count_covariance(i,i) = ceil(_abundances[i]->mass_variance());
+        }
+        
+        // Check that we aren't below what the Poisson model says we ought to be at
+        if (_count_covariance(i,i) < ceil(_abundances[i]->num_fragments() + _iterated_exp_count_covariance(i,i)))
+        {
+            //fprintf(stderr, "Counts for %d (var = %lg) are underdispersed, reverting to additive variance model (%lg)\n", i, _count_covariance(i,i),  ceil(_abundances[i]->num_fragments() + _iterated_exp_count_covariance(i,i)));
+            _count_covariance(i,i) = ceil(_abundances[i]->num_fragments() + _iterated_exp_count_covariance(i,i));
+        }
+        
+        long double count_var = 0.0;
+        
+        // Check that we aren't below what the BNB model says we ought to be at
+        bool numerics_ok = estimate_count_variance(count_var,
+                                                   _abundances[i]->gamma(),
+                                                   _iterated_exp_count_covariance(i,i),
+                                                   num_fragments(),
+                                                   _abundances[i]->mass_variance(),
+                                                   _abundances[i]->effective_length());
+//        if (numerics_ok == false)
+//        {
+//            fprintf(stderr, "Warning: BNB has no analytic solution\n");
+//        }
+        
+        if (numerics_ok && _count_covariance(i,i) < ceil(count_var))
+        {
+            //fprintf(stderr, "Counts for %d (var = %lg) are underdispersed, reverting to additive variance model (%lg)\n", i, _count_covariance(i,i),  ceil(_abundances[i]->num_fragments() + _iterated_exp_count_covariance(i,i)));
+            _count_covariance(i,i) = ceil(count_var);
+        }
+    }
+    
+//    for (size_t i = 0; i < _abundances.size(); ++i)
+//    {
+//        _count_covariance(i,i) = ceil(_count_covariance(i,i));
+//    }
+    
+//    cerr << "simulated count covariance: " << endl;
 //    for (unsigned i = 0; i < _count_covariance.size1 (); ++ i) 
 //    {
 //        ublas::matrix_row<ublas::matrix<double> > mr (_count_covariance, i);
@@ -1308,12 +1692,18 @@ void AbundanceGroup::estimate_count_covariance()
 //        std::cerr << i << " : " << mr << std::endl;
 //    }
 //    cerr << "======" << endl;
+//    cerr << "updated expected counts: " << endl;
+//    std::cerr << expected_counts << std::endl;
+//    cerr << "======" << endl;
     
-//    cerr << "ITERATED:" << endl;
-//    cerr <<_iterated_exp_count_covariance << endl;
-//    
-//    cerr << "ITERATED:" << endl;
-//    cerr <<_iterated_exp_count_covariance << endl;
+        
+    _assigned_count_samples = assigned_counts;
+    
+//    for (size_t i = 0; i < num_count_draws; ++i)
+//    {
+//        cerr << generated_counts[i] << endl;
+//        
+//    }
 }
 
 void AbundanceGroup::calculate_FPKM_covariance()
@@ -1324,18 +1714,38 @@ void AbundanceGroup::calculate_FPKM_covariance()
 		return;
 	}
     
-    long double M = num_fragments()/mass_fraction();
+    //long double M = num_fragments()/mass_fraction();
     
-    estimate_count_covariance();
+    //estimate_count_covariance();
     
     long double total_var = 0.0;
-    long double total_count_var = 0.0;
-    long double total_iterated = 0.0;
-    
-    double dummy_var = 0.0;
     
     double abundance_weighted_length = 0.0;
     double total_abundance = 0.0;
+    
+    double external_scale_factor = -1.0;
+    
+    double M = 0;
+    
+    for (map<shared_ptr<ReadGroupProperties const>, double>::iterator itr = _count_per_replicate.begin();
+         itr != _count_per_replicate.end();
+         ++itr)
+    {
+        shared_ptr<ReadGroupProperties const> rg_props = itr->first;
+        M += rg_props->normalized_map_mass();
+        
+        if (external_scale_factor < 0)
+        {
+            external_scale_factor = rg_props->external_scale_factor();
+        }
+        else
+        {
+            assert (external_scale_factor == rg_props->external_scale_factor());
+        }
+    }
+    
+    M /= _count_per_replicate.size();
+    
     for (size_t j = 0; j < _abundances.size(); ++j)
     {
         abundance_weighted_length += _abundances[j]->effective_length() * _abundances[j]->FPKM();
@@ -1344,6 +1754,10 @@ void AbundanceGroup::calculate_FPKM_covariance()
         for (size_t i = 0; i < _abundances.size(); ++i)
         {
             _fpkm_covariance(i,j) = _count_covariance(i,j);
+            
+            // FPKMs need to be on the external scale, so we can compare them
+            // between conditions.  Counts are internally scaled up until here.
+            _fpkm_covariance(i,j) *= 1.0 / (external_scale_factor * external_scale_factor);
             assert (!isinf(_count_covariance(i,j)) && !isnan(_fpkm_covariance(i,j)));
             
             long double length_i = _abundances[i]->effective_length();
@@ -1355,8 +1769,6 @@ void AbundanceGroup::calculate_FPKM_covariance()
                 _fpkm_covariance(i,j) *=
                     ((1000000000.0 / (length_j *M)))*((1000000000.0 / (length_i *M)));
                 assert (!isinf(_fpkm_covariance(i,j)) && !isnan(_fpkm_covariance(i,j)));
-                assert (_fpkm_covariance(i,j) <= _fpkm_covariance(i,i)+_fpkm_covariance(j,j));
-                
             }
             else
             {
@@ -1365,29 +1777,30 @@ void AbundanceGroup::calculate_FPKM_covariance()
             
             if (i == j)
             {
-                assert (_abundances[i]->FPKM() == 0 || _fpkm_covariance(i,j) > 0 || _abundances[i]->status() != NUMERIC_OK);
-                _abundances[i]->FPKM_variance(_fpkm_covariance(i,j));
-                dummy_var += _fpkm_covariance(i,i);
-            }
-            else
-            {
-                dummy_var += _iterated_exp_count_covariance(i,j) * ((1000000000.0 / (length_j *M)))*((1000000000.0 / (length_i *M)));;
+                double fpkm = _abundances[i]->FPKM();
+                double fpkm_var = _fpkm_covariance(i,j);
+                assert (fpkm == 0 || fpkm_var > 0 || _abundances[i]->status() != NUMERIC_OK);
+                assert (!isinf(fpkm_var) && !isnan(fpkm_var));
+                _abundances[i]->FPKM_variance(fpkm_var);
+                _abundances[i]->num_fragment_var(_count_covariance(i,j));
+                
             }
             
-            total_count_var += _count_covariance(i,j);
             total_var += _fpkm_covariance(i,j);
-            total_iterated += _iterated_exp_count_covariance(i,j);
+
+            assert (!isinf(_fpkm_covariance(i,j)) && !isnan(_fpkm_covariance(i,j)));
         }
     }
     
     _FPKM_variance = total_var;
+    
     if (final_est_run && library_type != "transfrags")
     {
         ublas::matrix<double> test = _fpkm_covariance;
         double ret = cholesky_factorize(test);
         if (ret != 0 || (_FPKM_variance < 0 && status() == NUMERIC_OK))
         {
-            //fprintf(stderr, "Warning: total count covariance is not positive definite!\n");
+            //fprintf(stderr, "Warning: FPKM covariance is not positive definite (ret = %lg)!\n", ret);
             for (size_t j = 0; j < _abundances.size(); ++j)
             {
                 _abundances[j]->status(NUMERIC_FAIL);
@@ -1506,175 +1919,7 @@ void AbundanceGroup::calculate_conf_intervals()
 	}
 }
 
-
-//void AbundanceGroup::calculate_conf_intervals()
-//{        
-//	if (status() == NUMERIC_OK)
-//	{
-//		// This will compute the transcript level FPKM confidence intervals
-//		for (size_t j = 0; j < _abundances.size(); ++j)
-//		{
-//            //fprintf(stderr, "%s\n", _abundances[j]->description().c_str());
-//			if (_abundances[j]->effective_length() > 0.0 && mass_fraction() > 0)
-//			{
-//                assert (!isnan(_gamma_covariance(j,j)));
-//                
-//                long double fpkm_var = 0.0;
-//                double FPKM_hi = 0.0;      
-//                double FPKM_lo = 0.0;
-//
-//                bool numerics_ok = calculate_fpkm_variance(fpkm_var,
-//                                                           _abundances[j]->gamma(),
-//                                                           _iterated_exp_count_covariance(j,j),
-//                                                           num_fragments(),
-//                                                           _abundances[j]->mass_variance(),
-//                                                           _abundances[j]->effective_length(),
-//                                                           num_fragments()/mass_fraction());
-//                if (numerics_ok == false)
-//                {
-//                    _abundances[j]->status(NUMERIC_LOW_DATA);
-//                }
-//                else
-//                {
-//                    double gamma_cov_j =  _gamma_covariance(j,j);
-//                    double bootstrap_j = _gamma_bootstrap_covariance(j,j);
-//                    double bootstrap_gamma_delta = abs(bootstrap_j - gamma_cov_j);
-//                    if (bootstrap_gamma_delta > bootstrap_delta_gap * gamma_cov_j && _abundances.size() > 1)
-//                    {
-//                        _abundances[j]->status(NUMERIC_LOW_DATA);
-//                    }
-//                }
-//                
-//                
-//                if (fpkm_var < 0)
-//                {
-//                    //fprintf(stderr, "Warning: FPKM variance < 0 (FPKM = %lf, FPKM variance = %Lf\n", _abundances[j]->FPKM(), fpkm_var);
-//                }
-//                
-//				FPKM_hi = _abundances[j]->FPKM() + 2 * sqrt(fpkm_var);
-//                FPKM_lo = max(0.0, (double)(_abundances[j]->FPKM() - 2 * sqrt(fpkm_var)));
-//				assert (!numerics_ok || FPKM_lo <= _abundances[j]->FPKM() && _abundances[j]->FPKM() <= FPKM_hi);
-//				ConfidenceInterval conf(FPKM_lo, FPKM_hi);
-//				_abundances[j]->FPKM_conf(conf);
-//				_abundances[j]->FPKM_variance(fpkm_var);
-//			}
-//			else
-//			{
-//				_abundances[j]->FPKM_conf(ConfidenceInterval(0.0, 0.0));
-//				_abundances[j]->FPKM_variance(0.0);
-//			}
-//		}
-//		
-//		double group_fpkm = FPKM();
-//		if (group_fpkm > 0.0)
-//		{
-//			calculate_FPKM_variance();
-//			double FPKM_hi = FPKM() + 2 * sqrt(FPKM_variance());
-//			double FPKM_lo = max(0.0, FPKM() - 2 * sqrt(FPKM_variance()));
-//			ConfidenceInterval conf(FPKM_lo, FPKM_hi);
-//			FPKM_conf(conf);
-//		}
-//		else
-//		{
-//			_FPKM_variance = 0.0;
-//			ConfidenceInterval conf(0.0, 0.0);
-//			FPKM_conf(conf);
-//		}
-//	}
-//	else
-//	{
-//		double sum_transfrag_FPKM_hi = 0;
-//        double max_fpkm = 0.0;
-//        //double min_fpkm = 1e100;
-//		foreach(shared_ptr<Abundance> pA, _abundances)
-//		{
-//			double FPKM_hi;
-//			double FPKM_lo;
-//			if (pA->effective_length() > 0)
-//			{
-//                double norm_frag_density = 1000000000;
-//                norm_frag_density /= pA->effective_length();
-//                
-//                norm_frag_density *= mass_fraction();
-//                double fpkm_high = norm_frag_density;
-//                
-//                double var_fpkm = fpkm_high; 
-//                
-//				FPKM_hi = fpkm_high + 2 * sqrt(var_fpkm);
-//				FPKM_lo = 0.0;
-//				ConfidenceInterval conf(FPKM_lo, FPKM_hi);
-//				assert (FPKM_lo <= pA->FPKM() && pA->FPKM() <= FPKM_hi);
-//				pA->FPKM_conf(conf);
-//                pA->FPKM_variance(var_fpkm);
-//				max_fpkm = max(sum_transfrag_FPKM_hi, FPKM_hi);
-//			}
-//			else
-//			{
-//				FPKM_hi = 0.0;
-//				FPKM_lo = 0.0;
-//				ConfidenceInterval conf(0.0, 0.0);
-//				pA->FPKM_conf(conf);
-//                pA->FPKM_variance(0.0);
-//			}
-//            
-//		}
-//		calculate_FPKM_variance();
-//		// In the case of a numeric failure, the groups error bars need to be 
-//		// set such that 
-//		FPKM_conf(ConfidenceInterval(0.0, max_fpkm + 2 * sqrt(FPKM_variance())));
-//        
-//	}
-//}
-//
-//void AbundanceGroup::calculate_FPKM_variance()
-//{
-//	if (mass_fraction() == 0 || effective_length() == 0)
-//	{
-//		_FPKM_variance = 0.0;
-//		return;
-//	}
-//    
-//    vector<double> gammas;
-//    vector<double> ls;
-//    vector<double> V_X_gs;
-//    
-//    for (size_t j = 0; j < _abundances.size(); ++j)
-//    {
-//        gammas.push_back(_abundances[j]->gamma());
-//        ls.push_back(_abundances[j]->effective_length());
-//        V_X_gs.push_back(_abundances[j]->mass_variance());
-//    }
-//    
-//    if (status() == NUMERIC_OK)
-//    {   
-//        long double var = 0.0;
-//        compute_fpkm_group_variance(var,
-//                                    gammas,
-//                                    _iterated_exp_count_covariance,
-//                                    num_fragments(),
-//                                    V_X_gs,
-//                                    ls,
-//                                    num_fragments()/mass_fraction());
-//        _FPKM_variance = var;
-//    }
-//    else
-//    {
-//        long double max_var = 0.0;
-//        for (size_t i = 0; i < _abundances.size(); ++i)
-//        {
-//            bool ok = true;
-//            long double var = 0.0;
-//            ok = compute_fpkm_variance(var, 1.0, 0.0, num_fragments(), max_mass_variance(), ls[i], num_fragments()/mass_fraction());
-//            max_var = max(max_var,var);
-//        }
-//        _FPKM_variance = max_var;
-//        assert (_FPKM_variance != 0 || FPKM() == 0);
-//    }
-//    
-//    assert (!isinf(_FPKM_variance) && !isnan(_FPKM_variance));
-//}
-
-void AbundanceGroup::compute_cond_probs_and_effective_lengths(const vector<MateHit>& alignments,
+void compute_cond_probs_and_effective_lengths(const vector<MateHit>& alignments,
 															  vector<shared_ptr<Abundance> >& transcripts,
 															  vector<shared_ptr<Abundance> >& mapped_transcripts)
 {		
@@ -1744,8 +1989,7 @@ bool AbundanceGroup::calculate_gammas(const vector<MateHit>& nr_alignments,
                                                        transcripts.size());
         _fpkm_covariance = ublas::zero_matrix<double>(transcripts.size(), 
                                                       transcripts.size());
-        _gamma_bootstrap_covariance = ublas::zero_matrix<double>(transcripts.size(), 
-                                                       transcripts.size());
+        
 		return true;
     }
 	
@@ -1795,8 +2039,7 @@ bool AbundanceGroup::calculate_gammas(const vector<MateHit>& nr_alignments,
                                                                     transcripts.size());
         _fpkm_covariance = ublas::zero_matrix<double>(transcripts.size(), 
                                                       transcripts.size());
-        _gamma_bootstrap_covariance = ublas::zero_matrix<double>(transcripts.size(), 
-                                                                 transcripts.size());
+        
 		return true;
 	}
 	
@@ -1833,13 +2076,6 @@ bool AbundanceGroup::calculate_gammas(const vector<MateHit>& nr_alignments,
 	{
         ublas::vector<double> gamma_mle(filtered_gammas.size());
         std::copy(filtered_gammas.begin(), filtered_gammas.end(), gamma_mle.begin());
-        
-        ublas::vector<double> gamma_map_estimate = ublas::zero_vector<double>(filtered_gammas.size());
-        ublas::matrix<double> gamma_map_covariance = ublas::zero_matrix<double>(N,N);
-        double cross_replicate_js = 0.0;
-        
-        ublas::matrix<double> empir_covariance = ublas::zero_matrix<double>(N,N);
-        
     }
 	
 	for (size_t i = 0; i < filtered_gammas.size(); ++i)
@@ -1858,8 +2094,7 @@ bool AbundanceGroup::calculate_gammas(const vector<MateHit>& nr_alignments,
     
 	ublas::matrix<double> updated_gamma_cov;
 	updated_gamma_cov = ublas::zero_matrix<double>(N, N);
-    ublas::matrix<double> updated_gamma_bootstrap_cov;
-    updated_gamma_bootstrap_cov = ublas::zero_matrix<double>(N, N);
+    
     ublas::matrix<double> updated_count_cov;
     updated_count_cov = ublas::zero_matrix<double>(N, N);
     ublas::matrix<double> updated_iterated_exp_count_cov;
@@ -1901,8 +2136,7 @@ bool AbundanceGroup::calculate_gammas(const vector<MateHit>& nr_alignments,
 				{
 					updated_gamma_cov(i,j) = _gamma_covariance(scaff_present[i],
 															   scaff_present[j]);
-                    updated_gamma_bootstrap_cov(i,j) = _gamma_bootstrap_covariance(scaff_present[i],
-                                                                                   scaff_present[j]);
+                    
                     updated_iterated_exp_count_cov(i,j) = _iterated_exp_count_covariance(scaff_present[i],
                                                                                          scaff_present[j]);
                     // Should still be empty but let's do these for consistency:
@@ -1955,12 +2189,44 @@ bool AbundanceGroup::calculate_gammas(const vector<MateHit>& nr_alignments,
 	_gamma_covariance = updated_gamma_cov;
     _count_covariance = updated_count_cov;
     _iterated_exp_count_covariance = updated_iterated_exp_count_cov;
-    _gamma_bootstrap_covariance = updated_gamma_bootstrap_cov;
     _fpkm_covariance = updated_fpkm_cov;
 	
 	return (status() == NUMERIC_OK);
 }
 
+void calculate_assignment_probs(const Eigen::VectorXd& alignment_multiplicities, 
+                                const Eigen::MatrixXd& transcript_cond_probs,
+                                const Eigen::VectorXd& proposed_gammas,
+                                Eigen::MatrixXd& assignment_probs)
+{
+//    vector<double> u(nr_alignments.size());
+//    for (size_t i = 0; i < alignment_multiplicity.size(); ++i)
+//    {
+//        u[i] = nr_alignments[i].collapse_mass();
+//    }
+    
+    //ublas::vector<double> total_cond_prob = ublas::prod(proposed_gammas,transcript_cond_probs);
+    Eigen::VectorXd total_cond_prob = proposed_gammas.transpose() * transcript_cond_probs ;
+    
+    // Compute the marginal conditional probability for each fragment against each isoform
+    //ublas::matrix<double>  marg_cond_prob = ublas::zero_matrix<double>(transcript_cond_probs.size1(), transcript_cond_probs.size2());
+    Eigen::MatrixXd marg_cond_prob(transcript_cond_probs.rows(), transcript_cond_probs.cols());
+    
+    for (size_t i = 0; i < alignment_multiplicities.size(); ++i)
+    {
+        marg_cond_prob.array().col(i) = proposed_gammas.array() * transcript_cond_probs.array().col(i);
+        
+        if (total_cond_prob(i) > 0)
+        {
+            marg_cond_prob.array().col(i) /= total_cond_prob(i);
+            //column(marg_cond_prob,i) /= total_cond_prob(i);
+        }
+    }
+    
+    assignment_probs = marg_cond_prob;
+}
+
+
 void AbundanceGroup::calculate_iterated_exp_count_covariance(const vector<MateHit>& nr_alignments, 
                                                              const vector<shared_ptr<Abundance> >& transcripts)
 {
@@ -2016,19 +2282,8 @@ void AbundanceGroup::calculate_iterated_exp_count_covariance(const vector<MateHi
     
     double total_var = 0.0;
     
-    double num_salient_frags = 0.0;
-    //double num_unsalient_frags = 0.0;
-    double num_frags = 0.0;
-    
-    //iterate over fragments
-    for (size_t i = 0; i < marg_cond_prob.size2(); ++i)
-    {
-        num_frags += u[i];
-        //cerr << u[i] << endl;
-    }
-    
     ublas::vector<double> expected_counts = ublas::zero_vector<double>(cond_probs.size());
-    
+
     //iterate over fragments
     for (size_t i = 0; i < marg_cond_prob.size2(); ++i)
     {
@@ -2037,45 +2292,54 @@ void AbundanceGroup::calculate_iterated_exp_count_covariance(const vector<MateHi
         for (size_t j = 0; j < marg_cond_prob.size1(); ++j)
         {
             double c_j_i = marg_cond_prob(j,i);
+            
             expected_counts(j) += u[i] * marg_cond_prob(j,i);
             
-            if (c_j_i == 0 || c_j_i == 1.0)
-                continue;
+            //if (c_j_i == 0 || c_j_i == 1.0)
+            //    continue;
+            
             for (size_t k = 0; k < marg_cond_prob.size1(); ++k)
             {
                 double c_k_i = marg_cond_prob(k,i);
-                if (c_k_i == 0 || c_k_i == 1.0)
-                    continue;
+                //if (c_k_i == 0 || c_k_i == 1.0)
+                //    continue;
                 
                 if (j == k)
                 {
-                    double var = u[i] * c_k_i * (1.0 - c_k_i);
-                    count_covariance(k,k) += var;
-                    assert (var >= 0);
-                    assert (!isnan(var) && !isinf(var));
-                    total_var += var;
+                    if (c_k_i != 0 && c_k_i != 1.0)
+                    {
+                        double var = u[i] * c_k_i * (1.0 - c_k_i);
+                        count_covariance(k,k) += var;
+                        assert (var >= 0);
+                        assert (!isnan(var) && !isinf(var));
+                        total_var += var;
+                    }
                 }
                 else
                 {
-                    double covar = -u[i] * c_k_i * c_j_i;
-                    assert (covar <= 0);
-                    assert (!isnan(covar) && !isinf(covar));
-                    count_covariance(k,j) += covar;
-                }
+                    if (c_k_i != 0 && c_k_i != 1.0 &&
+                        c_j_i != 0 && c_j_i != 1.0)
+                    {
+                        double covar = -u[i] * c_k_i * c_j_i;
+                        assert (covar <= 0);
+                        assert (!isnan(covar) && !isinf(covar));
+                        count_covariance(k,j) += covar;
+                    }
+                } 
             }
         }
 
     }
-    
-    double total_counts = accumulate(expected_counts.begin(), expected_counts.end(), 0);
-    if (total_counts > 0)
-    {
-        for (size_t i = 0; i < transcripts.size(); ++i)
-        {
-            //_abundances[i]->num_fragments(expected_counts(i));
-            _abundances[i]->gamma(expected_counts(i) / total_counts);
-        }
-    }
+        
+//    double total_counts = accumulate(expected_counts.begin(), expected_counts.end(), 0);
+//
+//    if (total_counts > 0)   
+//    {
+//        for (size_t i = 0; i < transcripts.size(); ++i)
+//        {
+//            _abundances[i]->gamma(expected_counts(i) / total_counts);  
+//        } 
+//    }
     
     _iterated_exp_count_covariance = count_covariance;
     
@@ -2099,13 +2363,14 @@ void AbundanceGroup::calculate_iterated_exp_count_covariance(const vector<MateHi
                 //assert(c <= 0);
             }
         }
+        _abundances[i]->num_fragment_uncertainty_var(_iterated_exp_count_covariance(i,i));
     }
 }
 
 void AbundanceGroup::calculate_kappas()
 {
-	size_t num_members = _abundances.size();
-	_kappa_covariance = ublas::matrix<double>(num_members, 
+    size_t num_members = _abundances.size();
+    _kappa_covariance = ublas::matrix<double>(num_members, 
 											  num_members);
 	//cerr << gamma_cov <<endl;
 	
@@ -2115,15 +2380,11 @@ void AbundanceGroup::calculate_kappas()
 	//tss_group.sub_quants = vector<QuantGroup>(isos_in_tss);
 	
 	double S_FPKM = 0.0;
-    double Z_kappa = 0.0;
-    double X_S = 0.0;
 	foreach (shared_ptr<Abundance> pA, _abundances)
 	{
 		if (pA->effective_length() > 0)
 		{
 			S_FPKM += pA->FPKM();
-            Z_kappa += pA->num_fragments() / pA->effective_length();
-            X_S += pA->num_fragments();
 		}
 	}
 	
@@ -2133,11 +2394,7 @@ void AbundanceGroup::calculate_kappas()
 		if (S_FPKM > 0)
 		{
 			pA->kappa(pA->FPKM() / S_FPKM);
-            double kappa = pA->kappa();
-            //fprintf (stderr, "kappa = %lg\n", kappa);
-            //if (kappa < 0.05)
-            //    pA->status(NUMERIC_LOW_DATA);
-		}
+        }
 		else
 		{
 			pA->kappa(0); 
@@ -2149,7 +2406,7 @@ void AbundanceGroup::calculate_kappas()
 		for (size_t m = 0; m < num_members; ++m)
 		{
             double L = _abundances[k]->effective_length() * 
-                       _abundances[m]->effective_length();
+            _abundances[m]->effective_length();
             if (L == 0.0)
             {
                 _kappa_covariance(k,m) = 0.0;
@@ -2157,26 +2414,18 @@ void AbundanceGroup::calculate_kappas()
             else if (m == k)
             {
                 // Use the modeled count variance here instead
-                double l_t = _abundances[k]->effective_length();
-                double M = num_fragments()/mass_fraction();
-                double den = (1000000000.0 / (l_t * M));
-                double counts = num_fragments();
-                //double count_var2 = _abundances[k]->FPKM_variance() / (den*den);
-                double count_var = _count_covariance(k, m);
-                double kappa = _abundances[k]->kappa();
-//                
-//                double kappa_var = count_var / (L * Z_kappa * Z_kappa);
                 double kappa_var;
                 if (S_FPKM)
                 {
-                    kappa_var = _abundances[k]->FPKM_variance() / (S_FPKM * S_FPKM);
+                    kappa_var = _fpkm_covariance(k,k) / (S_FPKM * S_FPKM);
                 }
                 else
                 {
                     kappa_var = 0.0;
                 }
                 
-                assert (!isnan(kappa_var) && !isinf(kappa_var));
+                if (isnan(kappa_var) || isinf(kappa_var)) // to protect against underflow
+                    kappa_var = 0;
                 _kappa_covariance(k,m) = kappa_var;
             }
             else
@@ -2194,6 +2443,131 @@ void AbundanceGroup::calculate_kappas()
             }
 		}
 	}
+
+    
+//	size_t num_members = _abundances.size();
+//	_kappa_covariance = ublas::zero_matrix<double>(num_members, 
+//											  num_members);
+//    if (FPKM() == 0)
+//    {
+//        for (size_t k = 0; k < num_members; ++k)
+//        {
+//            _abundances[k]->kappa(0);
+//        }
+//        return;
+//    }
+//    
+    size_t num_count_draws = _assigned_count_samples.size();
+    vector<Eigen::VectorXd > relative_abundances (num_count_draws, Eigen::VectorXd::Zero(num_members));
+    
+    // We'll use the effective lengths to transform counts into relative abundances,
+    // and then use that to calculate the kappa variances and covariances.
+    Eigen::VectorXd effective_length_recip = Eigen::VectorXd::Zero(_abundances.size());
+    for (size_t i = 0; i < _abundances.size(); ++i)
+    {
+        if (_abundances[i]->effective_length() > 0)
+            effective_length_recip(i) = 1.0 / _abundances[i]->effective_length();
+    }
+    
+    for (size_t i = 0; i < num_count_draws; ++i)
+    {
+        
+        Eigen::VectorXd relative_abundance = effective_length_recip.array() * _assigned_count_samples[i].array();
+        double total = relative_abundance.sum();
+        if (total > 0)
+            relative_abundance /= total;
+        //cerr << relative_abundance.transpose() << endl;
+        relative_abundances[i] = relative_abundance;
+    }
+    
+//    
+//    Eigen::VectorXd expected_relative_abundances = Eigen::VectorXd::Zero(_abundances.size());
+//    
+//    for (size_t i = 0; i < relative_abundances.size(); ++i)
+//    {
+//        expected_relative_abundances += relative_abundances[i];
+//    }
+//    
+//    if (relative_abundances.size() > 0)
+//    {
+//        expected_relative_abundances /= relative_abundances.size();
+//    }
+//    
+//    for (size_t k = 0; k < num_members; ++k)
+//    {
+//        _abundances[k]->kappa(expected_relative_abundances(k));
+//    }
+    
+//    cerr << "======" << endl;
+//    cerr << "updated expected relative abundances: " << endl;
+//    std::cerr << expected_relative_abundances << std::endl;
+//    cerr << "======" << endl;
+//    
+//    cerr << "simulated kappa deviations: " << endl;
+//    for (unsigned i = 0; i < _count_covariance.size1 (); ++ i) 
+//    {
+//        ublas::matrix_row<ublas::matrix<double> > mr (_kappa_covariance, i);
+//        cerr << i << " : " << _abundances[i]->kappa() << " : ";
+//        std::cerr << i << " : " << mr << std::endl;
+//    }
+    
+//    for (size_t i = 0; i < _abundances.size(); ++i)
+//    {
+//        for (size_t j = 0; j < _abundances.size(); ++j)
+//        {
+//            for (size_t k = 0 ; k < relative_abundances.size(); ++k)
+//            {
+//                double r = (relative_abundances[k](i) - expected_relative_abundances(i)) * (relative_abundances[k](j) - expected_relative_abundances(j));
+//                assert (r <= 1.0 && r >= -1);
+//                _kappa_covariance(i,j) += r;
+//                //assert (_kappa_covariance(i,j) >= -1 * relative_abundances.size() && _kappa_covariance(i,j) <= relative_abundances.size());
+//            }
+//        }
+//    }
+    
+//    cerr << "simulated kappa deviations: " << endl;
+//    for (unsigned i = 0; i < _count_covariance.size1 (); ++ i) 
+//    {
+//        ublas::matrix_row<ublas::matrix<double> > mr (_kappa_covariance, i);
+//        cerr << i << " : " << _abundances[i]->kappa() << " : ";
+//        std::cerr << i << " : " << mr << std::endl;
+//    }
+
+    
+//    _kappa_covariance /= relative_abundances.size();
+    
+    vector<double> js_samples;
+    
+    ublas::vector<double> kappa_mean(_abundances.size());
+    for (size_t j = 0; j < _abundances.size(); ++j)
+    {
+        kappa_mean(j) = _abundances[j]->kappa();
+    }
+    
+    ublas::matrix<double> kappa_cov_chol = _kappa_covariance;
+    double ret = cholesky_factorize(kappa_cov_chol);
+    if (ret == 0)
+    {
+        multinormal_generator<double> generator(kappa_mean, kappa_cov_chol);
+        vector<Eigen::VectorXd> multinormal_samples;
+        
+        generate_importance_samples(generator, multinormal_samples, 10000, false);
+
+        // We used to sample the JS using the real assigned count samples, but
+        // that's not quite as accurate as simulating from a multinomial built from
+        // the bounded covariance matrices.
+        
+        //generate_null_js_samples(relative_abundances, 100000, js_samples);
+        generate_null_js_samples(multinormal_samples, 100000, js_samples);
+        
+        _null_js_samples = js_samples;
+        //if (_null_js_samples.size() > 0)
+        //    fprintf(stderr, "Max JS from null: %lg\n",_null_js_samples.back()); 
+    }
+    else
+    {
+        _null_js_samples.clear();
+    }
 }
 
 void get_alignments_from_scaffolds(const vector<shared_ptr<Abundance> >& abundances,
@@ -2219,273 +2593,211 @@ void get_alignments_from_scaffolds(const vector<shared_ptr<Abundance> >& abundan
 	sort(alignments.begin(), alignments.end(), mate_hit_lt);
 }
 
-void round(vector<double> & p) {
-	
-	double KILLP = 0; // kill all probabilities below this
-	
-	for (vector<double>::iterator i = p.begin(); i != p.end(); ++i) {
-		if ((*i) < KILLP) 
-			*i = 0;
-	}
-}
+//void round(Eigen::VectorXd&  p) {
+//	
+//	double KILLP = 0; // kill all probabilities below this
+//	
+//	for (size_t i = 0; i < p.size(); ++i) {
+//		if (p(i) < KILLP) 
+//			p(i) = 0;
+//	}
+//}
 
 void Estep (int N, 
 			int M, 
-			vector<double> const & p,
-			vector<vector<double> >& U,
-			const vector<vector<double> >& cond_probs,
-			const vector<double>& u) {
+			const Eigen::VectorXd& p,
+			Eigen::MatrixXd& U,
+			const Eigen::MatrixXd& cond_probs,
+			const Eigen::VectorXd& alignment_multiplicities) {
 	// given p, fills U with expected frequencies
 	int i,j;	
     
-    vector<double> frag_prob_sums(M, 0.0);
+//    Eigen::VectorXd frag_prob_sums = Eigen::VectorXd::Zero(M);
+//    
+//    for (j = 0; j < N; ++j) 
+//    {
+//        for (i = 0; i < M; ++i) 
+//        {
+//            frag_prob_sums(i) += cond_probs(j,i) * p(j);
+//        }
+//    }
+//    
+//    for (i = 0; i < M; ++i) 
+//    {
+//        frag_prob_sums(i) = frag_prob_sums(i) ? (1.0 / frag_prob_sums(i)) : 0.0;
+//    }
+//    
+//    for (j = 0; j < N; ++j) 
+//    {
+//        for (i = 0; i < M; ++i) 
+//        {
+//            double ProbY = frag_prob_sums(i);
+//            double exp_i_j = alignment_multiplicities(i) * cond_probs(j,i) * p(j) * ProbY;
+//            U(j,i) = exp_i_j;
+//        }
+//    }
     
-    for (j = 0; j < N; ++j) 
+    Eigen::VectorXd frag_prob_sums;// = Eigen::VectorXd::Zero(M);
+    
+//    for (j = 0; j < N; ++j) 
+//    {
+//        for (i = 0; i < M; ++i) 
+//        {
+//            frag_prob_sums(i) += cond_probs(j,i) * p(j);
+//            assert (!isnan(cond_probs(j,i)) && !isinf(cond_probs(j,i)));
+//        }
+//    }
+    
+    frag_prob_sums = p.transpose() * cond_probs;
+    
+    for (i = 0; i < M; ++i) 
     {
-        for (i = 0; i < M; ++i) 
+        assert (!isnan(frag_prob_sums(i)) && !isinf(frag_prob_sums(i)));
+        //double x = frag_prob_sums(i);
+        frag_prob_sums(i) = frag_prob_sums(i) ? (1.0 / frag_prob_sums(i)) : 0.0;
+        if (isnan(frag_prob_sums(i)) || isinf(frag_prob_sums(i)))
         {
-            frag_prob_sums [i] += cond_probs[j][i] * p[j];
+            frag_prob_sums(i) = 0; // protect against overflow/underflow
         }
     }
     
+    Eigen::VectorXd x = frag_prob_sums.array() * alignment_multiplicities.array();
+//    Eigen::MatrixXd y = p.transpose() * cond_probs;
+//    Eigen::MatrixXd UU = y.array() * x.array();
+    
+//    cerr << UU <<endl;
+//    for (j = 0; j < N; ++j) 
+//    {
+//        for (i = 0; i < M; ++i) 
+//        {
+//            //double ProbY = frag_prob_sums(i);
+//            double exp_i_j = cond_probs(j,i) * p(j) * x(i);
+//            U(j,i) = exp_i_j;
+//        }
+//    }
+    
+    U = Eigen::MatrixXd(N,M);
+
     for (i = 0; i < M; ++i) 
     {
-        frag_prob_sums[i] = frag_prob_sums[i] ? (1.0 / frag_prob_sums[i]) : 0.0;
+        //double ProbY = frag_prob_sums(i);
+        //double exp_i_j = cond_probs(j,i) * p(j) * x(i);
+        //U.r = exp_i_j;
+        U.col(i) = cond_probs.col(i).array() * p.array();
     }
-    
     for (j = 0; j < N; ++j) 
     {
-        for (i = 0; i < M; ++i) 
-        {
-            double ProbY = frag_prob_sums[i];
-            double exp_i_j = u[i] * cond_probs[j][i] * p[j] * ProbY;
-            U[j][i] = exp_i_j;
-        }
+        U.array().row(j) *= x.transpose().array();
     }
+    
+    //cerr << UU << endl;
+    //cerr << "==========" << endl;
+    //cerr << U << endl;
+    //cerr << "**********" << endl;
+    //Eigen::ArrayXXd a_cond_probs = cond_probs.array();
+    //Eigen::ArrayXXd a_p = p.array();
+    //Eigen::ArrayXXd a_U = a_p * a_cond_probs.colwise();
+    //U = (.colwise() * p.transpose().array()).matrix();
+    //U = cond_probs.colwise() * p.array();
+    //U = alignment_multiplicities.array() * p.array() * cond_probs.array() * frag_prob_sums.array();
+    //U = (frag_prob_sums.array() * alignment_multiplicities.array()).rowwise() * p.array().colwise() * cond_probs.array().colwise();
 }
 
 
-void Mstep (int N, int M, vector<double> & p, vector<vector<double> > const & U) {
-	vector<double> v(N,0);
+void Mstep (int N, 
+            int M, 
+            Eigen::VectorXd& p, 
+            const Eigen::MatrixXd& U) 
+{
+	Eigen::VectorXd v;// = Eigen::VectorXd::Zero(N);
+    
 	double m = 0;
-	int i,j;
-	
-	//#pragma omp parallel for
-	for (j = 0; j < N; ++j) {
-		//cout << "." <<  v[j] << ".\n";
-		for (i = 0; i < M; ++i) {
-			//	cout << U[i][j] << " \n";
-			v[j] += U[j][i];
-		}
-		m += v[j];
-	}
-	
+    
+	v = U.rowwise().sum();
+    m = v.colwise().sum()(0);
+    
 	if (m)
 	{
-		for (j = 0; j < N; ++j) {
-			p[j] = v[j] / m;
-		}
+		p = v / m;
 	}
 	else
 	{
-        for (j = 0; j < N; ++j) 
-        {
-            p[j] = 0.0;
-        }
+        p = Eigen::VectorXd::Zero(N);
 	}
 }
  
 
 double logLike (int N, 
 				int M, 
-				vector<double> & p,
-				const vector<vector<double> >& cond_prob, 
-				const vector<double>& u,
+				Eigen::VectorXd& p,
+				const Eigen::MatrixXd& cond_prob, 
+				const Eigen::VectorXd& alignment_multiplicities,
                 const vector<double>& log_conv_factors) {
-	int i,j;
+	//int i,j;
 	
 	double ell = accumulate(log_conv_factors.begin(), log_conv_factors.end(), 0.0);
-	double Prob_Y;
-	for (i= 0; i < M; i++) {
-		Prob_Y = 0;
-		for (j= 0; j < N; j++) {
-			Prob_Y += cond_prob[j][i] * p[j];
-		}
-		if (Prob_Y > 0) {
-			ell += (u[i] * log(Prob_Y));
-		}
-	}
-	return ell;
-}
-
-void grad_ascent_step (int N, 
-                       int M, 
-                       vector<double> const & p,
-                       vector<vector<double> >& U,
-                       const vector<vector<double> >& cond_probs,
-                       const vector<double>& u,
-                       vector<double>& newP,
-                       double& epsilon) 
-{
-	// given p, fills U with expected frequencies
-	//int i,j;	
-    
-    vector<double> dLL_dj(N, 0.0);
-    
-    for (size_t i = 0; i < M; ++i)
-    {
-        double denom = 0.0;
-        for (size_t j = 0; j < N; ++j)
-        {
-            denom += p[j] * cond_probs[j][i];
-        }
-        
-        for (size_t j = 0; j < N; ++j)
-        {
-            if (denom > 0)
-            {
-                dLL_dj[j] += u[i] * cond_probs[j][i] / denom;
-            }
-        }
-    }
-    
-    for (size_t j = 0; j < N; ++j)
-    {
-        newP[j] = p[j] + epsilon * dLL_dj[j];
-    }
-    
-    double m = accumulate(newP.begin(), newP.end(), 0.0);
-    if (m > 0)
-    {    
-        for (int j = 0; j < N; ++j) {
-            newP[j] = newP[j] / m;
-        }
-    }
-    else
-    {
-        return;
-    }
-}
-
-double grad_ascent (int N, int M, vector<double> & newP, 
-                    const vector<vector<double> >& cond_prob, 
-                    vector<double> const & u,
-                    vector<double> const & log_conv_factors,
-                    bool& converged) 
-{
-    converged = true;
-    double sum = 0;
-	double newEll = 0;
-	vector<double> p(N,0);
-	vector<vector<double> > U(N, vector<double>(M,0));
-	double ell = 0; 
-	int iter = 0;
-	int j;
-	
-	for (j = 0; j < N; ++j) {
-		p[j] = drand48();
-		sum += p[j];
-	}
-	for (j = 0; j < N; ++j) {
-		p[j] = p[j] / sum;
-	}
-	
-    ell = logLike(N, M, p, cond_prob, u, log_conv_factors);
-    
-    double epsilon = 1e-5;
-    
-    static const double ACCURACY = 1e-6; // convergence criteria
-	
-	while (iter <= 2 || iter < max_mle_iterations) 
-    {
-        grad_ascent_step(N, M, p, U, cond_prob, u, newP, epsilon);
-		
-		newEll = logLike(N, M, newP, cond_prob,u, log_conv_factors);
-		
-        double delta = newEll - ell;
-        //fprintf (stderr, "%g\n", delta);
-        if (delta > 0)
-        {
-            //round(newP);
-			p = newP;
-			ell = newEll;
-            if (abs(delta) < ACCURACY)
-            {
-                break;
-            }
-        }
-        else
+	//double Prob_Y;
+//	for (int i= 0; i < M; i++) {
+//		Prob_Y = 0;
+//		for (int j= 0; j < N; j++) {
+//			Prob_Y += cond_prob(j,i) * p(j);
+//		}
+//		if (Prob_Y > 0) {
+//			ell += (alignment_multiplicities(i) * log(Prob_Y));
+//		}
+//	}
+    Eigen::VectorXd Prob_Ys = p.transpose() * cond_prob;
+    Eigen::VectorXd log_Prob_Ys = Prob_Ys.array().log();
+    //log_Prob_Ys *= alignment_multiplicities;
+    for (int i = 0; i < M; i++) {
+        if (Prob_Ys(i) > 0)
         {
-            //verbose_msg("Reducing EPSILON \n");
-            epsilon /= 10;
+            ell += alignment_multiplicities(i) * log_Prob_Ys(i);
         }
-		iter++;
-	}
-	if (iter == max_mle_iterations)
-    {
-		verbose_msg("Warning: ITERMAX reached in abundance estimation, estimation hasn't fully converged\n");
-        converged = false;
     }
-    verbose_msg("Convergence reached in %d iterations \n", iter);
-	return newEll;
-
+	return ell;
 }
 
-double EM (int N, int M, vector<double> & newP, 
-		   const vector<vector<double> >& cond_prob, 
-		   vector<double> const & u,
-           vector<double> const & log_conv_factors,
-           bool& converged,
-           vector<double>* p_hint) 
+double EM(int N, int M, 
+          Eigen::VectorXd&  newP, 
+          const Eigen::MatrixXd& cond_prob, 
+		  const Eigen::VectorXd& alignment_multiplicities,
+          vector<double> const & log_conv_factors,
+          bool& converged) 
 {
     converged = true;
 	//double sum = 0;
 	double newEll = 0;
-	vector<double> p(N,0);
-	vector<vector<double> > U(N, vector<double>(M,0));
+    Eigen::VectorXd p = Eigen::VectorXd::Zero(N);
+    Eigen::MatrixXd  U = Eigen::MatrixXd::Zero(N,M);
 	double ell = 0; 
 	int iter = 0;
 	int j;
     
-	if (p_hint == NULL)
-    {
-        for (j = 0; j < N; ++j) {
-            //p[j] = drand48();
-            //sum += p[j];
-            p[j] = 1.0/(double)N;
-        }
-    }
-    else
-    {
-        assert (p_hint->size() == N);
-        p = *p_hint;
+    if (N == 0 || M == 0)
+        return NUMERIC_OK;
+    
+    for (j = 0; j < N; ++j) {
+        //p[j] = drand48();
+        //sum += p[j];
+        p(j) = 1.0/(double)N;
     }
+  
     
-//	for (j = 0; j < N; ++j) {
-//		p[j] = p[j] / sum;
-//	}
-	
-	//#ifdef DEBUG
-//	for (j = 0; j < N; ++j) {
-//		cout << p[j] << " ";
-//	}
-//	cout << endl;
-	//#endif
 
-//	static const double ACCURACY = 1e-6; // convergence for EM
     static const double ACCURACY = mle_accuracy; // convergence for EM
     
 	while (((iter <= 2) || (abs(ell - newEll) > ACCURACY)) && (iter < max_mle_iterations)) {
 		if (iter > 0) {
-			round(newP);
+			//round(newP);
 			p = newP;
 			ell = newEll;
 		}
 		
-		Estep(N, M, p, U, cond_prob, u); //  fills U
+		Estep(N, M, p, U, cond_prob, alignment_multiplicities); //  fills U
 		Mstep(N, M, newP,U); // fills p
 		
-		newEll = logLike(N, M, newP, cond_prob,u, log_conv_factors);
+		newEll = logLike(N, M, newP, cond_prob,alignment_multiplicities, log_conv_factors);
 		
 		//fprintf(stderr, "%d\t%lf\n", iter, newEll);
 		
@@ -2556,97 +2868,6 @@ void compute_fisher(const vector<shared_ptr<Abundance> >& transcripts,
 	}
 }
 
-void compute_sample_weights(const ublas::matrix<double>& proposed_cov,
-							const vector<vector<double> >& cond_probs,
-							const vector<ublas::vector<double> >& samples,
-							const vector<double>& u,
-                            const vector<double>& log_conv_factors,
-							double scale,
-							const ublas::vector<double>& MLE,
-							vector<ublas::vector<double> >& weighted_samples,
-							vector<pair<size_t, double> >& sample_weights)
-{
-	if (cond_probs.empty())
-		return;
-	
-	int M = cond_probs.front().size();
-	int N = cond_probs.size();
-	
-	//cerr << "Cov^-1"<<inv_cov << endl;
-	for (size_t i = 0; i < samples.size(); ++i)
-	{
-		vector<double> sample(samples[i].begin(), samples[i].end()); 
-		
-		//cerr << "s: "<<samples[i] << endl;
-		
-
-		
-		double ell = logLike(N,
-                             M,
-                             sample, 
-                             cond_probs, 
-							 u,
-                             log_conv_factors);
-		
-		ublas::vector<double> diff = (samples[i] - MLE);
-		//cerr << "diff: "<<diff << endl;
-		
-		ublas::vector<double> diff_transpose = ublas::trans(diff);
-		//cerr << "diff^T" << diff_transpose << endl;
-		ublas::vector<double> P = prod(proposed_cov, diff);
-		//cerr << "Prod: "<< P << endl;
-		double X = inner_prod(diff_transpose,P);
-		
-		//cerr << diff_transpose << " "<< P << " " << X << endl;
-		
-		double sample_prob = exp(-0.5 * X) / scale;
-		
-		if (sample_prob == 0.0)
-		{
-			//			fprintf(stderr, "Error: sample_prob == 0, %lf after rounding. \n", X);
-			//			cerr << "diff: "<<diff << endl;//cerr << covariance << endl;
-			//			cerr << "Prod: "<< P << endl;
-			//			cerr << "s: "<<samples[i] << endl;
-			//			return false;
-			continue; // prob is zero after rounding, skip this sample
-		}
-		
-		assert (sample_prob);
-		assert (!isinf(sample_prob));
-		assert (!isnan(sample_prob));
-		//cerr << "Prob(sample) = " << sample_prob << endl;
-		double log_weight;
-		
-		
-		if (sample_prob == 0)
-		{
-			continue;
-		}
-		else
-		{
-			//assert (sample_prob > 0.0 && sample_prob <= 1.0);
-			//sample_prob *= scale;
-			double e_p = ell - log(sample_prob);
-			log_weight = e_p;
-		}
-		
-		ublas::vector<double> scaled_sample(N);
-		for (size_t v = 0; v < scaled_sample.size(); ++v)
-		{
-			assert (samples[i][v]);
-			scaled_sample(v) = log_weight + log(samples[i][v]);
-			assert (scaled_sample(v));
-			assert (!isinf(scaled_sample(v)));
-			assert (!isnan(scaled_sample(v)));
-		}
-		
-		//cerr << scaled_sample << endl;
-		weighted_samples.push_back(scaled_sample);
-		
-		sample_weights.push_back(make_pair(i, log_weight));
-	}
-}
-
 AbundanceStatus compute_posterior_expectation(const vector<ublas::vector<double> >& weighted_samples,
                                               const vector<pair<size_t, double> >& sample_weights,
                                               ublas::vector<double>& expectation,
@@ -2718,69 +2939,81 @@ AbundanceStatus compute_posterior_expectation(const vector<ublas::vector<double>
     return NUMERIC_OK;
 }
 
-AbundanceStatus empirical_mean_replicate_gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
+AbundanceStatus empirical_mean_replicate_gamma_mle(vector<shared_ptr<Abundance> >& transcripts,
                                                    const vector<MateHit>& nr_alignments,
                                                    const vector<double>& log_conv_factors,
                                                    ublas::vector<double>& gamma_map_estimate,
                                                    ublas::matrix<double>& gamma_covariance,
-                                                   std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> >& mles_for_read_groups)
+                                                   std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> >& mles_for_read_groups,
+                                                   std::map<shared_ptr<ReadGroupProperties const >, double >& count_per_replicate,
+                                                   std::map<shared_ptr<ReadGroupProperties const >, AbundanceStatus >& status_per_replicate)
 {
     size_t N = transcripts.size();	
 	size_t M = nr_alignments.size();
 
-    set<shared_ptr<ReadGroupProperties const> > rg_props;
+//    set<shared_ptr<ReadGroupProperties const> > rg_props;
     std::vector<ublas::vector<double> > mle_gammas;
-	for (size_t i = 0; i < M; ++i)
-	{
-        rg_props.insert(nr_alignments[i].read_group_props());
-	}
+//	for (std::map<shared_ptr<ReadGroupProperties const >, double >::const_iterator itr =_count_by_replicate.begin(); ++itr != _count_by_replicate.begin(); ++itr)
+//	{
+//        rg_props.insert(itr->first);
+//	}
     
     vector<double> rep_hit_counts;
     
-    for(set<shared_ptr<ReadGroupProperties const> >::iterator itr = rg_props.begin();
-        itr != rg_props.end(); 
+    for(std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> >::iterator itr = mles_for_read_groups.begin();
+        itr != mles_for_read_groups.end(); 
         ++itr)
     {
         vector<MateHit> rep_hits;
         vector<double> rep_log_conv_factors;
-        rep_hit_counts.push_back(0);
+        //rep_hit_counts.push_back(0);
         for (size_t i = 0; i < M; ++i)
         {
-            rep_hits.push_back(nr_alignments[i]);
-            rep_log_conv_factors.push_back(log_conv_factors[i]);
+            //rep_hits.push_back(nr_alignments[i]);
+            //rep_log_conv_factors.push_back(log_conv_factors[i]);
 
-            if (nr_alignments[i].read_group_props() != *itr)
+            if (nr_alignments[i].read_group_props() == itr->first)
             {
-                rep_hits.back().collapse_mass(0);
-                rep_log_conv_factors[rep_log_conv_factors.size() - 1] = 0;
+                //rep_hits.back().collapse_mass(0);
+                rep_hits.push_back(nr_alignments[i]);
+                rep_log_conv_factors.push_back(log_conv_factors[i]);
+                //rep_log_conv_factors[rep_log_conv_factors.size() - 1] = 0;
             }
-            rep_hit_counts[rep_hit_counts.size() - 1] += rep_hits.back().collapse_mass();
+            
+            //rep_hit_counts[rep_hit_counts.size() - 1] += rep_hits.back().collapse_mass();
         }
         
+        rep_hit_counts.push_back(count_per_replicate.find(itr->first)->second);
+        
         //fprintf(stderr,"Replicate # %lu has %lu fragments \n", mle_gammas.size(), rep_hits.size());
         vector<double> rep_gammas(0.0, transcripts.size());
+        vector<shared_ptr<Abundance> > mapped_transcripts; // This collects the transcripts that have alignments mapping to them
+        
+        compute_cond_probs_and_effective_lengths(rep_hits, transcripts, mapped_transcripts);
         
         AbundanceStatus mle_success = gamma_mle(transcripts,
                                                 rep_hits,
                                                 rep_log_conv_factors, 
-                                                rep_gammas);
-        if (mle_success == NUMERIC_OK)
-        {
-            ublas::vector<double> mle = ublas::zero_vector<double>(N);
-            for(size_t i = 0; i < N; ++i)
-            {
-                mle(i) = rep_gammas[i];
-            }
-            cerr << mle << endl;
-            mle_gammas.push_back(mle);
-            mles_for_read_groups[*itr] = mle;
-        }
-        else
+                                                rep_gammas,
+                                                false);
+        //if (mle_success == NUMERIC_OK)
+        
+        ublas::vector<double> mle = ublas::zero_vector<double>(N);
+        for(size_t i = 0; i < N; ++i)
         {
-            // if one replicate fails, let's just not trust any of them
-            mles_for_read_groups.clear();
-            return mle_success;
+            mle(i) = rep_gammas[i];
         }
+        //cerr << mle << endl;
+        mle_gammas.push_back(mle);
+        itr->second = mle;
+        status_per_replicate[itr->first] = mle_success;
+        
+//        else
+//        {
+//            // if one replicate fails, let's just not trust any of them
+//            //mles_for_read_groups.clear();
+//            return mle_success;
+//        }
     }
 
 //    cerr << "***" << endl;
@@ -2908,335 +3141,6 @@ AbundanceStatus calculate_inverse_fisher(const vector<shared_ptr<Abundance> >& t
     return NUMERIC_OK;
 }
 
-AbundanceStatus bayesian_gammas(const vector<shared_ptr<Abundance> >& transcripts,
-                                 const vector<MateHit>& alignments,
-                                 const vector<double>& log_conv_factors,
-                                 const ublas::vector<double>& gamma_mle,
-                                 ublas::vector<double>& gamma_map_estimate,
-                                 ublas::matrix<double>& gamma_map_covariance)
-{
-    
-    ublas::matrix<double> inverse_fisher;
-    
-    // Calculate the mean gamma MLE and covariance matrix across replicates, so
-    // we can use it as the proposal distribution for importance sampling.  This will
-    // make the Bayesian prior more conservative than using the inverse of the 
-    // Fisher Information matrix on the mixed likelihood function.
-    AbundanceStatus fisher_status = calculate_inverse_fisher(transcripts,
-                                                             alignments,
-                                                             gamma_mle,
-                                                             inverse_fisher);
-    
-    
-    double trace = 0.0;
-    for (size_t i = 0; i < gamma_mle.size(); ++i)
-    {
-        trace += inverse_fisher(i,i);
-    }
-    
-    ublas::matrix<double> proposal = inverse_fisher;
-
-#if 1
-    proposal += ublas::identity_matrix<double>(gamma_mle.size()) * (trace / 10.0);
-    proposal *= 10.0;
-#endif
-    
-    if (fisher_status != NUMERIC_OK)
-        return fisher_status;
-    
-    AbundanceStatus map_status = map_estimation(transcripts,
-                                                alignments,
-                                                log_conv_factors,
-                                                gamma_mle,
-                                                proposal,
-                                                gamma_map_estimate,
-                                                gamma_map_covariance);
-    
-    return map_status;
-}
-
-AbundanceStatus bayesian_gammas_exact(const vector<shared_ptr<Abundance> >& transcripts,
-                                      const vector<MateHit>& nr_alignments,
-                                      const vector<double>& log_conv_factors,
-                                      const ublas::vector<double>& gamma_mle,
-                                      ublas::vector<double>& gamma_map_estimate,
-                                      ublas::matrix<double>& gamma_map_covariance)
-{
-    
-    ublas::matrix<double> inverse_fisher;
-    
-    // Calculate the mean gamma MLE and covariance matrix across replicates, so
-    // we can use it as the proposal distribution for importance sampling.  This will
-    // make the Bayesian prior more conservative than using the inverse of the 
-    // Fisher Information matrix on the mixed likelihood function.
-    AbundanceStatus fisher_status = calculate_inverse_fisher(transcripts,
-                                                             nr_alignments,
-                                                             gamma_mle,
-                                                             inverse_fisher);
-    
-    
-    double trace = 0.0;
-    for (size_t i = 0; i < gamma_mle.size(); ++i)
-    {
-        trace += inverse_fisher(i,i);
-    }
-    
-    ublas::matrix<double> proposal = inverse_fisher;
-    
-#if 1
-    proposal += ublas::identity_matrix<double>(gamma_mle.size()) * (trace / 10.0);
-    proposal *= 4.0;
-#endif
-    
-    if (fisher_status != NUMERIC_OK)
-        return fisher_status;
-    
-    AbundanceStatus map_status = map_estimation(transcripts,
-                                                nr_alignments,
-                                                log_conv_factors,
-                                                gamma_mle,
-                                                proposal,
-                                                gamma_map_estimate,
-                                                gamma_map_covariance);
-    return map_status;
-}
-
-
-AbundanceStatus bootstrap_gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
-                                    const vector<MateHit>& nr_alignments,
-                                    const vector<double>& log_conv_factors,
-                                    ublas::vector<double>& gamma_map_estimate,
-                                    ublas::matrix<double>& gamma_covariance,
-                                    double& cross_replicate_js)
-{
-    size_t N = transcripts.size();	
-	size_t M = nr_alignments.size();
-    
-    if (N == 1)
-    {
-        gamma_map_estimate = ublas::vector<double>(1);
-        gamma_map_estimate(0) = 1.0;
-        gamma_covariance = ublas::matrix<double>(1,1);
-        gamma_covariance(0,0) = 0.0;
-        return NUMERIC_OK;
-    }
-
-    vector<MateHit> alignments = nr_alignments;
-    vector<double>  scaled_masses;
-    vector<double>  unscaled_masses;
-    double num_uncollapsed_frags = 0.0;
-    for (size_t i = 0; i < M; ++i)
-    {
-        double uncollapsed_mass = alignments[i].collapse_mass() / alignments[i].common_scale_mass();
-        num_uncollapsed_frags += (uncollapsed_mass);
-        scaled_masses.push_back(alignments[i].collapse_mass());
-        unscaled_masses.push_back(uncollapsed_mass);
-        alignments[i].collapse_mass(uncollapsed_mass);
-    }
-    
-    // FIXME: this has already been computed above, so just pass it in.
-    vector<double> orig_gammas(0.0, transcripts.size());
-    gamma_mle(transcripts,
-              nr_alignments,
-              log_conv_factors, 
-              orig_gammas,
-              false);
-    
-    std::vector<ublas::vector<double> > mle_gammas;
-    
-    boost::uniform_int<> uniform_dist(0,num_uncollapsed_frags-1);
-    boost::mt19937 rng; 
-    boost::variate_generator<boost::mt19937&, boost::uniform_int<> > uniform_gen(rng, uniform_dist); 
-    
-    int num_sample_frags = floor(num_uncollapsed_frags * bootstrap_fraction);
-    
-    if (num_sample_frags <= 0)
-    {
-        return NUMERIC_FAIL;
-    }
-    
-    for (size_t i = 0; i < num_bootstrap_samples; ++i)
-    {
-        vector<int> sample_idxs;
-        for (size_t j = 0; j < num_sample_frags; ++j)
-        {
-            sample_idxs.push_back(uniform_gen());
-        }
-        sort (sample_idxs.begin(), sample_idxs.end());
-        assert (sample_idxs.empty() == false);
-        
-        size_t curr_sample = 0;
-        size_t processed_hits = 0;
-        vector<double> adjusted_masses(alignments.size(), 0);
-        for (size_t j = 0; j < alignments.size(); ++j)
-        {
-            int adjusted_mass = 0.0;
-            while (curr_sample < sample_idxs.size() &&
-                   sample_idxs[curr_sample] >= processed_hits &&
-                   sample_idxs[curr_sample] < processed_hits + alignments[j].collapse_mass())
-            {
-                adjusted_mass++;
-                curr_sample++;
-            }
-            processed_hits += alignments[j].collapse_mass();
-            alignments[j].collapse_mass(adjusted_mass);
-            adjusted_masses[j] = adjusted_mass;
-        }
-        
-        for (size_t j = 0; j < alignments.size(); ++j)
-        {
-            alignments[j].collapse_mass(alignments[j].collapse_mass() * alignments[j].common_scale_mass());
-        }
-        
-        vector<double> bs_gammas(0.0, transcripts.size());
-        
-        AbundanceStatus mle_success = gamma_mle(transcripts,
-                                                alignments,
-                                                log_conv_factors, 
-                                                bs_gammas,
-                                                false,
-                                                &orig_gammas);
-        if (mle_success == NUMERIC_OK)
-        {
-            ublas::vector<double> mle = ublas::zero_vector<double>(N);
-            for(size_t j = 0; j < N; ++j)
-            {
-                mle(j) = bs_gammas[j];
-            }
-            mle_gammas.push_back(mle);
-        }
-        
-        
-        
-        for (size_t j = 0; j < alignments.size(); ++j)
-        {
-            alignments[j].collapse_mass(unscaled_masses[j]);
-        }
-    }
-    
-    //fprintf(stderr, "Ran %lu bootstrap samples succesfully\n", mle_gammas.size());
-    
-    if (mle_gammas.empty())
-        return NUMERIC_FAIL;
-    
-    gamma_covariance = ublas::zero_matrix<double>(N,N);
-    ublas::vector<double> expected_mle_gamma = ublas::zero_vector<double>(N);
-
-    foreach(ublas::vector<double>& mle, mle_gammas)
-    {
-        //cerr << "MLE # "<< MLENUM++ << endl;
-        //cerr << mle << endl;
-        expected_mle_gamma += mle;
-    }
-    expected_mle_gamma /= mle_gammas.size();
-    
-    for (size_t i = 0; i < N; ++i)
-    {
-        for (size_t j = 0; j < N; ++j)
-        {
-            for (size_t k = 0 ; k < mle_gammas.size(); ++k)
-            {
-                double c = (mle_gammas[k](i) - expected_mle_gamma(i)) * (mle_gammas[k](j) - expected_mle_gamma(j));
-                gamma_covariance(i,j) += c;
-            }
-        }
-    }
-    
-    gamma_covariance /= mle_gammas.size();
-    gamma_map_estimate = expected_mle_gamma;
-    
-    //cerr << "MLE: " << expected_mle_gamma << endl;
-    //cerr << "COV:" << endl;
-    //cerr << gamma_covariance << endl;
-    //cerr << "*************" << endl;
-    return NUMERIC_OK;
-}
-
-AbundanceStatus bootstrap_gammas(const vector<shared_ptr<Abundance> >& transcripts,
-                                 const vector<MateHit>& alignments,
-                                 const vector<double>& log_conv_factors,
-                                 ublas::vector<double>& gamma_estimate,
-                                 ublas::matrix<double>& gamma_covariance,
-                                 double& cross_replicate_js)
-{
-    ublas::vector<double> empirical_gamma_mle = gamma_estimate;
-    ublas::matrix<double> empirical_gamma_covariance = gamma_covariance;
-    
-    // Calculate the mean gamma MLE and covariance matrix across replicates, so
-    // we can use it as the proposal distribution for importance sampling.  This will
-    // make the Bayesian prior more conservative than using the inverse of the 
-    // Fisher Information matrix on the mixed likelihood function.
-    AbundanceStatus empirical_mle_status = bootstrap_gamma_mle(transcripts,
-                                                               alignments,
-                                                               log_conv_factors,
-                                                               empirical_gamma_mle,
-                                                               empirical_gamma_covariance,
-                                                               cross_replicate_js);
-    
-    if (empirical_mle_status != NUMERIC_OK)
-        return empirical_mle_status;
-    
-    gamma_estimate = empirical_gamma_mle;
-    gamma_covariance = empirical_gamma_covariance;
-    
-
-    
-    
-
-    return NUMERIC_OK;
-}
-
-AbundanceStatus empirical_replicate_gammas(const vector<shared_ptr<Abundance> >& transcripts,
-                                           const vector<MateHit>& nr_alignments,
-                                           const vector<double>& log_conv_factors,
-                                           ublas::vector<double>& gamma_estimate,
-                                           ublas::matrix<double>& gamma_covariance,
-                                           std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> >& mles_for_read_groups)
-{
-    ublas::vector<double> empirical_gamma_mle = gamma_estimate;
-    ublas::matrix<double> empirical_gamma_covariance = gamma_covariance;
-    
-    // Calculate the mean gamma MLE and covariance matrix across replicates, so
-    // we can use it as the proposal distribution for importance sampling.  This will
-    // make the Bayesian prior more conservative than using the inverse of the 
-    // Fisher Information matrix on the mixed likelihood function.
-    AbundanceStatus empirical_mle_status = empirical_mean_replicate_gamma_mle(transcripts,
-                                                                              nr_alignments,
-                                                                              log_conv_factors,
-                                                                              empirical_gamma_mle,
-                                                                              empirical_gamma_covariance,
-                                                                              mles_for_read_groups);
-    
-    
-    if (empirical_mle_status != NUMERIC_OK)
-        return empirical_mle_status;
-    
-    gamma_estimate = empirical_gamma_mle;
-    gamma_covariance = empirical_gamma_covariance;
-
-#if 0
-//    // Perform a bayesian estimation to improve the gamma estimate and their covariances 
-//    ublas::matrix<double> epsilon = ublas::zero_matrix<double>(empirical_gamma_mle.size(),empirical_gamma_mle.size());
-//	for (size_t i = 0; i < empirical_gamma_mle.size(); ++i)
-//	{
-//		epsilon(i,i) = 1e-6;
-//	}
-//    
-//    empirical_gamma_covariance += epsilon;
-    
-    AbundanceStatus map_status = map_estimation(transcripts,
-                                                nr_alignments,
-                                                log_conv_factors,
-                                                empirical_gamma_mle,
-                                                empirical_gamma_covariance,
-                                                gamma_estimate,
-                                                gamma_covariance);
-    if (map_status != NUMERIC_OK)
-        return map_status;
-#endif
-    return NUMERIC_OK;
-}
-
 AbundanceStatus revise_map_mean_and_cov_estimate(double log_total_weight,
                                                  const ublas::vector<double>& expectation,
                                                  const vector<pair<size_t, double> >& sample_weights,
@@ -3331,105 +3235,6 @@ AbundanceStatus calc_is_scale_factor(const ublas::matrix<double>& covariance_cho
     return NUMERIC_OK;
 }
 
-AbundanceStatus map_estimation(const vector<shared_ptr<Abundance> >& transcripts,
-                               const vector<MateHit>& alignments,
-                               const vector<double>& log_conv_factors,
-                               const ublas::vector<double>& proposal_gamma_mean,
-                               const ublas::matrix<double>& proposal_gamma_covariance,
-                               ublas::vector<double>& gamma_map_estimate,
-                               ublas::matrix<double>& gamma_map_covariance)
-{
-    ublas::matrix<double> covariance_chol = proposal_gamma_covariance;
-    ublas::matrix<double> inv_cov = covariance_chol;
-	double ch = cholesky_factorize(covariance_chol);
-	
-	if (ch != 0.0)
-	{
-		verbose_msg("Warning: Covariance matrix is not positive definite (bad element: %lg)\n", ch);
-		return NUMERIC_FAIL;
-	}
-	
-	bool invertible = chol_invert_matrix(covariance_chol, inv_cov);
-	
-    if (!invertible)
-	{
-		verbose_msg("Warning: Covariance matrix is not invertible\n");
-		return NUMERIC_FAIL;
-	}
-    
-    //cerr << "Cholesky decomposed proposal covariance" << endl;
-    //cerr << covariance_chol << endl;
-    
-	multinormal_generator<double> generator(proposal_gamma_mean, covariance_chol);
-    vector<ublas::vector<double> > samples;
-    
-	generate_importance_samples(generator, samples, num_importance_samples, false);
-	
-	if (samples.size() < 100)
-	{
-		verbose_msg("Warning: not-enough samples for MAP re-estimation\n");
-		return NUMERIC_FAIL;
-	}
-	
-    double is_scale_factor = 0.0; 
-    
-    // Calculate the scaling factor for correcting the proposal distribution bias 
-    // during importance sampling
-	AbundanceStatus scale_status = calc_is_scale_factor(covariance_chol, is_scale_factor);
-	
-    if (scale_status == NUMERIC_FAIL)
-    {
-        return NUMERIC_FAIL;
-    }
-    
-	vector<pair<size_t, double> > sample_weights;
-	
-	ublas::vector<double> expectation(transcripts.size());
-	vector<ublas::vector<double> > weighted_samples;
-	
-	vector<vector<double> > cond_probs(transcripts.size(), vector<double>());
-	for(size_t j = 0; j < transcripts.size(); ++j)
-	{
-		cond_probs[j]= *(transcripts[j]->cond_probs());
-	}
-    
-    vector<double> u(alignments.size());
-	for (size_t i = 0; i < alignments.size(); ++i)
-	{
-		u[i] = alignments[i].collapse_mass();
-	}
-	
-	compute_sample_weights(proposal_gamma_covariance,
-						   cond_probs,
-						   samples,
-						   u,
-                           log_conv_factors,
-						   is_scale_factor,
-						   proposal_gamma_mean,
-						   weighted_samples,
-						   sample_weights);
-	
-    long double log_total_weight = 0.0;
-    
-	AbundanceStatus expectation_ok = compute_posterior_expectation(weighted_samples,
-                                                                   sample_weights,
-                                                                   expectation,
-                                                                   log_total_weight);
-    if (expectation_ok != NUMERIC_OK)
-    {
-        return expectation_ok;
-    }
-	
-    revise_map_mean_and_cov_estimate(log_total_weight,
-                                     expectation, 
-                                     sample_weights, 
-                                     weighted_samples,
-                                     gamma_map_estimate, 
-                                     gamma_map_covariance);
-    
-	return NUMERIC_OK;
-}
-
 template<class M, class PM>
 bool is_identifiable(M &m, PM &pm)
 {
@@ -3467,17 +3272,17 @@ AbundanceStatus gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
                           const vector<MateHit>& nr_alignments,
                           const vector<double>& log_conv_factors,
                           vector<double>& gammas,
-                          bool check_identifiability,
-                          vector<double>* p_hint)
+                          bool check_identifiability)
 {
-	gammas.clear();
+	//gammas.clear();
+    gammas = vector<double>(transcripts.size(), 0);
 	if (transcripts.empty())
 		return NUMERIC_OK;
 	
 	//long double bundle_mass_fraction = bundle_mass / (long double) map_mass;
 	if (transcripts.size() == 1)
 	{
-		gammas.push_back(1.0);
+		gammas = vector<double>(1,1.0);
 		return NUMERIC_OK;
 	}
 	
@@ -3495,16 +3300,20 @@ AbundanceStatus gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
 		
 		//compute_saliencies(cond_probs, saliencies, saliency_weight);
 		
-		vector<double> prob(N,0);
-
+        Eigen::VectorXd prob = Eigen::VectorXd::Zero(N);
+        Eigen::VectorXd _phint = Eigen::VectorXd::Zero(N);
+        
 		double logL;
 		
+        Eigen::MatrixXd cond_probs(N, M);
 		
-		vector<vector<double> > cond_probs(N, vector<double>());
-		for (size_t j = 0; j < N; ++j)
-		{
-			cond_probs[j] = *(transcripts[j]->cond_probs());
-		}
+        for (size_t j = 0; j < cond_probs.rows(); ++j)
+        {
+            for (size_t i = 0; i < cond_probs.cols(); ++i)
+            {
+                cond_probs(j,i) = (*(transcripts[j]->cond_probs()))[i];
+            }
+        }
         
         if (check_identifiability)
         {
@@ -3514,7 +3323,7 @@ AbundanceStatus gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
             {
                 for (size_t i = 0; i < M; ++i)
                 {
-                    if (cond_probs[j][i])
+                    if (cond_probs(j,i))
                     {
                         //compat(i,j) = cond_probs[j][i];
                         compat(i,j) = 1;
@@ -3554,25 +3363,19 @@ AbundanceStatus gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
             identifiable = is_identifiable<ublas::matrix<double>,pmatrix>(reduced_compat,pm);
         }
         
-		vector<double> u(M);
+        Eigen::VectorXd alignment_multiplicities(M);
 		for (size_t i = 0; i < M; ++i)
 		{
-			u[i] = nr_alignments[i].collapse_mass();
+			alignment_multiplicities[i] = nr_alignments[i].collapse_mass();
 		}
         		
-        if (use_em)
-        {
-            logL = EM(N, M, prob, cond_probs, u, log_conv_factors, converged, p_hint);
-        }
-		else
-        {
-            logL = grad_ascent(N, M, prob, cond_probs, u, log_conv_factors, converged);
-        }
+        logL = EM(N, M, prob, cond_probs, alignment_multiplicities, log_conv_factors, converged);
         
-		gammas = prob;
+		gammas = vector<double>(N, 0.0);
 		
 		for (size_t i = 0; i < gammas.size(); ++i)
 		{
+            gammas[i] = prob(i);
 			if (isnan(gammas[i]) || isinf(gammas[i]))
             {
                 return NUMERIC_FAIL;
@@ -3928,3 +3731,57 @@ double get_scaffold_min_doc(int bundle_origin,
 	
 	return min_doc;
 }
+
+bool generate_null_js_samples(const vector<Eigen::VectorXd>& rel_abundances,
+                              size_t num_js_samples,
+                              vector<double>& js_samples)
+{
+    if (rel_abundances.empty())
+        return true;
+    
+    size_t num_abundances = rel_abundances.front().size();
+    
+    if (num_abundances <= 1)
+        return true;
+    //    ublas::vector<double> null_kappa_mean(num_abundances);
+    //    for (size_t i = 0; i < num_abundances; ++i)
+    //    {
+    //        null_kappa_mean(i) = rel_abundances[i];
+    //    }
+    
+    //    cerr << endl << null_kappa_mean << endl;
+    //    for (unsigned i = 0; i < null_kappa_cov.size1 (); ++ i) 
+    //    {
+    //        ublas::matrix_row<ublas::matrix<double> > mr (null_kappa_cov, i);
+    //        std::cerr << i << " : " << mr << std::endl;
+    //    }
+    //    cerr << "======" << endl;
+    
+    //vector<ublas::vector<double> > null_samples;
+    
+    js_samples.clear();
+    
+    //size_t num_samples = std::min(prev_samples.size(), curr_samples.size());
+    size_t num_samples = num_js_samples;
+    vector<Eigen::VectorXd> sample_kappas(2);
+    
+    boost::uniform_int<> null_uniform_dist(0,rel_abundances.size()-1);
+    boost::mt19937 null_rng; 
+    boost::variate_generator<boost::mt19937&, boost::uniform_int<> > null_uniform_gen(null_rng, null_uniform_dist); 
+    
+    for (size_t i = 0; i < num_samples; ++i)
+    {
+		sample_kappas[0] = rel_abundances[null_uniform_gen()];
+        sample_kappas[1] = rel_abundances[null_uniform_gen()];
+        
+		double js = jensen_shannon_distance(sample_kappas);  
+        assert(!isnan(js));
+        //cerr << sample_kappas[0].transpose() << " vs. " <<  sample_kappas[1].transpose() << " = " << js << endl;
+        js_samples.push_back(js);
+    }
+    
+    sort(js_samples.begin(), js_samples.end());
+    
+    return true;
+}
+
diff --git a/src/abundances.h b/src/abundances.h
index ff30b77..51765be 100644
--- a/src/abundances.h
+++ b/src/abundances.h
@@ -17,6 +17,9 @@
 #include <vector>
 #include <boost/numeric/ublas/matrix.hpp>
 #include <boost/numeric/ublas/vector.hpp>
+
+#include <Eigen/Dense>
+
 #include "hits.h"
 #include "scaffolds.h"
 #include "bundles.h"
@@ -34,6 +37,10 @@ struct ConfidenceInterval
 
 enum AbundanceStatus { NUMERIC_OK, NUMERIC_FAIL, NUMERIC_LOW_DATA, NUMERIC_HI_DATA };
 
+typedef map<shared_ptr<ReadGroupProperties const>, double> CountPerReplicateTable;
+typedef map<shared_ptr<ReadGroupProperties const>, double> FPKMPerReplicateTable;
+typedef map<shared_ptr<ReadGroupProperties const>, AbundanceStatus> StatusPerReplicateTable;
+
 class Abundance
 {
 public:
@@ -65,15 +72,36 @@ public:
 	virtual double			kappa() const	= 0;
 	virtual void			kappa(double k)	= 0;
 	
+    // This tracks the final modeled variance in the assigned counts.
 	virtual double			num_fragments() const = 0;
 	virtual void			num_fragments(double nf) = 0;
     
+    // This tracks the final modeled variance in the assigned counts.
+    virtual double num_fragment_var() const	= 0;
+	virtual void num_fragment_var(double nfv) = 0;
+    
+    virtual CountPerReplicateTable num_fragments_by_replicate() const = 0;
+    virtual void            num_fragments_by_replicate(CountPerReplicateTable& cpr) = 0;
+    
+    virtual FPKMPerReplicateTable FPKM_by_replicate() const = 0;
+    virtual void            FPKM_by_replicate(CountPerReplicateTable& cpr) = 0;
+    
+    virtual StatusPerReplicateTable status_by_replicate() const = 0;
+    virtual void status_by_replicate(StatusPerReplicateTable& fpr) = 0;
+    
     virtual double          mass_fraction() const = 0;
 	virtual void            mass_fraction(double mf) = 0;
     
+    // This tracks the fitted variance from the overdispersion model,
+    // and does not include the fragment assignment uncertainty.
     virtual double          mass_variance() const = 0;
 	virtual void            mass_variance(double mv) = 0;
     
+    // This tracks the fragment assignment uncertainty,
+    // and does not include the overdispersion.
+    virtual double          num_fragment_uncertainty_var() const = 0;
+	virtual void            num_fragment_uncertainty_var(double mv) = 0;
+    
 	virtual double			effective_length() const= 0;
 	virtual void			effective_length(double el) = 0;
 	
@@ -111,24 +139,26 @@ public:
 		_gamma(0), 
 		_kappa(1.0), 
 		_num_fragments(0),
+        _num_fragment_var(0),
+        _num_fragment_uncertainty_var(0),
 		_eff_len(0),
 		_cond_probs(NULL),
         _sample_mass_fraction(0.0),
         _sample_mass_variance(0.0){}
 	
-	TranscriptAbundance(const TranscriptAbundance& other)
-	{
-		_status = other._status;
-		_transfrag = other._transfrag;
-		_FPKM = other._FPKM;
-		_FPKM_conf = other._FPKM_conf;
-		_gamma = other._gamma;
-		_num_fragments = other._num_fragments;
-		_eff_len = other._eff_len;
-		_cond_probs = other._cond_probs;
-        _sample_mass_fraction = other._sample_mass_fraction;
-        _sample_mass_variance = other._sample_mass_variance;
-	}
+//	TranscriptAbundance(const TranscriptAbundance& other)
+//	{
+//		_status = other._status;
+//		_transfrag = other._transfrag;
+//		_FPKM = other._FPKM;
+//		_FPKM_conf = other._FPKM_conf;
+//		_gamma = other._gamma;
+//		_num_fragments = other._num_fragments;
+//		_eff_len = other._eff_len;
+//		_cond_probs = other._cond_probs;
+//        _sample_mass_fraction = other._sample_mass_fraction;
+//        _sample_mass_variance = other._sample_mass_variance;
+//	}
 	
 	~TranscriptAbundance()
 	{
@@ -160,9 +190,28 @@ public:
 	double kappa() const					{ return _kappa; }
 	void kappa(double k)					{ _kappa = k; }
 	
+    // This returns the estimated number of fragments
 	double num_fragments() const			{ return _num_fragments; }
 	void num_fragments(double nf)			{ assert (!isnan(nf)); _num_fragments = nf; }
     
+    // This tracks the final modeled variance in the assigned counts.
+    double num_fragment_var() const			{ return _num_fragment_var; }
+	void num_fragment_var(double nfv)		{ assert (!isnan(nfv)); _num_fragment_var = nfv; }
+    
+    // This tracks the fragment assignment uncertainty,
+    // and does not include the overdispersion.
+    double          num_fragment_uncertainty_var() const { return _num_fragment_uncertainty_var; }
+	void            num_fragment_uncertainty_var(double nfv) { assert (!isnan(nfv)); _num_fragment_uncertainty_var = nfv; }
+    
+    CountPerReplicateTable num_fragments_by_replicate() const { return _num_fragments_per_replicate; }
+    void num_fragments_by_replicate(CountPerReplicateTable& cpr) { _num_fragments_per_replicate = cpr; }
+    
+    FPKMPerReplicateTable FPKM_by_replicate() const { return _fpkm_per_replicate; }
+    void FPKM_by_replicate(FPKMPerReplicateTable& fpr) { _fpkm_per_replicate = fpr; }
+    
+    StatusPerReplicateTable status_by_replicate() const { return _status_per_replicate; }
+    void status_by_replicate(StatusPerReplicateTable& fpr) { _status_per_replicate = fpr; }
+    
 	double mass_fraction() const			{ return _sample_mass_fraction; }
 	void mass_fraction(double mf)			{ _sample_mass_fraction = mf; }
 	
@@ -251,6 +300,7 @@ public:
 	
 	virtual const string&	reference_tag() const { return _ref_tag; }
 	virtual void			reference_tag(const string& r) { _ref_tag = r; } 
+    
 	
 private:
 	
@@ -264,6 +314,8 @@ private:
 	double _gamma;
 	double _kappa;
 	double _num_fragments;
+    double _num_fragment_var;
+    double _num_fragment_uncertainty_var;
 	double _eff_len;
 	vector<double>* _cond_probs;
 	
@@ -273,6 +325,10 @@ private:
 	
     long double _sample_mass_fraction;
     long double _sample_mass_variance;
+    
+    CountPerReplicateTable _num_fragments_per_replicate;
+    FPKMPerReplicateTable _fpkm_per_replicate;
+    StatusPerReplicateTable _status_per_replicate;
 };
 
 class AbundanceGroup : public Abundance
@@ -280,24 +336,25 @@ class AbundanceGroup : public Abundance
 public:
 	AbundanceGroup() : _kappa(1.0), _FPKM_variance(0.0), _max_mass_variance(0.0), _salient_frags(0.0), _total_frags(0.0) {}
 	
-	AbundanceGroup(const AbundanceGroup& other) 
-	{
-		_abundances = other._abundances;
-		_iterated_exp_count_covariance = other._iterated_exp_count_covariance;
-        _count_covariance = other._count_covariance;
-        _fpkm_covariance = other._fpkm_covariance;
-        _gamma_covariance = other._gamma_covariance;
-        _gamma_bootstrap_covariance = other._gamma_bootstrap_covariance;
-		_FPKM_conf = other._FPKM_conf;
-		_kappa = other._kappa;
-		_kappa_covariance = other._kappa_covariance;
-		_FPKM_variance = other._FPKM_variance;
-		_description = other._description;
-        _max_mass_variance = other._max_mass_variance;
-        _salient_frags = other._salient_frags;
-        _total_frags = other._total_frags;
-        _read_group_props = other._read_group_props;
-    }
+//	AbundanceGroup(const AbundanceGroup& other) 
+//	{
+//		_abundances = other._abundances;
+//		_iterated_exp_count_covariance = other._iterated_exp_count_covariance;
+//        _count_covariance = other._count_covariance;
+//        _fpkm_covariance = other._fpkm_covariance;
+//        _gamma_covariance = other._gamma_covariance;
+//		_FPKM_conf = other._FPKM_conf;
+//		_kappa = other._kappa;
+//		_kappa_covariance = other._kappa_covariance;
+//		_FPKM_variance = other._FPKM_variance;
+//		_description = other._description;
+//        _max_mass_variance = other._max_mass_variance;
+//        _salient_frags = other._salient_frags;
+//        _total_frags = other._total_frags;
+//        _read_group_props = other._read_group_props;
+//        _assigned_count_samples = other._assigned_count_samples;
+//        _null_js_samples = other._null_js_samples;
+//    }
 	
 	AbundanceGroup(const vector<shared_ptr<Abundance> >& abundances) : 
 		_abundances(abundances), 
@@ -305,7 +362,6 @@ public:
         _count_covariance(ublas::zero_matrix<double>(abundances.size(), abundances.size())), 
         _fpkm_covariance(ublas::zero_matrix<double>(abundances.size(), abundances.size())), 
 		_gamma_covariance(ublas::zero_matrix<double>(abundances.size(), abundances.size())), 
-        _gamma_bootstrap_covariance(ublas::zero_matrix<double>(abundances.size(), abundances.size())), 
 		_kappa_covariance(ublas::zero_matrix<double>(abundances.size(), abundances.size())),
 		_kappa(1.0),
 		_FPKM_variance(0.0), 
@@ -315,16 +371,16 @@ public:
     
 	AbundanceGroup(const vector<shared_ptr<Abundance> >& abundances,
 				   const ublas::matrix<double>& gamma_covariance,
-                   const ublas::matrix<double>& gamma_bootstrap_covariance,
                    const ublas::matrix<double>& iterated_exp_count_covariance,
                    const ublas::matrix<double>& count_covariance,
                    const ublas::matrix<double>& fpkm_covariance,
                    const long double max_mass_variance,
-                   const std::set<shared_ptr<ReadGroupProperties const > >& rg_props); 
+                   const std::set<shared_ptr<ReadGroupProperties const > >& rg_props,
+                   const vector<Eigen::VectorXd>& assigned_count_samples); 
 	
 	AbundanceStatus status() const;
 	void status(AbundanceStatus s)			{ }
-	bool has_member_with_status(AbundanceStatus member_status);
+	bool has_member_with_status(AbundanceStatus member_status) const;
     
 	double FPKM() const;
     void   FPKM(double fpkm)                { }
@@ -344,6 +400,23 @@ public:
 	double num_fragments() const;
 	void num_fragments(double nf)			{  }
     
+    // This tracks the final modeled variance in the assigned counts.
+    double num_fragment_var() const;
+	void num_fragment_var(double nfv)		{  }
+    
+    // This tracks the uncertainty in the assigned counts
+    double num_fragment_uncertainty_var() const;
+	void num_fragment_uncertainty_var(double nfv)		{  }
+    
+    CountPerReplicateTable num_fragments_by_replicate() const;
+    void num_fragments_by_replicate(CountPerReplicateTable& cpr) { }
+    
+    FPKMPerReplicateTable FPKM_by_replicate() const;
+    void FPKM_by_replicate(FPKMPerReplicateTable& fpr) { }
+    
+    StatusPerReplicateTable status_by_replicate() const;
+    void status_by_replicate(StatusPerReplicateTable& fpr) { }
+    
     double mass_fraction() const;
 	void mass_fraction(double mf)			{  }
     
@@ -381,17 +454,18 @@ public:
 	
 	const ublas::matrix<double>& gamma_cov() const { return _gamma_covariance; }
     
-    const ublas::matrix<double>& gamma_bootstrap_cov() const { return _gamma_bootstrap_covariance; }
-    
     const ublas::matrix<double>& iterated_count_cov() const { return _iterated_exp_count_covariance; }
     
     const ublas::matrix<double>& count_cov() const { return _count_covariance; }
     
 	const ublas::matrix<double>& kappa_cov() const { return _kappa_covariance; }
     
-    const ublas::matrix<double>& fpkm_cov() const { return _kappa_covariance; }
-	
+    const ublas::matrix<double>& fpkm_cov() const { return _fpkm_covariance; }
 	
+	const vector<Eigen::VectorXd>& assigned_counts() const { return _assigned_count_samples; }
+    
+    const vector<double> null_js_samples() const { return _null_js_samples; }
+    
 	void calculate_abundance(const vector<MateHit>& alignments);
 	
     void max_mass_variance(double mmv) { _max_mass_variance = mmv; }
@@ -405,6 +479,18 @@ public:
     
     const std::set<shared_ptr<ReadGroupProperties const> >& rg_props() const { return _read_group_props; }
     
+    void init_rg_props(const std::set<shared_ptr<ReadGroupProperties const> >& rg) 
+    { 
+        _count_per_replicate.clear();
+        for ( std::set<shared_ptr<ReadGroupProperties const> >::const_iterator itr = rg.begin();
+             itr != rg.end();
+             ++itr)
+        {
+            _count_per_replicate[*itr] = 0;
+        }
+    }
+    
+    
 private:
 	
 	void FPKM_conf(const ConfidenceInterval& cf)  { _FPKM_conf = cf; }
@@ -414,45 +500,50 @@ private:
 						  const vector<shared_ptr<Abundance> >& transcripts,
 						  const vector<shared_ptr<Abundance> >& mapped_transcripts);
 	void calculate_FPKM_covariance();
-    void estimate_count_covariance();
+    
+    //void estimate_count_covariance();
+    
+    void simulate_count_covariance(const vector<MateHit>& nr_alignments,
+                                   const vector<shared_ptr<Abundance> >& transcripts);
+
     void calculate_conf_intervals();
 	void calculate_locus_scaled_mass_and_variance(const vector<MateHit>& nr_alignments,
                           const vector<shared_ptr<Abundance> >& transcripts);
     void calculate_iterated_exp_count_covariance(const vector<MateHit>& nr_alignments, 
                                                  const vector<shared_ptr<Abundance> >& transcripts);
+    
+        
 	void calculate_kappas();
     
     
 	void update_multi_reads(const vector<MateHit>& alignments, vector<shared_ptr<Abundance> > transcripts);
-
-    
-	void compute_cond_probs_and_effective_lengths(const vector<MateHit>& alignments, 
-												  vector<shared_ptr<Abundance> >& transcripts,
-												  vector<shared_ptr<Abundance> >& mapped_transcripts);
     
     void update_transcript_expression(double locus_mass, double locus_mass_fraction);
     
-    
+    void collect_per_replicate_mass(const vector<MateHit>& alignments,
+                                    vector<shared_ptr<Abundance> >& transcripts);
     
     //void collect_read_group_props();
 	
 	vector<shared_ptr<Abundance> > _abundances;
 	
-    // _count_covariance is the final count covariance matrix.  It's includes our estimates
-    // of transcript-level biological variability on counts
-    ublas::matrix<double> _count_covariance;
-    
     // _iterated_exp_count_covariance is the ITERATED EXPECTATION count covariance matrix.  It's not the 
     // estimated count covariance matrix (i.e. it doesn't include biological variability from
     // the fitted model.
     ublas::matrix<double> _iterated_exp_count_covariance;
+    
+    // _count_covariance is the final count covariance matrix.  It's includes our estimates
+    // of transcript-level biological variability on counts
+    ublas::matrix<double> _count_covariance;
+    
     ublas::matrix<double> _fpkm_covariance;
 	ublas::matrix<double> _gamma_covariance;
-    ublas::matrix<double> _gamma_bootstrap_covariance;
     
 	ConfidenceInterval _FPKM_conf;
 	
 	ublas::matrix<double> _kappa_covariance;
+    ublas::matrix<double> _assign_probs;
+    
 	double _kappa;
 	double _FPKM_variance;
 	string _description;
@@ -460,66 +551,48 @@ private:
     double _salient_frags;
     double _total_frags;
     
+    
+    vector<double> _null_js_samples;
+    
     std::set<shared_ptr<ReadGroupProperties const > > _read_group_props;
+    vector<Eigen::VectorXd> _assigned_count_samples;
+    
+    map<shared_ptr<ReadGroupProperties const>, double> _count_per_replicate;
     //std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> > _mles_for_read_groups;
 };
 
-void compute_compatibilities(vector<shared_ptr<Abundance> >& transcripts,
+void compute_cond_probs_and_effective_lengths(const vector<MateHit>& alignments, 
+                                              vector<shared_ptr<Abundance> >& transcripts,
+                                              vector<shared_ptr<Abundance> >& mapped_transcripts);
+
+void compute_compatibilities(const vector<shared_ptr<Abundance> >& transcripts,
 							 const vector<MateHit>& alignments,
 							 vector<vector<char> >& compatibilities);
 
 void get_alignments_from_scaffolds(const vector<shared_ptr<Abundance> >& abundances,
 								   vector<MateHit>& alignments);
 
-AbundanceStatus empirical_mean_replicate_gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
+AbundanceStatus empirical_mean_replicate_gamma_mle(vector<shared_ptr<Abundance> >& transcripts,
                                                    const vector<MateHit>& nr_alignments,
                                                    const vector<double>& log_conv_factors,
                                                    ublas::vector<double>& gamma_map_estimate,
                                                    ublas::matrix<double>& gamma_covariance,
-                                                   std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> >& mles_for_read_groups);
+                                                   std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> >& mles_for_read_groups,
+                                                   std::map<shared_ptr<ReadGroupProperties const >, double >& count_per_replicate,
+                                                   std::map<shared_ptr<ReadGroupProperties const >, AbundanceStatus >& status_per_replicate);
 
-AbundanceStatus empirical_replicate_gammas(const vector<shared_ptr<Abundance> >& transcripts,
+AbundanceStatus empirical_replicate_gammas(vector<shared_ptr<Abundance> >& transcripts,
                                            const vector<MateHit>& nr_alignments,
                                            const vector<double>& log_conv_factors,
                                            ublas::vector<double>& gamma_map_estimate,
                                            ublas::matrix<double>& gamma_map_covariance,
                                            std::map<shared_ptr<ReadGroupProperties const >, ublas::vector<double> >& mles_for_read_groups);
 
-AbundanceStatus bootstrap_gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
-                                    const vector<MateHit>& nr_alignments,
-                                    const vector<double>& log_conv_factors,
-                                    ublas::vector<double>& gamma_map_estimate,
-                                    ublas::matrix<double>& gamma_covariance,
-                                    double& cross_replicate_js);
-
-AbundanceStatus bootstrap_gammas(const vector<shared_ptr<Abundance> >& transcripts,
-                                 const vector<MateHit>& nr_alignments,
-                                 const vector<double>& log_conv_factors,
-                                 ublas::vector<double>& gamma_map_estimate,
-                                 ublas::matrix<double>& gamma_map_covariance,
-                                 double& cross_replicate_js);
-
-AbundanceStatus bayesian_gammas(const vector<shared_ptr<Abundance> >& transcripts,
-                                 const vector<MateHit>& nr_alignments,
-                                 const vector<double>& log_conv_factors,
-                                 const ublas::vector<double>& gamma_mle,
-                                 ublas::vector<double>& gamma_map_estimate,
-                                 ublas::matrix<double>& gamma_map_covariance);
-
-AbundanceStatus map_estimation(const vector<shared_ptr<Abundance> >& transcripts,
-                               const vector<MateHit>& alignments,
-                               const vector<double>& log_conv_factors,
-                               const ublas::vector<double>&  proposal_gamma_mean,
-                               const ublas::matrix<double>& proposal_gamma_covariance,
-                               ublas::vector<double>& gamma_map_estimate,
-                               ublas::matrix<double>& gamma_map_covariance);
-
 AbundanceStatus gamma_mle(const vector<shared_ptr<Abundance> >& transcripts,
                           const vector<MateHit>& nr_alignments,
                           const vector<double>& log_conv_factors,
                           vector<double>& gammas,
-                          bool check_identifiability = true,
-                          vector<double>* p_hint = NULL);
+                          bool check_identifiability = true);
 
 double compute_doc(int bundle_origin, 
 				   const vector<Scaffold>& scaffolds,
@@ -564,4 +637,13 @@ AbundanceStatus calculate_inverse_fisher(const vector<shared_ptr<Abundance> >& t
                                          const vector<MateHit>& alignments,
                                          const ublas::vector<double>& gamma_mean,
                                          ublas::matrix<double>& inverse_fisher);
+
+bool generate_null_js_samples(const vector<Eigen::VectorXd>& rel_abundances,
+                              size_t num_js_samples,
+                              vector<double>& js_samples);
+
+void calculate_assignment_probs(const Eigen::VectorXd& alignment_multiplicities, 
+                                const Eigen::MatrixXd& transcript_cond_probs,
+                                const Eigen::VectorXd& proposed_gammas,
+                                Eigen::MatrixXd& assignment_probs);
 #endif
diff --git a/src/biascorrection.cpp b/src/biascorrection.cpp
index 0d49851..1dd87ba 100644
--- a/src/biascorrection.cpp
+++ b/src/biascorrection.cpp
@@ -120,14 +120,19 @@ void learn_bias(BundleFactory& bundle_factory, BiasLearner& bl, bool progress_ba
 		if (progress_bar)
 			p_bar.update(bundle_label_buf, bundle.raw_mass());
 		
-		if (bundle.non_redundant_hits().size()==0 || bundle.ref_scaffolds().size() != 1)
+		if (bundle.non_redundant_hits().size()==0)// || bundle.ref_scaffolds().size() != 1)
 		{
 			delete bundle_ptr;
 			continue;
 		}
 
-		bl.preProcessTranscript(*(bundle.ref_scaffolds()[0]));
-			
+		//bl.preProcessTranscript(*(bundle.ref_scaffolds()[0]));
+		
+        for (size_t j = 0; j < bundle.ref_scaffolds().size(); ++j)
+        {
+            bl.preProcessTranscript(*(bundle.ref_scaffolds()[j]));
+        }
+        
 		delete bundle_ptr;
 	}
 	
@@ -264,10 +269,10 @@ void BiasLearner::processTranscript(const std::vector<double>& startHist, const
 		if (i - min_frag_len > endBinCutoff)
 			endBinCutoff = positionBins[++currEndBin]*(seqLen - min_frag_len);
 			
-		_startPosParams(currStartBin, lenClass) += startHist[i]/fpkm;
-		_startPosExp(currStartBin, lenClass) += !(_frag_len_dist->too_short(seqLen-i));
-		_endPosParams(currEndBin, lenClass) += endHist[i]/fpkm;
-		_endPosExp(currEndBin, lenClass) += !(_frag_len_dist->too_short(i+1));
+		_startPosParams(currStartBin, lenClass) += startHist[i];
+		_startPosExp(currStartBin, lenClass) += fpkm*(_frag_len_dist->cdf(seqLen-i));
+		_endPosParams(currEndBin, lenClass) += endHist[i];
+		_endPosExp(currEndBin, lenClass) += fpkm*(_frag_len_dist->cdf(i+1));
 
 		
 		bool start_in_bounds = i-CENTER >= 0 && i+(_m-1)-CENTER < seqLen;
@@ -287,8 +292,8 @@ void BiasLearner::processTranscript(const std::vector<double>& startHist, const
 				int v = seqToInt(seqSlice,paramTypes[j]);
 				if (v >= 0)
 				{
-					_startSeqParams(j,v) += startHist[i]/fpkm;
-					_startSeqExp(j,v) += !(_frag_len_dist->too_short(seqLen-i));
+					_startSeqParams(j,v) += startHist[i];
+					_startSeqExp(j,v) += fpkm*(_frag_len_dist->cdf(seqLen-i));
 				}
 				else // There is an N.  Average over all possible values of N
 				{
@@ -296,8 +301,8 @@ void BiasLearner::processTranscript(const std::vector<double>& startHist, const
 					genNList(seqSlice, 0, paramTypes[j],nList);
 					for (list<int>::iterator it=nList.begin(); it!=nList.end(); ++it)
 					{
-						_startSeqParams(j,*it) += startHist[i]/(fpkm * (double)nList.size());
-						_startSeqExp(j,*it) += !(_frag_len_dist->too_short(seqLen-i))/(double)nList.size();
+						_startSeqParams(j,*it) += startHist[i]/((double)nList.size());
+						_startSeqExp(j,*it) += fpkm*(_frag_len_dist->cdf(seqLen-i))/(double)nList.size();
 					}
 				}
 			}
@@ -309,8 +314,8 @@ void BiasLearner::processTranscript(const std::vector<double>& startHist, const
 				int v = seqToInt(seqSlice, paramTypes[j]);
 				if (v >= 0)
 				{
-					_endSeqParams(j,v) += endHist[i]/fpkm;
-					_endSeqExp(j,v) += !(_frag_len_dist->too_short(seqLen-i));
+					_endSeqParams(j,v) += endHist[i];
+					_endSeqExp(j,v) += fpkm*(_frag_len_dist->cdf(seqLen-i));
 				}
 				else // There is an N.  Average over all possible values of N
 				{
@@ -318,8 +323,8 @@ void BiasLearner::processTranscript(const std::vector<double>& startHist, const
 					genNList(seqSlice, 0, paramTypes[j], nList);
 					for (list<int>::iterator it=nList.begin(); it!=nList.end(); ++it)
 					{
-						_endSeqParams(j,*it) += endHist[i]/(fpkm * (double)nList.size());
-						_endSeqExp(j,*it) += !(_frag_len_dist->too_short(seqLen-i))/(double)nList.size();
+						_endSeqParams(j,*it) += endHist[i]/((double)nList.size());
+						_endSeqExp(j,*it) += fpkm*(_frag_len_dist->cdf(seqLen-i))/(double)nList.size();
 					}
 				}
 			}
diff --git a/src/bundles.cpp b/src/bundles.cpp
index ead07f2..f82d96c 100644
--- a/src/bundles.cpp
+++ b/src/bundles.cpp
@@ -588,7 +588,7 @@ void HitBundle::finalize(bool is_combined)
         {
             foreach (MateHit& hit, _hits)
             {
-                hit.incr_collapse_mass(hit.common_scale_mass());
+                hit.incr_collapse_mass(hit.internal_scale_mass());
             }
             _non_redundant = _hits;
             
@@ -733,8 +733,6 @@ double BundleFactory::next_valid_alignment(const ReadHit*& bh)
         {
             if ((*next_mask_scaff)->left() >= tmp.left())
             {
-                //REMOVE ME:
-                int a = 4;
                 break;
             }
             
@@ -797,7 +795,15 @@ bool BundleFactory::next_bundle_hit_driven(HitBundle& bundle)
         }
         else
         {
-            bundle.add_raw_mass(next_valid_alignment(bh));
+            double raw_mass = next_valid_alignment(bh);
+            if (bh && bh->num_hits() > max_frag_multihits)
+            {
+                skip_read = true;
+            }
+            else
+            {
+                bundle.add_raw_mass(raw_mass);
+            }
         }
 	}
 	
@@ -823,10 +829,18 @@ bool BundleFactory::next_bundle_ref_driven(HitBundle& bundle)
 		const ReadHit* bh = NULL;
 		while(_hit_fac->records_remain())
 		{
-            if (read_skip_fraction == 0.0 || _zeroone() >= read_skip_fraction ||
+            if ((read_skip_fraction == 0.0 || _zeroone() >= read_skip_fraction) ||
                 bundle.hits().size() >= max_frags_per_bundle)
             {
-                bundle.add_raw_mass(next_valid_alignment(bh));
+                double raw_mass = next_valid_alignment(bh);
+                if (bh && bh->num_hits() > max_frag_multihits)
+                {
+                    
+                }
+                else
+                {
+                    bundle.add_raw_mass(raw_mass);
+                }
             }
 		}
         bundle.finalize();
@@ -850,8 +864,7 @@ bool BundleFactory::next_bundle_ref_driven(HitBundle& bundle)
         bool skip_read = false;
 		// If we are randomly throwing out reads, check to see
         // whether this one should be kept.
-        double t = _zeroone();
-        if (read_skip_fraction > 0.0 && _zeroone() < read_skip_fraction ||
+        if ((read_skip_fraction > 0.0 && _zeroone() < read_skip_fraction) ||
             bundle.hits().size() >= max_frags_per_bundle)
         {
             next_valid_alignment(bh);
@@ -859,7 +872,15 @@ bool BundleFactory::next_bundle_ref_driven(HitBundle& bundle)
         }
         else
         {
-            bundle.add_raw_mass(next_valid_alignment(bh));
+            double raw_mass = next_valid_alignment(bh);
+            if (bh && bh->num_hits() > max_frag_multihits)
+            {
+                skip_read = true;
+            }
+            else
+            {
+                bundle.add_raw_mass(raw_mass);
+            }
         }
 
         if (bh == NULL)
@@ -1031,13 +1052,21 @@ bool BundleFactory::_expand_by_hits(HitBundle& bundle)
         bool skip_read = false;
         const ReadHit* bh = NULL;
         
-        if (read_skip_fraction > 0.0 && _zeroone() < read_skip_fraction)
+        if ((read_skip_fraction > 0.0 && _zeroone() < read_skip_fraction))
         {
             skip_read = true;
         }
         else
         {
-            bundle.add_raw_mass(next_valid_alignment(bh));
+            double raw_mass = next_valid_alignment(bh);
+            if (bh && bh->num_hits() > max_frag_multihits)
+            {
+                skip_read = true;
+            }
+            else
+            {
+                bundle.add_raw_mass(raw_mass);
+            }
 		}
         
 		if (bh == NULL)
@@ -1541,3 +1570,401 @@ bool BundleFactory::spans_bad_intron(const ReadHit& read)
 	
 	return false;
 }
+
+void inspect_map(BundleFactory& bundle_factory,
+                 BadIntronTable* bad_introns,
+                 vector<LocusCount>& count_table,
+                 bool progress_bar,
+                 bool show_stats)
+{
+
+	ProgressBar p_bar;
+	if (progress_bar)
+		p_bar = ProgressBar("Inspecting reads and determining fragment length distribution.",bundle_factory.ref_table().size());
+	RefID last_chrom = 0;
+
+	long double map_mass = 0.0;
+    long double norm_map_mass = 0.0;
+	
+	int min_len = numeric_limits<int>::max();
+	int max_len = def_max_frag_len;
+	vector<double> frag_len_hist(def_max_frag_len+1,0);
+	bool has_pairs = false;
+
+	int num_bundles = 0;
+	size_t total_hits = 0;
+	size_t total_non_redundant_hits = 0;
+	
+	//To be used for quartile normalization
+	vector<long double> mass_dist; 	
+	
+	// Store the maximum read length for "first" and "second" reads to report to user.
+	int max_1 = 0;
+	int max_2 = 0;
+	
+	shared_ptr<MultiReadTable> mrt(new MultiReadTable());
+	
+	while(true)
+	{
+		HitBundle* bundle_ptr = new HitBundle();
+		
+		bool valid_bundle = bundle_factory.next_bundle(*bundle_ptr);
+		HitBundle& bundle = *bundle_ptr;
+
+        if (use_compat_mass) //only count hits that are compatible with ref transcripts
+        {
+            // Take raw mass even if bundle is "empty", since we could be out of refs
+            // with remaining hits
+            map_mass += bundle.compatible_mass();
+            if (use_quartile_norm && bundle.compatible_mass() > 0) 
+            {
+                mass_dist.push_back(bundle.compatible_mass());
+            }
+        }
+        else if (use_total_mass) //use all raw mass
+        { 
+            
+            // Take raw mass even if bundle is "empty", since we could be out of refs
+            // with remaining hits
+            map_mass += bundle.raw_mass();
+            if (use_quartile_norm && bundle.raw_mass() > 0) 
+            {
+                mass_dist.push_back(bundle.raw_mass());
+            }
+        }
+        else
+        {
+            fprintf(stderr, "Error: hit counting scheme for normalization is not set!\n");
+            assert(false);
+            exit(1);
+        }
+		
+		const RefSequenceTable& rt = bundle_factory.ref_table();
+		const char* chrom = rt.get_name(bundle.ref_id());
+		char bundle_label_buf[2048];
+        if (chrom)
+        {
+            sprintf(bundle_label_buf, "%s:%d-%d", chrom, bundle.left(), bundle.right());
+            verbose_msg("Inspecting bundle %s with %lu reads\n", bundle_label_buf, bundle.hits().size());
+            count_table.push_back(LocusCount(bundle_label_buf, bundle.raw_mass(), bundle.ref_scaffolds().size()));
+		}
+        
+        if (!valid_bundle)
+		{
+			delete bundle_ptr;
+			break;
+		}
+		num_bundles++;
+        
+        if (progress_bar) 
+        {
+			double inc_amt = last_chrom == bundle.ref_id() ? 0.0 : 1.0;
+			p_bar.update(bundle_label_buf, inc_amt);
+			last_chrom = bundle.ref_id();
+        }
+        
+        if (bad_introns != NULL)
+		{
+			identify_bad_splices(bundle, *bad_introns);
+		}
+		
+		const vector<MateHit>& hits = bundle.non_redundant_hits();
+		if (hits.empty())
+		{
+			delete bundle_ptr;
+			continue;
+		}
+		
+		list<pair<int, int> > open_ranges;
+		int curr_range_start = hits[0].left();
+		int curr_range_end = numeric_limits<int>::max();
+		int next_range_start = -1;
+		
+		total_non_redundant_hits += bundle.non_redundant_hits().size();
+		total_hits += bundle.hits().size();
+		
+		// This first loop calclates the map mass and finds ranges with no introns
+		// Note that we are actually looking at non-redundant hits, which is why we use collapse_mass
+		// This loop will also add multi-reads to the MultiReads table 
+		for (size_t i = 0; i < hits.size(); ++i) 
+		{
+			assert(hits[i].left_alignment());
+            
+            // Add to table if multi-read
+			if (hits[i].is_multi())
+			{
+				mrt->add_hit(hits[i]);
+			}
+			
+			// Find left length
+			int left_len = hits[i].left_alignment()->right()-hits[i].left_alignment()->left();
+			min_len = min(min_len, left_len);
+			if (!hits[i].left_alignment()->contains_splice())
+            {
+				if (hits[i].left_alignment()->is_first())
+                    max_1 = max(max_1, left_len);
+                else
+                    max_2 = max(max_2, left_len);
+            }
+			
+			// Find right length
+			if (hits[i].right_alignment())
+			{
+				int right_len = hits[i].right_alignment()->right()-hits[i].right_alignment()->left();
+				min_len = min(min_len, right_len);
+				if (!hits[i].right_alignment()->contains_splice())
+                {
+                    if (hits[i].right_alignment()->is_first())
+                        max_1 = max(max_1, right_len);
+                    else
+                        max_2 = max(max_2, right_len);
+                }
+                has_pairs = true;
+			}
+			
+			// Find fragment length
+			if (bundle.ref_scaffolds().size()==1 && hits[i].is_pair())
+			// Annotation provided and single isoform gene
+			{
+				int start, end, mate_length;
+				shared_ptr<Scaffold> scaff = bundle.ref_scaffolds()[0];
+				if (scaff->map_frag(hits[i], start, end, mate_length))
+				{
+					if (mate_length >= min_len && mate_length <= max_len)
+						frag_len_hist[mate_length] += hits[i].collapse_mass();
+				}
+			}
+			else if (bundle.ref_scaffolds().empty())
+			// No annotation provided.  Look for ranges.
+			{
+				if (hits[i].left() > curr_range_end)
+				{
+					if (curr_range_end - curr_range_start > max_len)
+						open_ranges.push_back(make_pair(curr_range_start, curr_range_end));
+					curr_range_start = next_range_start;
+					curr_range_end = numeric_limits<int>::max();
+				}
+				if (hits[i].left_alignment()->contains_splice())
+				{
+					if (hits[i].left() - curr_range_start > max_len)
+						open_ranges.push_back(make_pair(curr_range_start, hits[i].left()-1));
+					curr_range_start = max(next_range_start, hits[i].left_alignment()->right());
+				}
+				if (hits[i].right_alignment() && hits[i].right_alignment()->contains_splice())
+				{
+					assert(hits[i].right_alignment()->left() >= hits[i].left());
+					curr_range_end = min(curr_range_end, hits[i].right_alignment()->left()-1);
+					next_range_start = max(next_range_start, hits[i].right());
+				}
+			}
+		}
+        
+        if (bundle.ref_scaffolds().empty() && has_pairs) // No annotation provided
+		{
+			pair<int, int> curr_range(-1,-1);
+			
+			// This second loop uses the ranges found above to find the estimated frag length distribution
+			// It also finds the minimum read length to use in the linear interpolation
+			for (size_t i = 0; i < hits.size(); ++i)
+			{
+				if (hits[i].left() > curr_range.second && open_ranges.empty())
+					break;
+				
+				if (hits[i].left() > curr_range.second)
+				{
+					curr_range = open_ranges.front();
+					open_ranges.pop_front();
+				}
+				
+				if (hits[i].left() >= curr_range.first && hits[i].right() <= curr_range.second && hits[i].is_pair())
+				{
+					int mate_len = hits[i].right()-hits[i].left();
+					if (mate_len <= max_len)
+						frag_len_hist[mate_len] += hits[i].collapse_mass();
+				}
+			}
+		}
+		
+        open_ranges.clear();
+		delete bundle_ptr;
+	}
+	
+    norm_map_mass = map_mass;
+    
+	if (use_quartile_norm && mass_dist.size() > 0)
+	{
+		sort(mass_dist.begin(),mass_dist.end());
+		int upper_quart_index = mass_dist.size() * 0.75;
+		norm_map_mass = mass_dist[upper_quart_index];
+	}
+
+    if (bad_introns != NULL)
+    {
+        size_t alloced = 0;
+        size_t used = 0;
+        size_t num_introns = 0;
+        for (BadIntronTable::const_iterator itr = bad_introns->begin();
+             itr != bad_introns->end();
+             ++itr)
+        {
+            alloced += itr->second.capacity() * sizeof(AugmentedCuffOp);
+            used += itr->second.size() * sizeof(AugmentedCuffOp);
+            num_introns += itr->second.size();
+        }
+        
+        verbose_msg( "Bad intron table has %lu introns: (%lu alloc'd, %lu used)\n", num_introns, alloced, used);
+    	verbose_msg( "Map has %lu hits, %lu are non-redundant\n", total_hits, total_non_redundant_hits);
+    } 
+    
+	if (progress_bar)
+		p_bar.complete();
+	
+	vector<double> frag_len_pdf(max_len+1, 0.0);
+	vector<double> frag_len_cdf(max_len+1, 0.0);
+    long double tot_count = accumulate(frag_len_hist.begin(), frag_len_hist.end(), 0.0 );
+    bool empirical = false;
+	
+	if (user_provided_fld && has_pairs && tot_count >= 10000)
+	{
+		fprintf(stderr, "Warning: Overriding empirical fragment length distribution with user-specified parameters is not recommended.\n");
+	}
+	
+	if (!has_pairs || tot_count < 10000)
+	{
+		if (has_pairs && !user_provided_fld)
+		{
+			fprintf(stderr, "Warning: Using default Gaussian distribution due to insufficient paired-end reads in open ranges.  It is recommended that correct parameters (--frag-len-mean and --frag-len-std-dev) be provided.\n");
+		}
+		tot_count = 0;
+		normal frag_len_norm(def_frag_len_mean, def_frag_len_std_dev);
+		max_len = def_frag_len_mean + 3*def_frag_len_std_dev;
+		for(int i = min_len; i <= max_len; i++)
+		{
+			frag_len_hist[i] = cdf(frag_len_norm, i+0.5)-cdf(frag_len_norm, i-0.5);
+			tot_count += frag_len_hist[i];
+		}
+	}
+	else
+	// Calculate the max frag length and interpolate all zeros between min read len and max frag len
+	{	
+		empirical = true;
+		double curr_total = 0;
+		size_t last_nonzero = min_len-1;
+		for(size_t i = last_nonzero+1; i < frag_len_hist.size(); i++)
+		{
+			if (frag_len_hist[i] > 0)
+			{
+				if (last_nonzero != i-1)
+				{
+					double b = frag_len_hist[last_nonzero];
+					double m = (frag_len_hist[i] - b)/(i-last_nonzero);
+					for (size_t x = 1; x < i - last_nonzero; x++)
+					{
+						frag_len_hist[last_nonzero+x] = m * x + b;
+						tot_count += frag_len_hist[last_nonzero+x];
+						curr_total += frag_len_hist[last_nonzero+x];
+					}	
+				}
+				last_nonzero = i;
+			}
+			
+			curr_total += frag_len_hist[i];
+			
+			if (curr_total/tot_count > 0.9999)
+			{
+				max_len = i; 
+				tot_count = curr_total;
+				break;
+			}
+		}
+	}
+	
+    double mean = 0.0;
+
+    if (output_fld)
+    {
+        FILE* fhist = fopen(string(output_dir + "/frag_len_hist.csv").c_str(),"w");
+        fprintf(fhist, "Length,Count\n");
+        for(size_t i = 1; i < frag_len_hist.size(); i++)
+        {
+            fprintf(fhist, "%zu,%f\n", i, frag_len_hist[i]);
+        }
+        fclose(fhist);
+    }
+
+	// Convert histogram to pdf and cdf, calculate mean
+	int frag_len_mode = 0;
+	for(size_t i = min_len; i <= (size_t)max_len; i++)
+	{
+		frag_len_pdf[i] = frag_len_hist[i]/tot_count;
+		frag_len_cdf[i] = frag_len_cdf[i-1] + frag_len_pdf[i];
+        
+		if (frag_len_pdf[i] > frag_len_pdf[frag_len_mode])
+			frag_len_mode = i;
+        mean += frag_len_pdf[i] * i;
+	}
+    
+    double std_dev =  0.0;
+    for(size_t i = 1; i < frag_len_hist.size(); i++)
+    {
+        std_dev += frag_len_pdf[i] * ((i - mean) * (i - mean));
+    }
+    
+    std_dev = sqrt(std_dev);
+	
+	shared_ptr<ReadGroupProperties> rg_props = bundle_factory.read_group_properties();
+
+    FLDSource source = DEFAULT;
+    if (empirical)
+    {
+        source = LEARNED;
+    }
+    else if (user_provided_fld)
+    {
+        source = USER;
+    }
+
+	shared_ptr<EmpDist const> fld(new EmpDist(frag_len_pdf, frag_len_cdf, frag_len_mode, mean, std_dev, min_len, max_len, source));
+	rg_props->multi_read_table(mrt);
+	rg_props->frag_len_dist(fld);
+	rg_props->normalized_map_mass(norm_map_mass);
+    rg_props->total_map_mass(map_mass);
+
+    if (show_stats)
+    {
+        fprintf(stderr, "> Map Properties:\n");
+        if (use_quartile_norm)
+            fprintf(stderr, ">\tUpper Quartile: %.2Lf\n", norm_map_mass);
+        fprintf(stderr, ">\tNormalized Map Mass: %.2Lf\n", norm_map_mass);
+        fprintf(stderr, ">\tRaw Map Mass: %.2Lf\n", map_mass);
+        if (corr_multi)
+            fprintf(stderr,">\tNumber of Multi-Reads: %zu (with %zu total hits)\n", mrt->num_multireads(), mrt->num_multihits()); 
+    //	if (has_pairs)
+    //		fprintf(stderr, ">\tRead Type: %dbp x %dbp\n", max_1, max_2);
+    //	else
+    //		fprintf(stderr, ">\tRead Type: %dbp single-end\n", max(max_1,max_2));
+
+        if (empirical)
+        {
+            fprintf(stderr, ">\tFragment Length Distribution: Empirical (learned)\n");
+            fprintf(stderr, ">\t              Estimated Mean: %.2f\n", mean);
+            fprintf(stderr, ">\t           Estimated Std Dev: %.2f\n", std_dev);
+        }
+        else
+        {
+            if (user_provided_fld)
+            {
+                fprintf(stderr, ">\tFragment Length Distribution: Truncated Gaussian (user-specified)\n");
+            }
+            else
+            {
+                fprintf(stderr, ">\tFragment Length Distribution: Truncated Gaussian (default)\n");
+            }
+            fprintf(stderr, ">\t              Default Mean: %d\n", def_frag_len_mean);
+            fprintf(stderr, ">\t           Default Std Dev: %d\n", def_frag_len_std_dev);
+        }
+    }
+	bundle_factory.num_bundles(num_bundles);
+	bundle_factory.reset(); 
+	return;
+}
diff --git a/src/bundles.h b/src/bundles.h
index 15f51ee..6b24c46 100644
--- a/src/bundles.h
+++ b/src/bundles.h
@@ -205,9 +205,6 @@ void load_ref_rnas(FILE* ref_mRNA_file,
 
 class BundleFactory
 {
-    boost::mt19937 rng;
-    boost::uniform_01<boost::mt19937> _zeroone;
-    
 public:
     
 	BundleFactory(shared_ptr<HitFactory> fac, BundleMode bm)
@@ -361,6 +358,10 @@ private:
     RefID _prev_ref_id;
     int _num_bundles;
     int _curr_bundle;
+    
+    boost::mt19937 rng;
+    boost::uniform_01<boost::mt19937> _zeroone;
+    
 #if ENABLE_THREADS    
     boost::mutex _factory_lock;
 #endif
@@ -369,385 +370,10 @@ private:
 void identify_bad_splices(const HitBundle& bundle, 
 						  BadIntronTable& bad_splice_ops);
 
-template<class BundleFactoryType>
-void inspect_map(BundleFactoryType& bundle_factory,
-                 BadIntronTable* bad_introns,
-                 vector<LocusCount>& count_table,
-                 bool progress_bar = true)
-{
-
-	ProgressBar p_bar;
-	if (progress_bar)
-		p_bar = ProgressBar("Inspecting reads and determining fragment length distribution.",bundle_factory.ref_table().size());
-	RefID last_chrom = 0;
-
-	long double map_mass = 0.0;
-    long double norm_map_mass = 0.0;
-	
-	int min_len = numeric_limits<int>::max();
-	int max_len = def_max_frag_len;
-	vector<double> frag_len_hist(def_max_frag_len+1,0);
-	bool has_pairs = false;
-
-	int num_bundles = 0;
-	size_t total_hits = 0;
-	size_t total_non_redundant_hits = 0;
-	
-	//To be used for quartile normalization
-	vector<long double> mass_dist; 	
-	
-	// Store the maximum read length for "first" and "second" reads to report to user.
-	int max_1 = 0;
-	int max_2 = 0;
-	
-	shared_ptr<MultiReadTable> mrt(new MultiReadTable());
-	
-	while(true)
-	{
-		HitBundle* bundle_ptr = new HitBundle();
-		
-		bool valid_bundle = bundle_factory.next_bundle(*bundle_ptr);
-		HitBundle& bundle = *bundle_ptr;
-
-        if (use_compat_mass) //only count hits that are compatible with ref transcripts
-        {
-            // Take raw mass even if bundle is "empty", since we could be out of refs
-            // with remaining hits
-            map_mass += bundle.compatible_mass();
-            if (use_quartile_norm && bundle.compatible_mass() > 0) 
-            {
-                mass_dist.push_back(bundle.compatible_mass());
-            }
-        }
-        else if (use_total_mass) //use all raw mass
-        { 
-            
-            // Take raw mass even if bundle is "empty", since we could be out of refs
-            // with remaining hits
-            map_mass += bundle.raw_mass();
-            if (use_quartile_norm && bundle.raw_mass() > 0) 
-            {
-                mass_dist.push_back(bundle.raw_mass());
-            }
-        }
-        else
-        {
-            fprintf(stderr, "Error: hit counting scheme for normalization is not set!\n");
-            assert(false);
-            exit(1);
-        }
-		
-		const RefSequenceTable& rt = bundle_factory.ref_table();
-		const char* chrom = rt.get_name(bundle.ref_id());
-		char bundle_label_buf[2048];
-        if (chrom)
-        {
-            sprintf(bundle_label_buf, "%s:%d-%d", chrom, bundle.left(), bundle.right());
-            verbose_msg("Inspecting bundle %s with %lu reads\n", bundle_label_buf, bundle.hits().size());
-            count_table.push_back(LocusCount(bundle_label_buf, bundle.raw_mass(), bundle.ref_scaffolds().size()));
-		}
-        
-        if (!valid_bundle)
-		{
-			delete bundle_ptr;
-			break;
-		}
-		num_bundles++;
-        
-        if (progress_bar) 
-        {
-			double inc_amt = last_chrom == bundle.ref_id() ? 0.0 : 1.0;
-			p_bar.update(bundle_label_buf, inc_amt);
-			last_chrom = bundle.ref_id();
-        }
-        
-        if (bad_introns != NULL)
-		{
-			identify_bad_splices(bundle, *bad_introns);
-		}
-		
-		const vector<MateHit>& hits = bundle.non_redundant_hits();
-		if (hits.empty())
-		{
-			delete bundle_ptr;
-			continue;
-		}
-		
-		list<pair<int, int> > open_ranges;
-		int curr_range_start = hits[0].left();
-		int curr_range_end = numeric_limits<int>::max();
-		int next_range_start = -1;
-		
-		total_non_redundant_hits += bundle.non_redundant_hits().size();
-		total_hits += bundle.hits().size();
-		
-		// This first loop calclates the map mass and finds ranges with no introns
-		// Note that we are actually looking at non-redundant hits, which is why we use collapse_mass
-		// This loop will also add multi-reads to the MultiReads table 
-		for (size_t i = 0; i < hits.size(); ++i) 
-		{
-			assert(hits[i].left_alignment());
-            
-            // Add to table if multi-read
-			if (hits[i].is_multi())
-			{
-				mrt->add_hit(hits[i]);
-			}
-			
-			// Find left length
-			int left_len = hits[i].left_alignment()->right()-hits[i].left_alignment()->left();
-			min_len = min(min_len, left_len);
-			if (!hits[i].left_alignment()->contains_splice())
-            {
-				if (hits[i].left_alignment()->is_first())
-                    max_1 = max(max_1, left_len);
-                else
-                    max_2 = max(max_2, left_len);
-            }
-			
-			// Find right length
-			if (hits[i].right_alignment())
-			{
-				int right_len = hits[i].right_alignment()->right()-hits[i].right_alignment()->left();
-				min_len = min(min_len, right_len);
-				if (!hits[i].right_alignment()->contains_splice())
-                {
-                    if (hits[i].right_alignment()->is_first())
-                        max_1 = max(max_1, right_len);
-                    else
-                        max_2 = max(max_2, right_len);
-                }
-                has_pairs = true;
-			}
-			
-			// Find fragment length
-			if (bundle.ref_scaffolds().size()==1 && hits[i].is_pair())
-			// Annotation provided and single isoform gene
-			{
-				int start, end, mate_length;
-				shared_ptr<Scaffold> scaff = bundle.ref_scaffolds()[0];
-				if (scaff->map_frag(hits[i], start, end, mate_length))
-				{
-					if (mate_length >= min_len && mate_length <= max_len)
-						frag_len_hist[mate_length] += hits[i].collapse_mass();
-				}
-			}
-			else if (bundle.ref_scaffolds().empty())
-			// No annotation provided.  Look for ranges.
-			{
-				if (hits[i].left() > curr_range_end)
-				{
-					if (curr_range_end - curr_range_start > max_len)
-						open_ranges.push_back(make_pair(curr_range_start, curr_range_end));
-					curr_range_start = next_range_start;
-					curr_range_end = numeric_limits<int>::max();
-				}
-				if (hits[i].left_alignment()->contains_splice())
-				{
-					if (hits[i].left() - curr_range_start > max_len)
-						open_ranges.push_back(make_pair(curr_range_start, hits[i].left()-1));
-					curr_range_start = max(next_range_start, hits[i].left_alignment()->right());
-				}
-				if (hits[i].right_alignment() && hits[i].right_alignment()->contains_splice())
-				{
-					assert(hits[i].right_alignment()->left() >= hits[i].left());
-					curr_range_end = min(curr_range_end, hits[i].right_alignment()->left()-1);
-					next_range_start = max(next_range_start, hits[i].right());
-				}
-			}
-		}
-        
-        if (bundle.ref_scaffolds().empty() && has_pairs) // No annotation provided
-		{
-			pair<int, int> curr_range(-1,-1);
-			
-			// This second loop uses the ranges found above to find the estimated frag length distribution
-			// It also finds the minimum read length to use in the linear interpolation
-			for (size_t i = 0; i < hits.size(); ++i)
-			{
-				if (hits[i].left() > curr_range.second && open_ranges.empty())
-					break;
-				
-				if (hits[i].left() > curr_range.second)
-				{
-					curr_range = open_ranges.front();
-					open_ranges.pop_front();
-				}
-				
-				if (hits[i].left() >= curr_range.first && hits[i].right() <= curr_range.second && hits[i].is_pair())
-				{
-					int mate_len = hits[i].right()-hits[i].left();
-					if (mate_len <= max_len)
-						frag_len_hist[mate_len] += hits[i].collapse_mass();
-				}
-			}
-		}
-		
-        open_ranges.clear();
-		delete bundle_ptr;
-	}
-	
-    norm_map_mass = map_mass;
-    
-	if (use_quartile_norm && mass_dist.size() > 0)
-	{
-		sort(mass_dist.begin(),mass_dist.end());
-		int upper_quart_index = mass_dist.size() * 0.75;
-		norm_map_mass = mass_dist[upper_quart_index];
-	}
-
-    if (bad_introns != NULL)
-    {
-        size_t alloced = 0;
-        size_t used = 0;
-        size_t num_introns = 0;
-        for (BadIntronTable::const_iterator itr = bad_introns->begin();
-             itr != bad_introns->end();
-             ++itr)
-        {
-            alloced += itr->second.capacity() * sizeof(AugmentedCuffOp);
-            used += itr->second.size() * sizeof(AugmentedCuffOp);
-            num_introns += itr->second.size();
-        }
-        
-        verbose_msg( "Bad intron table has %lu introns: (%lu alloc'd, %lu used)\n", num_introns, alloced, used);
-    	verbose_msg( "Map has %lu hits, %lu are non-redundant\n", total_hits, total_non_redundant_hits);
-    } 
-    
-	if (progress_bar)
-		p_bar.complete();
-	
-	vector<double> frag_len_pdf(max_len+1, 0.0);
-	vector<double> frag_len_cdf(max_len+1, 0.0);
-    long double tot_count = accumulate(frag_len_hist.begin(), frag_len_hist.end(), 0.0 );
-    bool empirical = false;
-	
-	if (user_provided_fld && has_pairs && tot_count >= 10000)
-	{
-		fprintf(stderr, "Warning: Overriding empirical fragment length distribution with user-specified parameters is not recommended.\n");
-	}
-	
-	if (!has_pairs || tot_count < 10000)
-	{
-		if (has_pairs && !user_provided_fld)
-		{
-			fprintf(stderr, "Warning: Using default Gaussian distribution due to insufficient paired-end reads in open ranges.  It is recommended that correct parameters (--frag-len-mean and --frag-len-std-dev) be provided.\n");
-		}
-		tot_count = 0;
-		normal frag_len_norm(def_frag_len_mean, def_frag_len_std_dev);
-		max_len = def_frag_len_mean + 3*def_frag_len_std_dev;
-		for(int i = min_len; i <= max_len; i++)
-		{
-			frag_len_hist[i] = cdf(frag_len_norm, i+0.5)-cdf(frag_len_norm, i-0.5);
-			tot_count += frag_len_hist[i];
-		}
-	}
-	else
-	// Calculate the max frag length and interpolate all zeros between min read len and max frag len
-	{	
-		empirical = true;
-		double curr_total = 0;
-		size_t last_nonzero = min_len-1;
-		for(size_t i = last_nonzero+1; i < frag_len_hist.size(); i++)
-		{
-			if (frag_len_hist[i] > 0)
-			{
-				if (last_nonzero != i-1)
-				{
-					double b = frag_len_hist[last_nonzero];
-					double m = (frag_len_hist[i] - b)/(i-last_nonzero);
-					for (size_t x = 1; x < i - last_nonzero; x++)
-					{
-						frag_len_hist[last_nonzero+x] = m * x + b;
-						tot_count += frag_len_hist[last_nonzero+x];
-						curr_total += frag_len_hist[last_nonzero+x];
-					}	
-				}
-				last_nonzero = i;
-			}
-			
-			curr_total += frag_len_hist[i];
-			
-			if (curr_total/tot_count > 0.9999)
-			{
-				max_len = i; 
-				tot_count = curr_total;
-				break;
-			}
-		}
-	}
-	
-    double mean = 0.0;
-
-    if (output_fld)
-    {
-        FILE* fhist = fopen(string(output_dir + "/frag_len_hist.csv").c_str(),"w");
-        fprintf(fhist, "Length,Count\n");
-        for(size_t i = 1; i < frag_len_hist.size(); i++)
-        {
-            fprintf(fhist, "%zu,%f\n", i, frag_len_hist[i]);
-        }
-        fclose(fhist);
-    }
-
-	// Convert histogram to pdf and cdf, calculate mean
-	int frag_len_mode = 0;
-	for(size_t i = min_len; i <= (size_t)max_len; i++)
-	{
-		frag_len_pdf[i] = frag_len_hist[i]/tot_count;
-		frag_len_cdf[i] = frag_len_cdf[i-1] + frag_len_pdf[i];
-        
-		if (frag_len_pdf[i] > frag_len_pdf[frag_len_mode])
-			frag_len_mode = i;
-        mean += frag_len_pdf[i] * i;
-	}
-    
-    double std_dev =  0.0;
-    for(size_t i = 1; i < frag_len_hist.size(); i++)
-    {
-        std_dev += frag_len_pdf[i] * ((i - mean) * (i - mean));
-    }
-    
-    std_dev = sqrt(std_dev);
-	
-	shared_ptr<ReadGroupProperties> rg_props = bundle_factory.read_group_properties();
-	shared_ptr<EmpDist const> fld(new EmpDist(frag_len_pdf, frag_len_cdf, frag_len_mode, mean, std_dev, min_len, max_len));
-	rg_props->multi_read_table(mrt);
-	rg_props->frag_len_dist(fld);
-	rg_props->normalized_map_mass(norm_map_mass);
-    rg_props->total_map_mass(map_mass);
-
-	fprintf(stderr, "> Map Properties:\n");
-	if (use_quartile_norm)
-		fprintf(stderr, ">\tUpper Quartile: %.2Lf\n", norm_map_mass);
-	else
-		fprintf(stderr, ">\tTotal Map Mass: %.2Lf\n", norm_map_mass);
-	if (corr_multi)
-		fprintf(stderr,">\tNumber of Multi-Reads: %zu (with %zu total hits)\n", mrt->num_multireads(), mrt->num_multihits()); 
-//	if (has_pairs)
-//		fprintf(stderr, ">\tRead Type: %dbp x %dbp\n", max_1, max_2);
-//	else
-//		fprintf(stderr, ">\tRead Type: %dbp single-end\n", max(max_1,max_2));
-
-	if (empirical)
-	{
-		fprintf(stderr, ">\tFragment Length Distribution: Empirical (learned)\n");
-		fprintf(stderr, ">\t              Estimated Mean: %.2f\n", mean);
-		fprintf(stderr, ">\t           Estimated Std Dev: %.2f\n", std_dev);
-	}
-	else
-	{
-		if (user_provided_fld)
-			fprintf(stderr, ">\tFragment Length Distribution: Truncated Gaussian (user-specified)\n");
-		else
-			fprintf(stderr, ">\tFragment Length Distribution: Truncated Gaussian (default)\n");
-		fprintf(stderr, ">\t              Default Mean: %d\n", def_frag_len_mean);
-		fprintf(stderr, ">\t           Default Std Dev: %d\n", def_frag_len_std_dev);
-	}
-
-	bundle_factory.num_bundles(num_bundles);
-	bundle_factory.reset(); 
-	return;
-}
+void inspect_map(BundleFactory& bundle_factory,
+					BadIntronTable* bad_introns,
+					vector<LocusCount>& count_table,
+					bool progress_bar = true,
+					bool show_stats = true);
 
 #endif
diff --git a/src/clustering.h b/src/clustering.h
index 7a9a1f8..e9d22a9 100644
--- a/src/clustering.h
+++ b/src/clustering.h
@@ -82,7 +82,7 @@ void cluster_transcripts(const AbundanceGroup& transfrags,
                          ublas::matrix<double>* new_iterated_count = NULL,
                          ublas::matrix<double>* new_count = NULL,
                          ublas::matrix<double>* new_fpkm = NULL,
-                         ublas::matrix<double>* new_gamma_bootstrap = NULL)
+                         vector<Eigen::VectorXd>* new_assigned_counts = NULL)
 {
 	adjacency_list <vecS, vecS, undirectedS> G;
 	
@@ -101,8 +101,8 @@ void cluster_transcripts(const AbundanceGroup& transfrags,
 	vector<vector<size_t> > cluster_indices(transfrags.abundances().size());
 	for (size_t i = 0; i < transfrags.abundances().size(); ++i)
 	{
-		clusters[component[i]][i] = true;
-		cluster_indices[component[i]].push_back(i);
+        clusters[component[i]][i] = true;
+        cluster_indices[component[i]].push_back(i);
 	}
 	for (size_t i = 0; i < cluster_indices.size(); ++i)
 	{
@@ -123,24 +123,26 @@ void cluster_transcripts(const AbundanceGroup& transfrags,
 	if (new_gamma != NULL)
 	{
 		const ublas::matrix<double>& trans_gamma_cov = transfrags.gamma_cov();
-        const ublas::matrix<double>& trans_gamma_bootstrap_cov = transfrags.gamma_bootstrap_cov();
         const ublas::matrix<double>& trans_iterated_count_cov = transfrags.iterated_count_cov();
         const ublas::matrix<double>& trans_count_cov = transfrags.count_cov();
         const ublas::matrix<double>& trans_fpkm_cov = transfrags.fpkm_cov();
+        const vector<Eigen::VectorXd>& trans_assigned_counts = transfrags.assigned_counts();
         
 		ublas::matrix<double>& cov = *new_gamma;
-        ublas::matrix<double>& boot_cov = *new_gamma_bootstrap;
         ublas::matrix<double>& iterated_count_cov = *new_iterated_count;
         ublas::matrix<double>& count_cov = *new_count;
         ublas::matrix<double>& fpkm_cov = *new_fpkm;
+        vector<Eigen::VectorXd>& assigned_counts = *new_assigned_counts;
         
 		// number of primary transcripts for this gene
 		size_t num_pt = cluster_indices.size();
 		cov = ublas::zero_matrix<double>(num_pt, num_pt);
-        boot_cov = ublas::zero_matrix<double>(num_pt, num_pt);
+        
         count_cov = ublas::zero_matrix<double>(num_pt, num_pt);
         iterated_count_cov = ublas::zero_matrix<double>(num_pt, num_pt);
         fpkm_cov = ublas::zero_matrix<double>(num_pt, num_pt);
+        assigned_counts = vector<Eigen::VectorXd>(trans_assigned_counts.size(), Eigen::VectorXd::Zero(num_pt));
+        
 		//cerr << "combined " << combined << endl;
 		
 		//cerr << "locus isoform gamma cov" << gamma_cov << endl;
@@ -155,7 +157,6 @@ void cluster_transcripts(const AbundanceGroup& transfrags,
 					for (size_t k = 0; k < K_isos.size(); ++k)
 					{
 						cov(L,K) += trans_gamma_cov(L_isos[l],K_isos[k]);
-                        boot_cov(L,K) += trans_gamma_bootstrap_cov(L_isos[l],K_isos[k]);
                         count_cov(L,K) += trans_count_cov(L_isos[l],K_isos[k]);
                         iterated_count_cov(L,K) += trans_iterated_count_cov(L_isos[l],K_isos[k]);
                         fpkm_cov(L,K) += trans_fpkm_cov(L_isos[l],K_isos[k]);
@@ -163,6 +164,20 @@ void cluster_transcripts(const AbundanceGroup& transfrags,
 				}
 			}
 		}
+        for (size_t L = 0; L < cluster_indices.size(); ++L)
+        {
+            const vector<size_t>& L_isos = cluster_indices[L];
+            for (size_t i = 0; i < assigned_counts.size(); ++i)
+            {
+                double count = 0.0;
+                for (size_t l = 0; l < L_isos.size(); ++l)
+                {
+                    count += trans_assigned_counts[i](L_isos[l]);
+                }
+                assigned_counts[i](L) = count;
+            }
+        }
+        
 	}
 }
 
diff --git a/src/common.cpp b/src/common.cpp
index 01131a4..8ebab14 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -65,7 +65,7 @@ bool corr_bias = false;
 bool corr_multi = false;
 bool use_quartile_norm = false;
 bool poisson_dispersion = false;
-BiasMode bias_mode = POS_VLMM;
+BiasMode bias_mode = VLMM;
 int def_frag_len_mean = 200;
 int def_frag_len_std_dev = 80;
 int def_max_frag_len = 800;
@@ -112,6 +112,13 @@ int num_bootstrap_samples = 20;
 double bootstrap_fraction = 1.0;
 double bootstrap_delta_gap = 0.001;
 int max_frags_per_bundle = 1000000;
+//bool analytic_diff = false;
+bool no_differential = false;
+double num_frag_count_draws = 1000;
+double num_frag_assignments = 1;
+double max_multiread_fraction = 0.75;
+double max_frag_multihits = 10000000;
+int min_reps_for_js_test = 3;
 
 // SECRET OPTIONS: 
 // These options are just for instrumentation and benchmarking code
@@ -121,8 +128,13 @@ bool no_read_pairs = false;
 int trim_read_length = -1;
 double mle_accuracy = 1e-6;
 
+
+
 // END SECRET OPTIONS
 
+bool bias_run = false;
+
+std::string cmd_str;
 
 map<string, ReadGroupProperties> library_type_table;
 const ReadGroupProperties* global_read_properties = NULL;
@@ -369,8 +381,9 @@ ReadGroupProperties::ReadGroupProperties() :
     _platform(UNKNOWN_PLATFORM),
     _total_map_mass(0.0),
     _norm_map_mass(0.0),
-    _mass_scaling_factor(1.0),
+    _internal_scale_factor(1.0),
+    _external_scale_factor(1.0),
     _complete_fragments(false)
 {
-    _mass_dispersion_model = boost::shared_ptr<MassDispersionModel const>(new PoissonDispersionModel);
+    _mass_dispersion_model = boost::shared_ptr<MassDispersionModel const>(new PoissonDispersionModel(""));
 } 
diff --git a/src/common.h b/src/common.h
index b715e9c..8900e8c 100644
--- a/src/common.h
+++ b/src/common.h
@@ -99,6 +99,13 @@ extern int num_bootstrap_samples;
 extern double bootstrap_fraction;
 extern double bootstrap_delta_gap;
 extern int max_frags_per_bundle;
+//extern bool analytic_diff;
+extern bool no_differential;
+extern double num_frag_count_draws;
+extern double num_frag_assignments;
+extern double max_multiread_fraction;
+extern double max_frag_multihits;
+extern int min_reps_for_js_test;
 
 // SECRET OPTIONS: 
 // These options are just for instrumentation and benchmarking code
@@ -119,6 +126,11 @@ extern boost::thread_specific_ptr<std::string> bundle_label; // for consistent,
 extern boost::shared_ptr<std::string> bundle_label;
 #endif
 
+// Global switch to mark when we're in the middle of learning bias.
+extern bool bias_run;
+
+// Hold the command line string used to run the program
+extern std::string cmd_str;
 
 bool gaurd_assembly();
 
@@ -204,6 +216,13 @@ enum Platform
     SOLID
 };
 
+enum FLDSource
+{
+    LEARNED,
+    USER,
+    DEFAULT
+};
+
 class EmpDist
 {
 	//Vectors only valid between min and max!
@@ -214,10 +233,11 @@ class EmpDist
     double _std_dev;
 	int _min;
 	int _max;
-	
+	FLDSource _source;
+    
 public:
-	EmpDist(std::vector<double>& pdf, std::vector<double>& cdf, int mode, double mean, double std_dev, int min, int max)
-	: _pdf(pdf), _cdf(cdf), _mode(mode), _mean(mean), _std_dev(std_dev), _min(min), _max(max) {}
+	EmpDist(std::vector<double>& pdf, std::vector<double>& cdf, int mode, double mean, double std_dev, int min, int max, FLDSource source)
+	: _pdf(pdf), _cdf(cdf), _mode(mode), _mean(mean), _std_dev(std_dev), _min(min), _max(max), _source(source) {}
 	
 	void pdf(std::vector<double>& pdf)	{ _pdf = pdf; }
 	double pdf(int l) const
@@ -266,6 +286,9 @@ public:
     
     void std_dev(double std_dev)				{ _std_dev = std_dev;  }
 	double std_dev() const					{ return _std_dev; }
+    
+    FLDSource source() const        { return _source; }
+    void source(FLDSource source)   { _source = source; } 
 };
 
 class BiasLearner;
@@ -312,18 +335,24 @@ public:
 	boost::shared_ptr<BiasLearner const> bias_learner() const { return _bias_learner; }
     void bias_learner(boost::shared_ptr<BiasLearner const> bl)  { _bias_learner = bl; } 
 	
-    void mass_scale_factor(double sf) { _mass_scaling_factor = sf; }
-    double mass_scale_factor() const  { return _mass_scaling_factor; }
+    // The internal scaling factor relates replicates to each other, so
+    // that replicates with larger library sizes don't bias the isoform
+    // deconvolution over smaller libraries
+    void internal_scale_factor(double sf) { _internal_scale_factor = sf; }
+    double internal_scale_factor() const  { return _internal_scale_factor; }
+    
+    void external_scale_factor(double sf) { _external_scale_factor = sf; }
+    double external_scale_factor() const  { return _external_scale_factor; }
     
     void complete_fragments(bool c)  { _complete_fragments = c; }
     bool complete_fragments() const { return _complete_fragments; }
     
-    double scale_mass(double unscaled_mass) const 
+    double internally_scale_mass(double unscaled_mass) const 
     { 
-        if (_mass_scaling_factor == 0)
+        if (_internal_scale_factor == 0)
             return unscaled_mass;
         
-        return unscaled_mass * (1.0 / _mass_scaling_factor);
+        return unscaled_mass * (1.0 / _internal_scale_factor);
     }
     
     boost::shared_ptr<const MassDispersionModel> mass_dispersion_model() const 
@@ -339,9 +368,24 @@ public:
     const std::vector<LocusCount>& common_scale_counts() { return _common_scale_counts; }
     void common_scale_counts(const std::vector<LocusCount>& counts) { _common_scale_counts = counts; }
     
+    const std::vector<LocusCount>& raw_counts() { return _raw_counts; }
+    void raw_counts(const std::vector<LocusCount>& counts) { _raw_counts = counts; }
+    
 	boost::shared_ptr<MultiReadTable> multi_read_table() const {return _multi_read_table; }	
 	void multi_read_table(boost::shared_ptr<MultiReadTable> mrt) { _multi_read_table = mrt;	}
 	
+//    const string& description() const { return _description; }
+//    void description(const string& d) { _description = d; }
+    
+    const std::string& condition_name() const { return _condition_name; }
+    void condition_name(const std::string& cd) { _condition_name = cd; }
+    
+    const std::string& file_path() const { return _file_path; }
+    void file_path(const std::string& fp) { _file_path = fp; }
+    
+    int replicate_num() const { return _replicate_num; }
+    void replicate_num(int rn) { _replicate_num = rn; }
+    
 private:
     
     Strandedness _strandedness;
@@ -354,11 +398,17 @@ private:
 	boost::shared_ptr<BiasLearner const> _bias_learner;
 	boost::shared_ptr<MultiReadTable> _multi_read_table;
     
-    double _mass_scaling_factor;
+    double _internal_scale_factor;
+    double _external_scale_factor;
     boost::shared_ptr<const MassDispersionModel> _mass_dispersion_model;
     std::vector<LocusCount> _common_scale_counts;
+    std::vector<LocusCount> _raw_counts;
     
     bool _complete_fragments;
+    
+    std::string _condition_name;
+    std::string _file_path;
+    int _replicate_num;
 };
 
 extern std::map<std::string, ReadGroupProperties> library_type_table;
@@ -433,4 +483,18 @@ std::string cat_strings(const T& container, const char* delimiter=",")
 #define OPT_TRIM_READ_LENGTH        297
 #define OPT_MAX_DELTA_GAP           298
 #define OPT_MLE_MIN_ACC             299
+//#define OPT_ANALYTIC_DIFF           300
+#define OPT_NO_DIFF                 301
+#define OPT_GEOMETRIC_NORM          302
+#define OPT_RAW_MAPPED_NORM         303
+#define OPT_NUM_FRAG_COUNT_DRAWS    304
+#define OPT_NUM_FRAG_ASSIGN_DRAWS   305
+#define OPT_MAX_MULTIREAD_FRACTION  306
+#define OPT_LOCUS_COUNT_DISPERSION  307
+#define OPT_MIN_OUTLIER_P           308
+#define OPT_FRAG_MAX_MULTIHITS      309
+#define OPT_MIN_REPS_FOR_JS_TEST    310
+#define OPT_OLAP_RADIUS             311
+
+
 #endif
diff --git a/src/cuffcompare.cpp b/src/cuffcompare.cpp
index 07257bb..198ffa1 100644
--- a/src/cuffcompare.cpp
+++ b/src/cuffcompare.cpp
@@ -116,9 +116,6 @@ class GSeqTrack {
   bool operator==(GSeqTrack& d){
       return (gseq_id==d.gseq_id);
       }
-  bool operator>(GSeqTrack& d){
-     return (gseq_id>d.gseq_id);
-     }
   bool operator<(GSeqTrack& d){
      return (gseq_id<d.gseq_id);
      }
@@ -170,6 +167,11 @@ void show_usage() {
   }
 
 int main(int argc, char * const argv[]) {
+
+#ifdef HEAPROFILE
+  if (!IsHeapProfilerRunning())
+      HeapProfilerStart("./cuffcompare_dbg.hprof");
+#endif
   GArgs args(argc, argv, "XDTMNVGSCKRLhp:c:d:s:i:n:r:o:");
   int e;
   if ((e=args.isError())>0) {
@@ -216,6 +218,8 @@ int main(int argc, char * const argv[]) {
           numqryfiles=args.startNonOpt();
           char *infile=NULL;
           if (numqryfiles>0) {
+            if (numqryfiles>6) 
+               gtf_tracking_largeScale=true;
             while ((infile=args.nextNonOpt())!=NULL) {
               if (!fileExists(infile)) GError("Error: cannot locate input file: %s\n", infile);
               qryfiles.Add(new GStr(infile));
@@ -857,9 +861,6 @@ class GProtCl {
    bool operator==(GProtCl& cl) {
     return this==&cl;
     }
-   bool operator>(GProtCl& cl) {
-     return (this>&cl);
-    }
    bool operator<(GProtCl& cl) {
     return (this<&cl);
     }
@@ -1509,8 +1510,6 @@ GSeqTrack* findGSeqTrack(int gsid) {
   return gseqtracks[fidx];
 }
 
-
-
 GffObj* findRefMatch(GffObj& m, GLocus& rloc, int& ovlen) {
  ovlen=0;
  CTData* mdata=((CTData*)m.uptr);
@@ -1863,7 +1862,7 @@ void printITrack(FILE* ft, GList<GffObj>& mrnas, int qcount, int& cnum) {
        tcons=mrnas[i];
        tmaxcov=tcons->covlen;
        }
-   if (qtdata->isEqHead()) {//head of a equivalency chain
+   if (qtdata->eqhead) {//head of a equivalency chain
       //check if all transcripts in this chain have the same ovlcode
       for (int k=0;k<qtdata->eqlist->Count();k++) {
          GffObj* m=qtdata->eqlist->Get(k);
@@ -1896,7 +1895,7 @@ void printITrack(FILE* ft, GList<GffObj>& mrnas, int qcount, int& cnum) {
    if (ovlcode==0 || ovlcode=='-') ovlcode = (ref==NULL) ? 'u' : '.';
    //-- print columns 1 and 2 as LOCUS_ID and TCONS_ID
    //bool chainHead=(qtdata->eqnext!=NULL && ((qtdata->eqdata & EQHEAD_TAG)!=0));
-   bool chainHead=qtdata->isEqHead();
+   bool chainHead=qtdata->eqhead;
    //bool noChain=((qtdata->eqdata & EQCHAIN_TAGMASK)==0);
    bool noChain=(eqchain==NULL);
    if (chainHead || noChain) {
@@ -2003,7 +2002,7 @@ void findTRMatch(GTrackLocus& loctrack, int qcount, GLocus& rloc) {
     GffObj* rmatch=NULL; //== ref match for this row
     int rovlen=0;
     //if (qtdata->eqnext!=NULL && ((qtdata->eqdata & EQHEAD_TAG)!=0)) { 
-    if (qtdata->isEqHead()) {
+    if (qtdata->eqhead) {
         //EQ chain head -- transfrag equivalency list starts here
         if (qtdata->eqref==NULL) { //find rloc overlap
            if (qt.overlap(rloc.start, rloc.end)) {
diff --git a/src/cuffdiff.cpp b/src/cuffdiff.cpp
index 575b064..02a0df3 100644
--- a/src/cuffdiff.cpp
+++ b/src/cuffdiff.cpp
@@ -31,6 +31,7 @@
 #include "update_check.h"
 
 #include <boost/thread.hpp>
+#include <boost/version.hpp>
 #include <boost/graph/adjacency_list.hpp>
 #include <boost/graph/graph_traits.hpp>
 #include <boost/numeric/ublas/matrix.hpp>
@@ -50,6 +51,10 @@ bool samples_are_time_series = false;
 using namespace std;
 using namespace boost;
 
+bool use_geometric_norm = false;
+bool use_raw_mapped_norm = false;
+bool use_isoform_count_dispersion = true;
+
 // We leave out the short codes for options that don't take an argument
 #if ENABLE_THREADS
 const char *short_options = "m:p:s:c:I:j:L:M:o:b:TNqvuF:";
@@ -61,7 +66,7 @@ const char *short_options = "m:s:c:I:j:L:M:o:b:TNqvuF:";
 
 static struct option long_options[] = {
 {"frag-len-mean",			required_argument,       0,          'm'},
-{"frag-len-std-dev",			required_argument,       0,          's'},
+{"frag-len-std-dev",        required_argument,       0,          's'},
 {"transcript-score-thresh", required_argument,       0,          't'},
 {"pre-mrna-fraction",		required_argument,		 0,			 'j'},
 {"max-intron-length",		required_argument,		 0,			 'I'},
@@ -77,6 +82,8 @@ static struct option long_options[] = {
 {"multi-read-correct",      no_argument,			 0,			 'u'},
 {"time-series",             no_argument,             0,			 'T'},
 {"upper-quartile-norm",     no_argument,	 		 0,	         'N'},
+{"geometric-norm",          no_argument,	 		 0,	         OPT_GEOMETRIC_NORM},
+{"raw-mapped-norm",         no_argument,	 		 0,	         OPT_RAW_MAPPED_NORM},
 {"min-isoform-fraction",    required_argument,       0,          'F'},
 #if ENABLE_THREADS
 {"num-threads",				required_argument,       0,          'p'},
@@ -93,6 +100,10 @@ static struct option long_options[] = {
 {"emit-count-tables",       no_argument,             0,          OPT_EMIT_COUNT_TABLES},
 {"compatible-hits-norm",    no_argument,	 		 0,	         OPT_USE_COMPAT_MASS},
 {"total-hits-norm",         no_argument,	 		 0,	         OPT_USE_TOTAL_MASS},
+//{"analytic-diff",           no_argument,	 		 0,	         OPT_ANALYTIC_DIFF},
+{"no-diff",                 no_argument,	 		 0,	         OPT_NO_DIFF},
+{"num-frag-count-draws",	required_argument,		 0,			 OPT_NUM_FRAG_COUNT_DRAWS},
+{"num-frag-assign-draws",	required_argument,		 0,			 OPT_NUM_FRAG_ASSIGN_DRAWS},
     
 // Some options for testing different stats policies
 {"fisher-covariance",       no_argument,	 		 0,	         OPT_USE_FISHER_COVARIANCE},
@@ -106,6 +117,10 @@ static struct option long_options[] = {
 {"no-read-pairs",           no_argument,	 		 0,          OPT_NO_READ_PAIRS},
 {"trim-read-length",        required_argument,	     0,          OPT_TRIM_READ_LENGTH},
 {"cov-delta",               required_argument,	     0,          OPT_MAX_DELTA_GAP},
+{"locus-count-dispersion",  no_argument,             0,          OPT_LOCUS_COUNT_DISPERSION},
+{"max-frag-multihits",      required_argument,       0,          OPT_FRAG_MAX_MULTIHITS},
+{"min-outlier-p",           required_argument,       0,          OPT_MIN_OUTLIER_P},
+{"min-reps-for-js-test",      required_argument,     0,          OPT_MIN_REPS_FOR_JS_TEST},
 {0, 0, 0, 0} // terminator
 };
 
@@ -127,17 +142,20 @@ void print_usage()
     fprintf(stderr, "  -b/--frag-bias-correct       use bias correction - reference fasta required        [ default:   NULL ]\n");
     fprintf(stderr, "  -u/--multi-read-correct      use 'rescue method' for multi-reads (more accurate)   [ default:  FALSE ]\n");
     fprintf(stderr, "  -N/--upper-quartile-norm     use upper-quartile normalization                      [ default:  FALSE ]\n");
+    fprintf(stderr, "  --geometric-norm             use geometric mean normalization                      [ default:  TRUE ]\n");
+    fprintf(stderr, "  --raw-mapped-norm            use raw mapped count normalized (classic FPKM)        [ default:  FALSE ]\n");
     fprintf(stderr, "  -L/--labels                  comma-separated list of condition labels\n");
 #if ENABLE_THREADS
 	fprintf(stderr, "  -p/--num-threads             number of threads used during quantification          [ default:      1 ]\n");
 #endif
+    fprintf(stderr, "  --no-diff                    Don't generate differential analysis files            [ default:  FALSE ]\n");
 	fprintf(stderr, "\nAdvanced Options:\n");
     fprintf(stderr, "  --library-type               Library prep used for input reads                     [ default:  below ]\n");
     fprintf(stderr, "  -m/--frag-len-mean           average fragment length (unpaired reads only)         [ default:    200 ]\n");
     fprintf(stderr, "  -s/--frag-len-std-dev        fragment length std deviation (unpaired reads only)   [ default:     80 ]\n");
-    fprintf(stderr, "  --num-importance-samples     number of importance samples for MAP restimation      [ default:   1000 ]\n");
-	fprintf(stderr, "  --num-bootstrap-samples      Number of bootstrap replications                      [ default:     20 ]\n");
-    fprintf(stderr, "  --bootstrap-fraction         Fraction of fragments in each bootstrap sample        [ default:    1.0 ]\n");
+    fprintf(stderr, "  --num-importance-samples     number of importance samples for MAP restimation      [ DEPRECATED      ]\n");
+	fprintf(stderr, "  --num-bootstrap-samples      Number of bootstrap replications                      [ DEPRECATED      ]\n");
+    fprintf(stderr, "  --bootstrap-fraction         Fraction of fragments in each bootstrap sample        [ DEPRECATED      ]\n");
     fprintf(stderr, "  --max-mle-iterations         maximum iterations allowed for MLE calculation        [ default:   5000 ]\n");
     fprintf(stderr, "  --compatible-hits-norm       count hits compatible with reference RNAs only        [ default:   TRUE ]\n");
     fprintf(stderr, "  --total-hits-norm            count all hits for normalization                      [ default:  FALSE ]\n");
@@ -147,11 +165,15 @@ void print_usage()
     fprintf(stderr, "  --no-update-check            do not contact server to check for update availability[ default:  FALSE ]\n");    
     fprintf(stderr, "  --emit-count-tables          print count tables used to fit overdispersion         [ default:  FALSE ]\n");
     fprintf(stderr, "  --max-bundle-frags           maximum fragments allowed in a bundle before skipping [ default: 500000 ]\n");
+    fprintf(stderr, "  --num-frag-count-draws       Number of fragment generation samples                 [ default:   1000 ]\n");
+    fprintf(stderr, "  --num-frag-assign-draws      Number of fragment assignment samples per generation  [ default:      1 ]\n");
+    fprintf(stderr, "  --max-frag-multihits         Maximum number of alignments allowed per fragment     [ default: unlim  ]\n");
+    fprintf(stderr, "  --min-outlier-p              Min replicate p value to admit for testing            [ default:   0.01 ]\n");
+    fprintf(stderr, "  --min-reps-for-js-test        Replicates needed for relative isoform shift testing  [ default:      3 ]\n");
     fprintf(stderr, "\nDebugging use only:\n");
     fprintf(stderr, "  --read-skip-fraction         Skip a random subset of reads this size               [ default:    0.0 ]\n");
     fprintf(stderr, "  --no-read-pairs              Break all read pairs                                  [ default:  FALSE ]\n");
     fprintf(stderr, "  --trim-read-length           Trim reads to be this long (keep 5' end)              [ default:   none ]\n");
-    fprintf(stderr, "  --cov-delta                  Maximum gap between bootstrap and IS                  [ default:   2.0  ]\n");
     print_library_table();
 }
 
@@ -332,7 +354,7 @@ int parse_options(int argc, char** argv)
             }
             case OPT_NUM_BOOTSTRAP_SAMPLES:
             {
-                num_bootstrap_samples = parseInt(0, "--num-bootstrap-samples must be at least 1", print_usage);
+                //num_bootstrap_samples = parseInt(1, "--num-bootstrap-samples must be at least 1", print_usage);
                 break;
             }
             case OPT_BOOTSTRAP_FRACTION:
@@ -370,6 +392,57 @@ int parse_options(int argc, char** argv)
                 bootstrap_delta_gap = parseFloat(0, 10000000.0, "--read-skip-fraction must be between 0 and 10000000.0", print_usage);
                 break;
             }
+//            case OPT_ANALYTIC_DIFF:
+//            {
+//                analytic_diff = true;
+//                break;
+//            }
+            case OPT_NO_DIFF:
+            {
+                no_differential = true;
+                break;
+            }
+            case OPT_GEOMETRIC_NORM:
+            {
+                use_geometric_norm = true;
+                break;
+            } 
+            case OPT_RAW_MAPPED_NORM:
+            {
+                use_raw_mapped_norm = true;
+                break;
+            } 
+            case OPT_NUM_FRAG_COUNT_DRAWS:
+            {
+                num_frag_count_draws = parseInt(1, "--num-frag-count-draws must be at least 1", print_usage);
+                break;
+            }
+            case OPT_NUM_FRAG_ASSIGN_DRAWS:
+            {
+                num_frag_assignments = parseInt(1, "--num-frag-assign-draws must be at least 1", print_usage);
+                break;
+            }
+            case OPT_LOCUS_COUNT_DISPERSION:
+            {
+                use_isoform_count_dispersion = false;
+                break;
+            }
+            case OPT_FRAG_MAX_MULTIHITS:
+            {
+                max_frag_multihits = parseInt(1, "--max-frag-multihits must be at least 1", print_usage);
+                break;
+            }
+            case OPT_MIN_OUTLIER_P:
+            {
+                min_outlier_p = parseFloat(0, 1.0, "--min-outlier-p must be between 0 and 1.0", print_usage);
+                break;
+            }
+            case OPT_MIN_REPS_FOR_JS_TEST:
+            {
+                min_reps_for_js_test = parseInt(1, "--min-reps-for-js-test must be at least 1", print_usage);
+                break;
+            }
+                
 			default:
 				print_usage();
 				return 1;
@@ -401,6 +474,16 @@ int parse_options(int argc, char** argv)
         exit(1);
     }
     
+    if (use_raw_mapped_norm + use_geometric_norm + use_quartile_norm > 1)
+    {
+        fprintf(stderr, "Error: Choose one of upper-quartile-norm, geometric-norm, or raw-mapped-norm\n");
+        exit(1);
+    }
+    if (use_raw_mapped_norm + use_geometric_norm + use_quartile_norm == 0)
+    {
+        use_geometric_norm = true;
+    }
+    
     tokenize(sample_label_list, ",", sample_labels);
     
 	allow_junk_filtering = false;
@@ -559,6 +642,175 @@ void print_FPKM_tracking(FILE* fout,
 	}
 }
 
+void print_count_tracking(FILE* fout, 
+						  const FPKMTrackingTable& tracking)
+{
+	fprintf(fout,"tracking_id");
+	FPKMTrackingTable::const_iterator first_itr = tracking.begin();
+	if (first_itr != tracking.end())
+	{
+		const FPKMTracking& track = first_itr->second;
+		const vector<FPKMContext>& fpkms = track.fpkm_series;
+		for (size_t i = 0; i < fpkms.size(); ++i)
+		{
+			fprintf(fout, "\t%s_count\t%s_count_variance\t%s_count_uncertainty_var\t%s_count_dispersion_var\t%s_status", sample_labels[i].c_str(), sample_labels[i].c_str(), sample_labels[i].c_str(), sample_labels[i].c_str(), sample_labels[i].c_str());
+		}
+	}
+	fprintf(fout, "\n");
+	for (FPKMTrackingTable::const_iterator itr = tracking.begin(); itr != tracking.end(); ++itr)
+	{
+		const string& description = itr->first;
+		const FPKMTracking& track = itr->second;
+		const vector<FPKMContext>& fpkms = track.fpkm_series;
+		
+        AbundanceStatus status = NUMERIC_OK;
+        foreach (const FPKMContext& c, fpkms)
+        {
+            if (c.status == NUMERIC_FAIL)
+                status = NUMERIC_FAIL;
+        }
+        
+        fprintf(fout, "%s", 
+                description.c_str());
+        
+		for (size_t i = 0; i < fpkms.size(); ++i)
+		{
+            const char* status_str = "OK";
+            
+            if (fpkms[i].status == NUMERIC_OK)
+            {
+                status_str = "OK";
+            }
+            else if (fpkms[i].status == NUMERIC_FAIL)
+            {
+                status_str = "FAIL";
+            }
+            else if (fpkms[i].status == NUMERIC_LOW_DATA)
+            {
+                status_str = "LOWDATA";
+            }
+            else if (fpkms[i].status == NUMERIC_HI_DATA)
+            {
+                status_str = "HIDATA";
+            }
+            else
+            {
+                assert(false);
+            }
+            
+            double external_counts = fpkms[i].count_mean;
+            double external_count_var = fpkms[i].count_var;
+            double uncertainty_var = fpkms[i].count_uncertainty_var;
+            double dispersion_var = fpkms[i].count_dispersion_var;
+			fprintf(fout, "\t%lg\t%lg\t%lg\t%lg\t%s", external_counts, external_count_var, uncertainty_var, dispersion_var, status_str);
+		}
+		
+		fprintf(fout, "\n");
+	}
+}
+
+void print_read_group_tracking(FILE* fout, 
+                               const FPKMTrackingTable& tracking)
+{
+	fprintf(fout,"tracking_id\tcondition\treplicate\traw_frags\tinternal_scaled_frags\texternal_scaled_frags\tFPKM\teffective_length\tstatus");
+	
+	fprintf(fout, "\n");
+	for (FPKMTrackingTable::const_iterator itr = tracking.begin(); itr != tracking.end(); ++itr)
+	{
+		const string& description = itr->first;
+		const FPKMTracking& track = itr->second;
+		const vector<FPKMContext>& fpkms = track.fpkm_series;
+                
+		for (size_t i = 0; i < fpkms.size(); ++i)
+		{
+            for (CountPerReplicateTable::const_iterator itr = fpkms[i].count_per_rep.begin(); 
+                 itr != fpkms[i].count_per_rep.end(); 
+                 ++itr)
+            { 
+                FPKMPerReplicateTable::const_iterator f_itr = fpkms[i].fpkm_per_rep.find(itr->first);
+                StatusPerReplicateTable::const_iterator s_itr = fpkms[i].status_per_rep.find(itr->first);
+                
+                
+                if (f_itr == fpkms[i].fpkm_per_rep.end())
+                {
+                    fprintf(stderr, "Error: missing per-replicate FPKM data\n");
+                }
+                
+                double FPKM = f_itr->second;
+                double internal_count = itr->second;
+                double external_count = internal_count / itr->first->external_scale_factor();
+                double raw_count = internal_count * itr->first->internal_scale_factor();
+                const  string& condition_name = itr->first->condition_name();
+                AbundanceStatus status = s_itr->second;
+                
+                int rep_num = itr->first->replicate_num();
+                
+                const char* status_str = "OK";
+                
+                if (status == NUMERIC_OK)
+                {
+                    status_str = "OK";
+                }
+                else if (status == NUMERIC_FAIL)
+                {
+                    status_str = "FAIL";
+                }
+                else if (status == NUMERIC_LOW_DATA)
+                {
+                    status_str = "LOWDATA";
+                }
+                else if (status == NUMERIC_HI_DATA)
+                {
+                    status_str = "HIDATA";
+                }
+                else
+                {
+                    assert(false);
+                }
+                
+                fprintf(fout, "%s\t%s\t%d\t%lg\t%lg\t%lg\t%lg\t%s\t%s\n",
+                        description.c_str(),
+                        condition_name.c_str(),
+                        rep_num,
+                        raw_count,
+                        internal_count,
+                        external_count,
+                        FPKM,
+                        "-",
+                        status_str);
+            }
+		}
+	}
+}
+
+void print_read_group_info(FILE* fout, 
+                           const vector<shared_ptr<ReadGroupProperties> >& all_read_groups)
+{
+    fprintf(fout, "file\tcondition\treplicate_num\ttotal_mass\tnorm_mass\tinternal_scale\texternal_scale\n");
+    for (size_t i = 0; i < all_read_groups.size(); ++i)
+    {
+        shared_ptr<ReadGroupProperties const> rg_props = all_read_groups[i];
+        fprintf(fout, "%s\t%s\t%d\t%Lg\t%Lg\t%lg\t%lg\n",
+                rg_props->file_path().c_str(),
+                rg_props->condition_name().c_str(),
+                rg_props->replicate_num(),
+                rg_props->total_map_mass(),
+                rg_props->normalized_map_mass(),
+                rg_props->internal_scale_factor(),
+                rg_props->external_scale_factor());
+                
+    }
+}
+
+void print_run_info(FILE* fout)
+{
+    fprintf(fout, "param\tvalue\n");
+    fprintf(fout, "cmd_line\t%s\n", cmd_str.c_str());
+    fprintf(fout, "version\t%s\n", PACKAGE_VERSION);
+    fprintf(fout, "SVN_revision\t%s\n",SVN_REVISION); 
+    fprintf(fout, "boost_version\t%d\n", BOOST_VERSION);
+}
+
 bool p_value_lt(const SampleDifference* lhs, const SampleDifference* rhs)
 {
 	return lhs->p_value < rhs->p_value;
@@ -734,6 +986,220 @@ bool quantitate_next_locus(const RefSequenceTable& rt,
     return true;
 }
 
+void normalize_as_pool(vector<shared_ptr<ReadGroupProperties> >& all_read_groups)
+{
+    vector<LocusCountList> sample_count_table;
+    for (size_t i = 0; i < all_read_groups.size(); ++i)
+    {
+        shared_ptr<ReadGroupProperties> rg_props = all_read_groups[i];
+        const vector<LocusCount>& raw_count_table = rg_props->raw_counts();
+        
+        for (size_t j = 0; j < raw_count_table.size(); ++j)
+        {
+            if (sample_count_table.size() == j)
+            {
+                const string& locus_id = raw_count_table[j].locus_desc;
+                int num_transcripts = raw_count_table[j].num_transcripts;
+                sample_count_table.push_back(LocusCountList(locus_id,all_read_groups.size(), num_transcripts));
+            }
+            double scaled = raw_count_table[j].count;
+            //sample_count_table[j].counts[i] = scaled * unscaling_factor;
+            sample_count_table[j].counts[i] = scaled;
+            assert(sample_count_table[j].counts[i] >= 0 && !isinf(sample_count_table[j].counts[i]));
+        }
+    }
+    
+    vector<double> scale_factors(all_read_groups.size(), 0.0);
+    
+    // TODO: needs to be refactored - similar code exists in replicates.cpp
+    calc_scaling_factors(sample_count_table, scale_factors);
+    
+    for (size_t j = 0; j < scale_factors.size(); ++j)
+    {
+        double total = 0.0;
+        double sf = scale_factors[j];
+        for (size_t i = 0; i < sample_count_table.size(); ++i)
+        {
+            total += sample_count_table[i].counts[j];
+        }
+        //fprintf(stderr, "SF: %lg, Total: %lg\n", sf, total);
+    }
+    
+    for (size_t i = 0; i < all_read_groups.size(); ++i)
+    {
+        shared_ptr<ReadGroupProperties> rg_props = all_read_groups[i];
+        rg_props->internal_scale_factor(scale_factors[i]);
+        //rg_props->external_scale_factor(scale_factors[i]);
+    }
+    
+    // Transform raw counts to the common scale
+    for (size_t i = 0; i < sample_count_table.size(); ++i)
+    {
+        LocusCountList& p = sample_count_table[i];
+        for (size_t j = 0; j < p.counts.size(); ++j)
+        {
+            assert (scale_factors.size() > j);
+            p.counts[j] *= (1.0 / scale_factors[j]);
+        }
+    }
+    
+    for (size_t i = 0; i < all_read_groups.size(); ++i)
+    {
+        shared_ptr<ReadGroupProperties> rg_props = all_read_groups[i];
+        vector<LocusCount> scaled_counts;
+        for (size_t j = 0; j < sample_count_table.size(); ++j)
+        {
+            string& locus_id = sample_count_table[j].locus_desc;
+            double count = sample_count_table[j].counts[i];
+            int num_transcripts = sample_count_table[j].num_transcripts;
+            LocusCount locus_count(locus_id, count, num_transcripts);
+            scaled_counts.push_back(locus_count);
+        }
+        rg_props->common_scale_counts(scaled_counts);
+        // revert each read group back to native scaling to avoid a systematic fold change toward the mean.
+        
+        // rg_props->internal_scale_factor(1.0);         
+    }
+    
+    if (poisson_dispersion == false)
+    {
+        shared_ptr<MassDispersionModel const> disperser;
+        disperser = fit_dispersion_model("pooled", scale_factors, sample_count_table, false);
+        
+        foreach (shared_ptr<ReadGroupProperties> rg_props, all_read_groups)
+        {
+            rg_props->mass_dispersion_model(disperser);
+        }
+    }
+    
+    double avg_total_common_scaled_count = 0.0;
+    
+    for (size_t fac_idx = 0; fac_idx < all_read_groups.size(); ++fac_idx)
+    {
+        //shared_ptr<ReadGroupProperties> rg = bundle_factories[fac_idx];
+        //double scaled_mass = scale_factors[fac_idx] * rg->total_map_mass();
+        double total_common = 0.0;
+        for (size_t j = 0; j < sample_count_table.size(); ++j)
+        {
+            total_common += sample_count_table[j].counts[fac_idx];
+        }
+        
+        avg_total_common_scaled_count += (1.0/all_read_groups.size()) * total_common;
+    }
+    
+    foreach(shared_ptr<ReadGroupProperties> rg, all_read_groups)
+    {
+        rg->normalized_map_mass(avg_total_common_scaled_count);
+        //bf->read_group_properties()->normalized_map_mass(scale_factors[fac_idx]);
+    }
+
+}
+
+void fit_isoform_level_count_dispersion(const FPKMTrackingTable& isoform_fpkm_tracking,
+                                        vector<shared_ptr<ReplicatedBundleFactory> >& bundle_factories)
+{
+    map<shared_ptr<MassDispersionModel const>, vector<LocusCountList> > sample_count_table_for_disp_model;
+    
+    for (size_t fac_idx = 0; fac_idx < bundle_factories.size(); ++fac_idx)
+    {
+        shared_ptr<ReplicatedBundleFactory> rep_fac = bundle_factories[fac_idx];
+        vector<shared_ptr<BundleFactory> > replicates = rep_fac->factories();
+        //vector<double> count_table;
+        
+        vector<LocusCountList> sample_count_table;
+        
+        set<shared_ptr<ReadGroupProperties> > reps_for_condition;
+        
+        for (size_t i = 0; i < replicates.size(); ++i)
+        {
+            shared_ptr<ReadGroupProperties> rg_props = replicates[i]->read_group_properties();
+            reps_for_condition.insert(rg_props);
+        }
+    }
+
+    size_t iso_num = 0;
+    
+    for (FPKMTrackingTable::const_iterator itr = isoform_fpkm_tracking.begin(); itr != isoform_fpkm_tracking.end(); ++itr)
+    {
+        const string& description = itr->first;
+		const FPKMTracking& track = itr->second;
+        const vector<FPKMContext>& fpkms = track.fpkm_series;
+		
+        bool skip_iso = false;
+        for (size_t i = 0; i < fpkms.size(); ++i)
+		{
+            if (fpkms[i].count_per_rep.empty())
+            {
+                skip_iso = true;
+                break;
+            }
+        }
+        if (skip_iso)
+            continue;
+        
+        for (size_t i = 0; i < fpkms.size(); ++i)
+		{
+            size_t fac_idx = 0;
+            for (CountPerReplicateTable::const_iterator itr = fpkms[i].count_per_rep.begin(); 
+                 itr != fpkms[i].count_per_rep.end(); 
+                 ++itr)
+            {
+                shared_ptr<ReadGroupProperties const> rg_props = itr->first;
+                pair<map<shared_ptr<MassDispersionModel const>, vector<LocusCountList> >::iterator, bool >  p;
+                p = sample_count_table_for_disp_model.insert(make_pair(rg_props->mass_dispersion_model(),
+                                                                   vector<LocusCountList>()));
+                map<shared_ptr<MassDispersionModel const>, vector<LocusCountList> >::iterator lc_itr = p.first;
+                vector<LocusCountList>& lc_list = lc_itr->second;
+                double count = itr->second;
+                
+                if (iso_num >= lc_list.size())
+                {
+                    LocusCountList locus_count(description, fpkms[i].count_per_rep.size(), 1); 
+                    lc_list.push_back(locus_count);
+                    lc_list[lc_list.size() - 1].counts[0] = count;
+                }
+                else
+                {
+                    const string& ld = lc_list[iso_num].locus_desc;
+                    if (ld != description)
+                    {
+                        fprintf (stderr, "Error: bundle boundaries don't match across replicates!\n");
+                        exit(1);
+                    }
+                    lc_list[iso_num].counts[fac_idx] = count;
+                }
+                fac_idx++;
+            }
+        }
+        iso_num++;
+    }
+    
+    for (map<shared_ptr<MassDispersionModel const>, vector<LocusCountList> >::const_iterator itr = sample_count_table_for_disp_model.begin(); 
+         itr != sample_count_table_for_disp_model.end(); 
+         ++itr)
+    {
+        if (itr->second.empty())
+            continue;
+        
+        vector<double> scale_factors(itr->second.front().counts.size(), 1);
+        shared_ptr<MassDispersionModel const> model = fit_dispersion_model(itr->first->name()+"iso", scale_factors, itr->second, true);
+        for (size_t fac_idx = 0; fac_idx < bundle_factories.size(); ++fac_idx)
+        {
+            shared_ptr<ReplicatedBundleFactory> rep_fac = bundle_factories[fac_idx];
+            vector<shared_ptr<BundleFactory> > replicates = rep_fac->factories();
+            
+            for (size_t i = 0; i < replicates.size(); ++i)
+            {
+                shared_ptr<ReadGroupProperties> rg_props = replicates[i]->read_group_properties();
+                if (rg_props->mass_dispersion_model() == itr->first)
+                {
+                    rg_props->mass_dispersion_model(model);
+                }
+            }
+        }
+    }
+}
+
 void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_lists, Outfiles& outfiles)
 {
 
@@ -752,6 +1218,9 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
         tokenize(sam_hit_filename_lists[i], ",", sam_hit_filenames);
         
         vector<shared_ptr<BundleFactory> > replicate_factories;
+        
+        string condition_name = sample_labels[i];
+        
         for (size_t j = 0; j < sam_hit_filenames.size(); ++j)
         {
             shared_ptr<HitFactory> hs;
@@ -764,7 +1233,7 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
                 try
                 {
                     fprintf(stderr, "File %s doesn't appear to be a valid BAM file, trying SAM...\n",
-                            sam_hit_filename_lists[i].c_str());
+                            sam_hit_filenames[j].c_str());
                     hs = shared_ptr<HitFactory>(new SAMHitFactory(sam_hit_filenames[j], it, rt));
                 }
                 catch (std::runtime_error& e)
@@ -789,6 +1258,10 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
                 *rg_props = hs->read_group_properties();
             }
             
+            rg_props->condition_name(condition_name);
+            rg_props->replicate_num(j);
+            rg_props->file_path(sam_hit_filenames[j]);
+            
             all_read_groups.push_back(rg_props);
             
             hf->read_group_properties(rg_props);
@@ -797,7 +1270,7 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
             //replicate_factories.back()->set_ref_rnas(ref_mRNAs);
         }
         
-        string condition_name = sample_labels[i];
+        
         bundle_factories.push_back(shared_ptr<ReplicatedBundleFactory>(new ReplicatedBundleFactory(replicate_factories, condition_name)));
 	}
     
@@ -872,29 +1345,6 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
     }
 #endif
     
-    
-    if (use_quartile_norm)
-    {
-        long double total_mass = 0.0;
-        long double total_norm_mass = 0.0;
-        foreach (shared_ptr<ReadGroupProperties> rg, all_read_groups)
-        {
-            total_mass += rg->total_map_mass();
-            total_norm_mass += rg->normalized_map_mass();
-        }
-        
-        if (total_mass > 0)
-        {
-            double scaling_factor = total_mass / total_norm_mass;
-            foreach (shared_ptr<ReadGroupProperties> rg, all_read_groups)
-            {
-                double scaled_mass = scaling_factor * rg->normalized_map_mass();
-                
-                rg->normalized_map_mass(scaled_mass);
-            }
-        }
-    }
-    
     int most_reps = -1;
     int most_reps_idx = 0;
     
@@ -914,89 +1364,231 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
         }
     }
     
-    if (most_reps != 1 && poisson_dispersion == false)
+    if (most_reps == 1)
     {
-        foreach (shared_ptr<ReplicatedBundleFactory> fac, bundle_factories)
-        {
-            if (fac->num_replicates() == 1)
-            {
-                fac->mass_dispersion_model(bundle_factories[most_reps_idx]->mass_dispersion_model());
-            }
-        }
+        normalize_as_pool(all_read_groups);
     }
     
-    if (most_reps == 1 && poisson_dispersion == false)
+    if (most_reps != 1 && (use_quartile_norm || use_geometric_norm))
     {
         vector<LocusCountList> sample_count_table;
-        for (size_t i = 0; i < all_read_groups.size(); ++i)
+        
+        //vector<shared_ptr<ReplicatedBundleFactory> > bundle_factories;
+        
+        for (size_t fac_idx = 0; fac_idx < bundle_factories.size(); ++fac_idx)
         {
-            shared_ptr<ReadGroupProperties> rg_props = all_read_groups[i];
-            const vector<LocusCount>& common_count_table = rg_props->common_scale_counts();
-            double unscaling_factor = 1.0 / rg_props->mass_scale_factor();
-            for (size_t j = 0; j < common_count_table.size(); ++j)
+            shared_ptr<ReplicatedBundleFactory> rep_fac = bundle_factories[fac_idx];
+            vector<shared_ptr<BundleFactory> > replicates = rep_fac->factories();
+            vector<double> count_table;
+            for (size_t j = 0; j < replicates.size(); ++j)
+            {
+                shared_ptr<ReadGroupProperties> rg = replicates[j]->read_group_properties();
+                const vector<LocusCount>& rep_count_table = rg->common_scale_counts();
+                if (count_table.empty())
+                    count_table = vector<double>(rep_count_table.size(), 0);
+                
+                for (size_t i = 0; i < rep_count_table.size(); ++i)
+                {
+                    const LocusCount& c = rep_count_table[i];
+                    double count = c.count;
+                    count_table[i] += (count / replicates.size());;
+                }
+                
+            }
+            
+            for (size_t i = 0; i < count_table.size(); ++i)
             {
-                if (sample_count_table.size() == j)
+                
+                const LocusCount& c = replicates.front()->read_group_properties()->common_scale_counts()[i];
+                double count = count_table[i];
+                
+                if (i >= sample_count_table.size())
+                {
+                    LocusCountList locus_count(c.locus_desc, bundle_factories.size(), c.num_transcripts); 
+                    sample_count_table.push_back(locus_count);
+                    sample_count_table.back().counts[0] = count;
+                }
+                else
                 {
-                    const string& locus_id = common_count_table[j].locus_desc;
-                    int num_transcripts = common_count_table[j].num_transcripts;
-                    sample_count_table.push_back(LocusCountList(locus_id,all_read_groups.size(), num_transcripts));
+                    if (sample_count_table[i].locus_desc != c.locus_desc)
+                    {
+                        fprintf (stderr, "Error: bundle boundaries don't match across replicates!\n");
+                        exit(1);
+                    }
+                    sample_count_table[i].counts[fac_idx] = count;
                 }
-                double scaled = common_count_table[j].count;
-                sample_count_table[j].counts[i] = scaled * unscaling_factor;
-                assert(sample_count_table[j].counts[i] >= 0 && !isinf(sample_count_table[j].counts[i]));
+                
             }
         }
         
-        vector<double> scale_factors(all_read_groups.size(), 0.0);
+        vector<double> scale_factors(bundle_factories.size(), 0.0);
         
-        // TODO: needs to be refactored - similar code exists in replicates.cpp
         calc_scaling_factors(sample_count_table, scale_factors);
         
-        for (size_t i = 0; i < all_read_groups.size(); ++i)
+        for (size_t j = 0; j < scale_factors.size(); ++j)
         {
-            shared_ptr<ReadGroupProperties> rg_props = all_read_groups[i];
-            rg_props->mass_scale_factor(scale_factors[i]);
+            shared_ptr<ReplicatedBundleFactory> rep_fac = bundle_factories[j];
+            vector<shared_ptr<BundleFactory> > replicates = rep_fac->factories();
+            
+            for (size_t i = 0; i < replicates.size(); ++i)
+            {
+                shared_ptr<ReadGroupProperties> rg = replicates[i]->read_group_properties();
+                rg->external_scale_factor(scale_factors[j]);
+            }
+            
+            double total = 0.0;
+            double sf = scale_factors[j];
+            for (size_t i = 0; i < sample_count_table.size(); ++i)
+            {
+                total += sample_count_table[i].counts[j];
+            }
+            //fprintf(stderr, "SF: %lg, Total: %lg\n", sf, total);
         }
         
-        // Transform raw counts to the common scale
-        for (size_t i = 0; i < sample_count_table.size(); ++i)
+        if (use_quartile_norm)
         {
-            LocusCountList& p = sample_count_table[i];
-            for (size_t j = 0; j < p.counts.size(); ++j)
+            vector<double> upper_quartiles(bundle_factories.size(), 0);
+            vector<double> total_common_masses(bundle_factories.size(), 0);
+            
+            for (size_t fac_idx = 0; fac_idx < bundle_factories.size(); ++fac_idx)
             {
-                assert (scale_factors.size() > j);
-                p.counts[j] *= (1.0 / scale_factors[j]);
+                //shared_ptr<ReadGroupProperties> rg = bundle_factories[fac_idx];
+                //double scaled_mass = scale_factors[fac_idx] * rg->total_map_mass();
+                vector<double> common_scaled_counts;
+                double total_common = 0.0;
+                
+                for (size_t j = 0; j < sample_count_table.size(); ++j)
+                {
+                    total_common += sample_count_table[j].counts[fac_idx];
+                    common_scaled_counts.push_back(sample_count_table[j].counts[fac_idx]);
+                }
+                
+                sort(common_scaled_counts.begin(), common_scaled_counts.end());
+                if (common_scaled_counts.empty())
+                    continue;
+                
+                int upper_quart_index = common_scaled_counts.size() * 0.75;
+                double upper_quart_count = common_scaled_counts[upper_quart_index];
+                upper_quartiles[fac_idx] = upper_quart_count;
+                total_common_masses[fac_idx] = total_common;
+            }
+            
+            long double total_mass = accumulate(total_common_masses.begin(), total_common_masses.end(), 0.0);
+            long double total_norm_mass = accumulate(upper_quartiles.begin(), upper_quartiles.end(), 0.0);
+            
+            for (size_t fac_idx = 0; fac_idx < bundle_factories.size(); ++fac_idx)
+            {
+                if (total_mass > 0)
+                {
+                    double scaling_factor = total_mass / total_norm_mass;
+                    foreach(shared_ptr<BundleFactory> bf, bundle_factories[fac_idx]->factories())
+                    {
+                        double scaled_mass = scaling_factor * upper_quartiles[fac_idx];
+                        bf->read_group_properties()->normalized_map_mass(scaled_mass);
+                        bf->read_group_properties()->external_scale_factor(1.0);
+                    }
+                }
             }
         }
+        else
+        {
+            transform_counts_to_common_scale(scale_factors, sample_count_table);
+            
+            double avg_total_common_scaled_count = 0.0;
+            
+            for (size_t fac_idx = 0; fac_idx < bundle_factories.size(); ++fac_idx)
+            {
+                //shared_ptr<ReadGroupProperties> rg = bundle_factories[fac_idx];
+                //double scaled_mass = scale_factors[fac_idx] * rg->total_map_mass();
+                double total_common = 0.0;
+                for (size_t j = 0; j < sample_count_table.size(); ++j)
+                {
+                    total_common += sample_count_table[j].counts[fac_idx];
+                }
+                
+                avg_total_common_scaled_count += (1.0/bundle_factories.size()) * total_common;
+                
+                //rg->normalized_map_mass(scale_factors[fac_idx])
+            }
+            
+            for (size_t fac_idx = 0; fac_idx < bundle_factories.size(); ++fac_idx)
+            {
+                foreach(shared_ptr<BundleFactory> bf, bundle_factories[fac_idx]->factories())
+                {
+                    bf->read_group_properties()->normalized_map_mass(avg_total_common_scaled_count);
+                }
+            }
+        }  
         
-        for (size_t i = 0; i < all_read_groups.size(); ++i)
+        foreach (shared_ptr<ReplicatedBundleFactory> fac, bundle_factories)
         {
-            shared_ptr<ReadGroupProperties> rg_props = all_read_groups[i];
-            vector<LocusCount> scaled_counts;
-            for (size_t j = 0; j < sample_count_table.size(); ++j)
-            {
-                string& locus_id = sample_count_table[j].locus_desc;
-                double count = sample_count_table[j].counts[i];
-                int num_transcripts = sample_count_table[j].num_transcripts;
-                LocusCount locus_count(locus_id, count, num_transcripts);
-                scaled_counts.push_back(locus_count);
-            }
-            rg_props->common_scale_counts(scaled_counts);
-            // revert each read group back to native scaling to avoid a systematic fold change toward the mean.
-
-            rg_props->mass_scale_factor(1.0);         
+            // for now, "borrow" the dispersion model for the condition with the most replicates
+            size_t borrowed_disp_model_idx = most_reps_idx;
+            if (fac->num_replicates() == 1)
+            {
+                fac->mass_dispersion_model(bundle_factories[borrowed_disp_model_idx]->mass_dispersion_model());
+                double borrowed_internal_size_factor = scale_factors[borrowed_disp_model_idx];
+                double borrowed_external_size_factor = scale_factors[borrowed_disp_model_idx];
+                double borrowed_norm_map_mass = bundle_factories[borrowed_disp_model_idx]->factories().front()->read_group_properties()->normalized_map_mass();
+                foreach(shared_ptr<BundleFactory> bf, fac->factories())
+                {
+                    // we need to adjust the scaling factors so that the FPKMs aren't skewed
+                    // and the variance function from the dispersion model is correct.
+                    //bf->read_group_properties()->normalized_map_mass(avg_total_common_scaled_count);
+                    bf->read_group_properties()->internal_scale_factor(bf->read_group_properties()->external_scale_factor()/borrowed_internal_size_factor);
+                    bf->read_group_properties()->normalized_map_mass(borrowed_norm_map_mass);
+                    bf->read_group_properties()->external_scale_factor(borrowed_external_size_factor);
+                }
+            }
         }
-        
-        shared_ptr<MassDispersionModel const> disperser;
-        disperser = fit_dispersion_model("pooled", scale_factors, sample_count_table);
+    }
+    else if (use_raw_mapped_norm)
+    {
+        // no need to do anything beyond what's already being done during 
+        // per-condition map inspection.  Counts are common-scale-transformed 
+        // on a per condition basis.  External scale factors are set to 1.0 
+        // by default
+    }
 
-        foreach (shared_ptr<ReadGroupProperties> rg_props, all_read_groups)
+
+//    if (use_quartile_norm || use_raw_mapped_norm)
+//    {
+//        // scale the normalized masses so that both quantile total count normalization
+//        // are roughly on the same numerical scale
+//        foreach (shared_ptr<ReadGroupProperties> rg_props, all_read_groups)
+//        {
+//            long double new_norm = rg_props->normalized_map_mass() * (total_mass / total_norm_mass);
+//            rg_props->normalized_map_mass(new_norm);
+//        }
+//    }
+    
+    for (size_t i = 0; i < all_read_groups.size(); ++i)
+    {
+        shared_ptr<ReadGroupProperties> rg = all_read_groups[i];
+        fprintf(stderr, "> Map Properties:\n");
+        
+        fprintf(stderr, ">\tNormalized Map Mass: %.2Lf\n", rg->normalized_map_mass());
+        fprintf(stderr, ">\tRaw Map Mass: %.2Lf\n", rg->total_map_mass());
+        if (corr_multi)
+            fprintf(stderr,">\tNumber of Multi-Reads: %zu (with %zu total hits)\n", rg->multi_read_table()->num_multireads(), rg->multi_read_table()->num_multihits()); 
+        
+        if (rg->frag_len_dist()->source() == LEARNED)
         {
-            rg_props->mass_dispersion_model(disperser);
+            fprintf(stderr, ">\tFragment Length Distribution: Empirical (learned)\n");
+            fprintf(stderr, ">\t              Estimated Mean: %.2f\n", rg->frag_len_dist()->mean());
+            fprintf(stderr, ">\t           Estimated Std Dev: %.2f\n", rg->frag_len_dist()->std_dev());
+        }
+        else
+        {
+            if (rg->frag_len_dist()->source() == USER)
+                fprintf(stderr, ">\tFragment Length Distribution: Truncated Gaussian (user-specified)\n");
+            else //rg->frag_len_dist()->source == FLD::DEFAULT
+                fprintf(stderr, ">\tFragment Length Distribution: Truncated Gaussian (default)\n");
+            fprintf(stderr, ">\t              Default Mean: %d\n", def_frag_len_mean);
+            fprintf(stderr, ">\t           Default Std Dev: %d\n", def_frag_len_std_dev);
         }
-
     }
-
+    
     long double total_norm_mass = 0.0;
     long double total_mass = 0.0;
     foreach (shared_ptr<ReadGroupProperties> rg_props, all_read_groups)
@@ -1004,14 +1596,6 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
         total_norm_mass += rg_props->normalized_map_mass();
         total_mass += rg_props->total_map_mass();
     }
-    
-    // scale the normalized masses so that both quantile total count normalization
-    // are roughly on the same numerical scale
-    foreach (shared_ptr<ReadGroupProperties> rg_props, all_read_groups)
-    {
-        long double new_norm = rg_props->normalized_map_mass() * (total_mass / total_norm_mass);
-        rg_props->normalized_map_mass(new_norm);
-    }
 
 	min_frag_len = tmp_min_frag_len;
     max_frag_len = tmp_max_frag_len;
@@ -1020,21 +1604,26 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
 	
 	double num_bundles = (double)bundle_factories[0]->num_bundles();
 	
-    //test_launcher = shared_ptr<TestLauncher>(new TestLauncher(bundle_factories.size(), &tests, &tracking, samples_are_time_series, p_bar)
+//    if (corr_bias && corr_multi)
+//        p_bar = ProgressBar("Calculating initial abundance estimates for bias and multi-read correction.", num_bundles);
+//    else if (corr_bias)
+//        p_bar = ProgressBar("Calculating initial abundance estimates for bias correction.", num_bundles);
+//    else if (corr_multi)
+//        p_bar = ProgressBar("Calculating initial abundance estimates for multi-read correction.", num_bundles);
+//    else
+    
+    p_bar = ProgressBar("Calculating preliminary abundance estimates", num_bundles);
+    
+    Tracking tracking;
+    
+    test_launcher = shared_ptr<TestLauncher>(new TestLauncher(bundle_factories.size(), NULL, &tracking, samples_are_time_series, &p_bar));
     
 	if (corr_bias || corr_multi) // Only run initial estimation if correcting bias or multi-reads
 	{
-        if (corr_bias && corr_multi)
-            p_bar = ProgressBar("Calculating initial abundance estimates for bias and multi-read correction.", num_bundles);
-        else if (corr_bias)
-            p_bar = ProgressBar("Calculating initial abundance estimates for bias correction.", num_bundles);
-        else if (corr_multi)
-            p_bar = ProgressBar("Calculating initial abundance estimates for multi-read correction.", num_bundles);
-
 		while (1) 
 		{
 			//p_bar.update("",1);
-            test_launcher = shared_ptr<TestLauncher>(new TestLauncher((int)bundle_factories.size(), NULL, NULL, samples_are_time_series, &p_bar));
+            //test_launcher = shared_ptr<TestLauncher>(new TestLauncher((int)bundle_factories.size(), NULL, &tracking, samples_are_time_series, &p_bar));
                                                      
 			shared_ptr<vector<shared_ptr<SampleAbundances> > > abundances(new vector<shared_ptr<SampleAbundances> >());
 			quantitate_next_locus(rt, bundle_factories, test_launcher);
@@ -1080,6 +1669,7 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
 	}
     if (corr_bias)
     {
+        bias_run = true;
         p_bar = ProgressBar("Learning bias parameters.", 0);
 		foreach (shared_ptr<ReplicatedBundleFactory> rep_fac, bundle_factories)
 		{
@@ -1128,9 +1718,15 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
 		{
 			rep_fac->reset();
         }
+        bias_run = false;
 	}
     
+//    if (use_isoform_count_dispersion)
+//    {
+//        fit_isoform_level_count_dispersion(tracking.isoform_fpkm_tracking, bundle_factories);
+//    }
     
+    test_launcher->clear_tracking_data();
 	
 	Tests tests;
     
@@ -1154,8 +1750,6 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
         tests.diff_promoter_tests[i] = vector<SampleDiffs>(i);
         tests.diff_cds_tests[i] = vector<SampleDiffs>(i);
     }
-
-	Tracking tracking;
 	
 	final_est_run = true;
 	p_bar = ProgressBar("Testing for differential expression and regulation in locus.", num_bundles);
@@ -1204,157 +1798,200 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
 	int total_iso_de_tests = 0;
 	
 	vector<SampleDifference*> isoform_exp_diffs;
-	for (size_t i = 1; i < tests.isoform_de_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    fprintf(outfiles.isoform_de_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tlog2(fold_change)\ttest_stat\tp_value\tq_value\tsignificant\n");
+    
+    //if (no_differential == false)
+    {
+        for (size_t i = 1; i < tests.isoform_de_tests.size(); ++i)
         {
-            total_iso_de_tests += tests.isoform_de_tests[i][j].size();
-            extract_sample_diffs(tests.isoform_de_tests[i][j], isoform_exp_diffs);
+            for (size_t j = 0; j < i; ++j)
+            {
+                total_iso_de_tests += tests.isoform_de_tests[i][j].size();
+                extract_sample_diffs(tests.isoform_de_tests[i][j], isoform_exp_diffs);
+            }
         }
-	}
-	int iso_exp_tests = fdr_significance(FDR, isoform_exp_diffs);
-	fprintf(stderr, "Performed %d isoform-level transcription difference tests\n", iso_exp_tests);
-    fprintf(outfiles.isoform_de_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tlog2(fold_change)\ttest_stat\tp_value\tq_value\tsignificant\n");
-	for (size_t i = 1; i < tests.isoform_de_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+        
+        int iso_exp_tests = fdr_significance(FDR, isoform_exp_diffs);
+        fprintf(stderr, "Performed %d isoform-level transcription difference tests\n", iso_exp_tests);
+        
+        for (size_t i = 1; i < tests.isoform_de_tests.size(); ++i)
         {
-            print_tests(outfiles.isoform_de_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.isoform_de_tests[i][j]);
+            for (size_t j = 0; j < i; ++j)
+            {
+                print_tests(outfiles.isoform_de_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.isoform_de_tests[i][j]);
+            }
         }
 	}
-	
+    
 	int total_group_de_tests = 0;
 	vector<SampleDifference*> tss_group_exp_diffs;
-	for (size_t i = 1; i < tests.tss_group_de_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    fprintf(outfiles.group_de_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tlog2(fold_change)\ttest_stat\tp_value\tq_value\tsignificant\n");
+    
+	//if (no_differential == false)
+    {
+        for (size_t i = 1; i < tests.tss_group_de_tests.size(); ++i)
         {
-            extract_sample_diffs(tests.tss_group_de_tests[i][j], tss_group_exp_diffs);
-            total_group_de_tests += tests.tss_group_de_tests[i][j].size();
+            for (size_t j = 0; j < i; ++j)
+            {
+                extract_sample_diffs(tests.tss_group_de_tests[i][j], tss_group_exp_diffs);
+                total_group_de_tests += tests.tss_group_de_tests[i][j].size();
+            }
         }
-	}
-	
-	int tss_group_exp_tests = fdr_significance(FDR, tss_group_exp_diffs);
-	fprintf(stderr, "Performed %d tss-level transcription difference tests\n", tss_group_exp_tests);
-    fprintf(outfiles.group_de_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tlog2(fold_change)\ttest_stat\tp_value\tq_value\tsignificant\n");
-	for (size_t i = 1; i < tests.tss_group_de_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    
+        int tss_group_exp_tests = fdr_significance(FDR, tss_group_exp_diffs);
+        fprintf(stderr, "Performed %d tss-level transcription difference tests\n", tss_group_exp_tests);
+        
+        for (size_t i = 1; i < tests.tss_group_de_tests.size(); ++i)
         {
-            print_tests(outfiles.group_de_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.tss_group_de_tests[i][j]);
+            for (size_t j = 0; j < i; ++j)
+            {
+                print_tests(outfiles.group_de_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.tss_group_de_tests[i][j]);
+            }
         }
-	}
+    }
 	
 	int total_gene_de_tests = 0;
 	vector<SampleDifference*> gene_exp_diffs;
-	for (size_t i = 1; i < tests.gene_de_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
-        {
-            total_gene_de_tests += tests.gene_de_tests[i][j].size();
-            extract_sample_diffs(tests.gene_de_tests[i][j], gene_exp_diffs);
-        }
-	}
-	
-    //fprintf(stderr, "***There are %lu difference records in gene_exp_diffs\n", gene_exp_diffs.size());
-    
-	int gene_exp_tests = fdr_significance(FDR, gene_exp_diffs);
-	fprintf(stderr, "Performed %d gene-level transcription difference tests\n", gene_exp_tests);
-	fprintf(outfiles.gene_de_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tlog2(fold_change)\ttest_stat\tp_value\tq_value\tsignificant\n");
-    for (size_t i = 1; i < tests.gene_de_tests.size(); ++i)
-	{        
-        for (size_t j = 0; j < i; ++j)
+    fprintf(outfiles.gene_de_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tlog2(fold_change)\ttest_stat\tp_value\tq_value\tsignificant\n");
+    
+    if (no_differential == false)
+    {
+        for (size_t i = 1; i < tests.gene_de_tests.size(); ++i)
         {
-            print_tests(outfiles.gene_de_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.gene_de_tests[i][j]);
+            for (size_t j = 0; j < i; ++j)
+            {
+                total_gene_de_tests += tests.gene_de_tests[i][j].size();
+                extract_sample_diffs(tests.gene_de_tests[i][j], gene_exp_diffs);
+            }
         }
-	}	
-
+    
+        //fprintf(stderr, "***There are %lu difference records in gene_exp_diffs\n", gene_exp_diffs.size());
+        int gene_exp_tests = fdr_significance(FDR, gene_exp_diffs);
+        fprintf(stderr, "Performed %d gene-level transcription difference tests\n", gene_exp_tests);
+        
+        for (size_t i = 1; i < tests.gene_de_tests.size(); ++i)
+        {        
+            for (size_t j = 0; j < i; ++j)
+            {
+                print_tests(outfiles.gene_de_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.gene_de_tests[i][j]);
+            }
+        }	
+    }
+    
 	int total_cds_de_tests = 0;
 	vector<SampleDifference*> cds_exp_diffs;
-	for (size_t i = 1; i < tests.cds_de_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    fprintf(outfiles.cds_de_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tlog2(fold_change)\ttest_stat\tp_value\tq_value\tsignificant\n");
+    
+    //if (no_differential == false)
+    {
+        for (size_t i = 1; i < tests.cds_de_tests.size(); ++i)
         {
-            total_cds_de_tests += tests.cds_de_tests[i][j].size();
-            extract_sample_diffs(tests.cds_de_tests[i][j], cds_exp_diffs);
+            for (size_t j = 0; j < i; ++j)
+            {
+                total_cds_de_tests += tests.cds_de_tests[i][j].size();
+                extract_sample_diffs(tests.cds_de_tests[i][j], cds_exp_diffs);
+            }
         }
-	}
-	int cds_exp_tests = fdr_significance(FDR, cds_exp_diffs);
-	fprintf(stderr, "Performed %d CDS-level transcription difference tests\n", cds_exp_tests);
-	fprintf(outfiles.cds_de_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tlog2(fold_change)\ttest_stat\tp_value\tq_value\tsignificant\n");
-    for (size_t i = 1; i < tests.cds_de_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    
+    
+        int cds_exp_tests = fdr_significance(FDR, cds_exp_diffs);
+        fprintf(stderr, "Performed %d CDS-level transcription difference tests\n", cds_exp_tests);
+        
+        for (size_t i = 1; i < tests.cds_de_tests.size(); ++i)
         {
-            print_tests(outfiles.cds_de_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.cds_de_tests[i][j]);
+            for (size_t j = 0; j < i; ++j)
+            {
+                print_tests(outfiles.cds_de_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.cds_de_tests[i][j]);
+            }
         }
 	}
-	
+    
 	int total_diff_splice_tests = 0;
 	vector<SampleDifference*> splicing_diffs;
-	for (size_t i = 1; i < tests.diff_splicing_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    fprintf(outfiles.diff_splicing_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tsqrt(JS)\ttest_stat\tp_value\tq_value\tsignificant\n");
+    
+    //if (no_differential == false)
+    {
+        for (size_t i = 1; i < tests.diff_splicing_tests.size(); ++i)
         {
-            total_diff_splice_tests += tests.diff_splicing_tests[i][j].size();
-            extract_sample_diffs(tests.diff_splicing_tests[i][j], splicing_diffs);
+            for (size_t j = 0; j < i; ++j)
+            {
+                total_diff_splice_tests += tests.diff_splicing_tests[i][j].size();
+                extract_sample_diffs(tests.diff_splicing_tests[i][j], splicing_diffs);
+            }
         }
-	}
-	
-	int splicing_tests = fdr_significance(FDR, splicing_diffs);
-	fprintf(stderr, "Performed %d splicing tests\n", splicing_tests);
-	fprintf(outfiles.diff_splicing_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tsqrt(JS)\ttest_stat\tp_value\tq_value\tsignificant\n");
-    for (size_t i = 1; i < tests.diff_splicing_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    
+        int splicing_tests = fdr_significance(FDR, splicing_diffs);
+        fprintf(stderr, "Performed %d splicing tests\n", splicing_tests);
+        
+        for (size_t i = 1; i < tests.diff_splicing_tests.size(); ++i)
         {
-            const SampleDiffs& diffs = tests.diff_splicing_tests[i][j];
-            print_tests(outfiles.diff_splicing_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), diffs);
+            for (size_t j = 0; j < i; ++j)
+            {
+                const SampleDiffs& diffs = tests.diff_splicing_tests[i][j];
+                print_tests(outfiles.diff_splicing_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), diffs);
+            }
         }
 	}
-	
+    
 	int total_diff_promoter_tests = 0;
 	vector<SampleDifference*> promoter_diffs;
-	for (size_t i = 1; i < tests.diff_splicing_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    fprintf(outfiles.diff_promoter_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tsqrt(JS)\ttest_stat\tp_value\tq_value\tsignificant\n");
+    
+    //if (no_differential == false)
+    {
+        for (size_t i = 1; i < tests.diff_splicing_tests.size(); ++i)
         {
-            total_diff_promoter_tests += tests.diff_promoter_tests[i][j].size();
-            extract_sample_diffs(tests.diff_promoter_tests[i][j], promoter_diffs);
+            for (size_t j = 0; j < i; ++j)
+            {
+                total_diff_promoter_tests += tests.diff_promoter_tests[i][j].size();
+                extract_sample_diffs(tests.diff_promoter_tests[i][j], promoter_diffs);
+            }
         }
-	}
-	int promoter_tests = fdr_significance(FDR, promoter_diffs);
-	fprintf(stderr, "Performed %d promoter preference tests\n", promoter_tests);
-    fprintf(outfiles.diff_promoter_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tsqrt(JS)\ttest_stat\tp_value\tq_value\tsignificant\n");
-    for (size_t i = 1; i < tests.diff_promoter_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    
+    
+        int promoter_tests = fdr_significance(FDR, promoter_diffs);
+        fprintf(stderr, "Performed %d promoter preference tests\n", promoter_tests);
+        
+        for (size_t i = 1; i < tests.diff_promoter_tests.size(); ++i)
         {
-            print_tests(outfiles.diff_promoter_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.diff_promoter_tests[i][j]);
+            for (size_t j = 0; j < i; ++j)
+            {
+                print_tests(outfiles.diff_promoter_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.diff_promoter_tests[i][j]);
+            }
         }
-	}
-
+    }
+    
 	int total_diff_cds_tests = 0;
 	vector<SampleDifference*> cds_use_diffs;
-	for (size_t i = 1; i < tests.diff_cds_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+    fprintf(outfiles.diff_cds_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tsqrt(JS)\ttest_stat\tp_value\tq_value\tsignificant\n");
+    
+    //if (no_differential == false)
+    {
+        for (size_t i = 1; i < tests.diff_cds_tests.size(); ++i)
         {
-            extract_sample_diffs(tests.diff_cds_tests[i][j], cds_use_diffs);
-            total_diff_cds_tests += tests.diff_cds_tests[i][j].size();
+            for (size_t j = 0; j < i; ++j)
+            {
+                extract_sample_diffs(tests.diff_cds_tests[i][j], cds_use_diffs);
+                total_diff_cds_tests += tests.diff_cds_tests[i][j].size();
+            }
         }
-	}
-	int cds_use_tests = fdr_significance(FDR, cds_use_diffs);
-	fprintf(stderr, "Performing %d relative CDS output tests\n", cds_use_tests);
-	fprintf(outfiles.diff_cds_outfile, "test_id\tgene_id\tgene\tlocus\tsample_1\tsample_2\tstatus\tvalue_1\tvalue_2\tsqrt(JS)\ttest_stat\tp_value\tq_value\tsignificant\n");
-    for (size_t i = 1; i < tests.diff_cds_tests.size(); ++i)
-	{
-        for (size_t j = 0; j < i; ++j)
+	
+    
+        int cds_use_tests = fdr_significance(FDR, cds_use_diffs);
+        fprintf(stderr, "Performing %d relative CDS output tests\n", cds_use_tests);
+        
+        for (size_t i = 1; i < tests.diff_cds_tests.size(); ++i)
         {
-            print_tests(outfiles.diff_cds_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.diff_cds_tests[i][j]);
+            for (size_t j = 0; j < i; ++j)
+            {
+                print_tests(outfiles.diff_cds_outfile, sample_labels[j].c_str(), sample_labels[i].c_str(), tests.diff_cds_tests[i][j]);
+            }
         }
-	}
+    }
 	
+    // FPKM tracking
+    
 	FILE* fiso_fpkm_tracking =  outfiles.isoform_fpkm_tracking_out;
 	fprintf(stderr, "Writing isoform-level FPKM tracking\n");
 	print_FPKM_tracking(fiso_fpkm_tracking,tracking.isoform_fpkm_tracking); 
@@ -1370,10 +2007,59 @@ void driver(FILE* ref_gtf, FILE* mask_gtf, vector<string>& sam_hit_filename_list
 	FILE* fcds_fpkm_tracking =  outfiles.cds_fpkm_tracking_out;
 	fprintf(stderr, "Writing CDS-level FPKM tracking\n");
 	print_FPKM_tracking(fcds_fpkm_tracking,tracking.cds_fpkm_tracking);
+
+    // Count tracking
+    
+    FILE* fiso_count_tracking =  outfiles.isoform_count_tracking_out;
+	fprintf(stderr, "Writing isoform-level count tracking\n");
+	print_count_tracking(fiso_count_tracking,tracking.isoform_fpkm_tracking); 
+	
+	FILE* ftss_count_tracking =  outfiles.tss_group_count_tracking_out;
+	fprintf(stderr, "Writing TSS group-level count tracking\n");
+	print_count_tracking(ftss_count_tracking,tracking.tss_group_fpkm_tracking);
+	
+	FILE* fgene_count_tracking =  outfiles.gene_count_tracking_out;
+	fprintf(stderr, "Writing gene-level count tracking\n");
+	print_count_tracking(fgene_count_tracking,tracking.gene_fpkm_tracking);
+	
+	FILE* fcds_count_tracking =  outfiles.cds_count_tracking_out;
+	fprintf(stderr, "Writing CDS-level count tracking\n");
+	print_count_tracking(fcds_count_tracking,tracking.cds_fpkm_tracking);
+    
+    // Read group tracking
+    
+    FILE* fiso_rep_tracking =  outfiles.isoform_rep_tracking_out;
+	fprintf(stderr, "Writing isoform-level read group tracking\n");
+	print_read_group_tracking(fiso_rep_tracking,tracking.isoform_fpkm_tracking); 
+	
+	FILE* ftss_rep_tracking =  outfiles.tss_group_rep_tracking_out;
+	fprintf(stderr, "Writing TSS group-level read group tracking\n");
+	print_read_group_tracking(ftss_rep_tracking,tracking.tss_group_fpkm_tracking);
+	
+	FILE* fgene_rep_tracking =  outfiles.gene_rep_tracking_out;
+	fprintf(stderr, "Writing gene-level read group tracking\n");
+	print_read_group_tracking(fgene_rep_tracking,tracking.gene_fpkm_tracking);
+	
+	FILE* fcds_rep_tracking =  outfiles.cds_rep_tracking_out;
+	fprintf(stderr, "Writing CDS-level read group tracking\n");
+	print_read_group_tracking(fcds_rep_tracking,tracking.cds_fpkm_tracking);
+    
+    FILE* fread_group_info =  outfiles.read_group_info_out;
+	fprintf(stderr, "Writing read group info\n");
+	print_read_group_info(fread_group_info,all_read_groups);
+
+    FILE* frun_info =  outfiles.run_info_out;
+	fprintf(stderr, "Writing run info\n");
+	print_run_info(frun_info);
 }
 
 int main(int argc, char** argv)
 {
+    for (int i = 0; i < argc; ++i)
+    {
+        cmd_str += string(argv[i]) + " ";
+    }
+    
     init_library_table();
     
     min_isoform_fraction = 1e-5;
@@ -1610,7 +2296,117 @@ int main(int argc, char** argv)
 		exit(1);
 	}
 	outfiles.gene_fpkm_tracking_out = gene_fpkm_out;
+
+    char isoform_count_tracking_name[filename_buf_size];
+	sprintf(isoform_count_tracking_name, "%s/isoforms.count_tracking", output_dir.c_str());
+	FILE* isoform_count_out = fopen(isoform_count_tracking_name, "w");
+	if (!isoform_count_out)
+	{
+		fprintf(stderr, "Error: cannot open isoform-level count tracking file %s for writing\n",
+				isoform_count_tracking_name);
+		exit(1);
+	}
+	outfiles.isoform_count_tracking_out = isoform_count_out;
+    
+	char tss_group_count_tracking_name[filename_buf_size];
+	sprintf(tss_group_count_tracking_name, "%s/tss_groups.count_tracking", output_dir.c_str());
+	FILE* tss_group_count_out = fopen(tss_group_count_tracking_name, "w");
+	if (!tss_group_count_out)
+	{
+		fprintf(stderr, "Error: cannot open TSS group-level count tracking file %s for writing\n",
+				tss_group_count_tracking_name);
+		exit(1);
+	}
+	outfiles.tss_group_count_tracking_out = tss_group_count_out;
+    
+	char cds_count_tracking_name[filename_buf_size];
+	sprintf(cds_count_tracking_name, "%s/cds.count_tracking", output_dir.c_str());
+	FILE* cds_count_out = fopen(cds_count_tracking_name, "w");
+	if (!cds_count_out)
+	{
+		fprintf(stderr, "Error: cannot open CDS level count tracking file %s for writing\n",
+				cds_count_tracking_name);
+		exit(1);
+	}
+	outfiles.cds_count_tracking_out = cds_count_out;
 	
+	char gene_count_tracking_name[filename_buf_size];
+	sprintf(gene_count_tracking_name, "%s/genes.count_tracking", output_dir.c_str());
+	FILE* gene_count_out = fopen(gene_count_tracking_name, "w");
+	if (!gene_count_out)
+	{
+		fprintf(stderr, "Error: cannot open gene-level count tracking file %s for writing\n",
+				gene_count_tracking_name);
+		exit(1);
+	}
+	outfiles.gene_count_tracking_out = gene_count_out;
+    
+    char isoform_rep_tracking_name[filename_buf_size];
+	sprintf(isoform_rep_tracking_name, "%s/isoforms.read_group_tracking", output_dir.c_str());
+	FILE* isoform_rep_out = fopen(isoform_rep_tracking_name, "w");
+	if (!isoform_rep_out)
+	{
+		fprintf(stderr, "Error: cannot open isoform-level read group tracking file %s for writing\n",
+				isoform_rep_tracking_name);
+		exit(1);
+	}
+	outfiles.isoform_rep_tracking_out = isoform_rep_out;
+    
+	char tss_group_rep_tracking_name[filename_buf_size];
+	sprintf(tss_group_rep_tracking_name, "%s/tss_groups.read_group_tracking", output_dir.c_str());
+	FILE* tss_group_rep_out = fopen(tss_group_rep_tracking_name, "w");
+	if (!tss_group_rep_out)
+	{
+		fprintf(stderr, "Error: cannot open TSS group-level read group tracking file %s for writing\n",
+				tss_group_rep_tracking_name);
+		exit(1);
+	}
+	outfiles.tss_group_rep_tracking_out = tss_group_rep_out;
+    
+	char cds_rep_tracking_name[filename_buf_size];
+	sprintf(cds_rep_tracking_name, "%s/cds.read_group_tracking", output_dir.c_str());
+	FILE* cds_rep_out = fopen(cds_rep_tracking_name, "w");
+	if (!cds_rep_out)
+	{
+		fprintf(stderr, "Error: cannot open CDS level read group tracking file %s for writing\n",
+				cds_rep_tracking_name);
+		exit(1);
+	}
+	outfiles.cds_rep_tracking_out = cds_rep_out;
+	
+	char gene_rep_tracking_name[filename_buf_size];
+	sprintf(gene_rep_tracking_name, "%s/genes.read_group_tracking", output_dir.c_str());
+	FILE* gene_rep_out = fopen(gene_rep_tracking_name, "w");
+	if (!gene_rep_out)
+	{
+		fprintf(stderr, "Error: cannot open gene-level read group tracking file %s for writing\n",
+				gene_rep_tracking_name);
+		exit(1);
+	}
+	outfiles.gene_rep_tracking_out = gene_rep_out;
+    
+    char read_group_info_name[filename_buf_size];
+	sprintf(read_group_info_name, "%s/read_groups.info", output_dir.c_str());
+	FILE* read_group_out = fopen(read_group_info_name, "w");
+	if (!read_group_out)
+	{
+		fprintf(stderr, "Error: cannot open read group info file %s for writing\n",
+				read_group_info_name);
+		exit(1);
+	}
+	outfiles.read_group_info_out = read_group_out;
+    
+    char run_info_name[filename_buf_size];
+	sprintf(run_info_name, "%s/run.info", output_dir.c_str());
+	FILE* run_info_out = fopen(run_info_name, "w");
+	if (!run_info_out)
+	{
+		fprintf(stderr, "Error: cannot open run info file %s for writing\n",
+				run_info_name);
+		exit(1);
+	}
+	outfiles.run_info_out = run_info_out;
+    
     driver(ref_gtf, mask_gtf, sam_hit_filenames, outfiles);
 	
 #if 0
diff --git a/src/cufflinks.cpp b/src/cufflinks.cpp
index 796af98..0c96192 100644
--- a/src/cufflinks.cpp
+++ b/src/cufflinks.cpp
@@ -96,6 +96,11 @@ static struct option long_options[] = {
 {"tile-read-sep",           required_argument,       0,          OPT_TILE_SEP}, 
     
 {"max-bundle-frags",        required_argument,        0,          OPT_MAX_FRAGS_PER_BUNDLE}, 
+{"num-frag-count-draws",	required_argument,		 0,			 OPT_NUM_FRAG_COUNT_DRAWS},
+{"num-frag-assign-draws",	required_argument,		 0,			 OPT_NUM_FRAG_ASSIGN_DRAWS},
+{"max-multiread-fraction",	required_argument,		 0,			 OPT_MAX_MULTIREAD_FRACTION},
+{"overlap-radius",       	required_argument,		 0,			 OPT_OLAP_RADIUS},
+{"max-frag-multihits",      required_argument,       0,          OPT_FRAG_MAX_MULTIHITS},
 {0, 0, 0, 0} // terminator
 };
 
@@ -124,9 +129,12 @@ void print_usage()
     fprintf(stderr, "  -s/--frag-len-std-dev        fragment length std deviation (unpaired reads only)   [ default:     80 ]\n");
     fprintf(stderr, "  --upper-quartile-norm        use upper-quartile normalization                      [ default:  FALSE ]\n");
     fprintf(stderr, "  --max-mle-iterations         maximum iterations allowed for MLE calculation        [ default:   5000 ]\n");
-    fprintf(stderr, "  --num-importance-samples     number of importance samples for MAP restimation      [ default:   1000 ]\n");
+    fprintf(stderr, "  --num-importance-samples     number of importance samples for MAP restimation      [    DEPRECATED   ]\n");
     fprintf(stderr, "  --compatible-hits-norm       count hits compatible with reference RNAs only        [ default:  FALSE ]\n");
     fprintf(stderr, "  --total-hits-norm            count all hits for normalization                      [ default:  TRUE  ]\n");
+    fprintf(stderr, "  --num-frag-count-draws       Number of fragment generation samples                 [ default:   1000 ]\n");
+    fprintf(stderr, "  --num-frag-assign-draws      Number of fragment assignment samples per generation  [ default:      1 ]\n");
+    fprintf(stderr, "  --max-frag-multihits         Maximum number of alignments allowed per fragment     [ default: unlim  ]\n");
     
     fprintf(stderr, "\nAdvanced Assembly Options:\n");
     fprintf(stderr, "  -L/--label                   assembled transcripts have this ID prefix             [ default:   CUFF ]\n");
@@ -142,6 +150,8 @@ void print_usage()
     fprintf(stderr, "  --min-intron-length          minimum intron size allowed in genome                 [ default:     50 ]\n");
     fprintf(stderr, "  --trim-3-avgcov-thresh       minimum avg coverage required to attempt 3' trimming  [ default:     10 ]\n");
     fprintf(stderr, "  --trim-3-dropoff-frac        fraction of avg coverage below which to trim 3' end   [ default:    0.1 ]\n");
+    fprintf(stderr, "  --max-multiread-fraction     maximum fraction of allowed multireads per transcript [ default:   0.75 ]\n");
+    fprintf(stderr, "  --overlap-radius             maximum gap size to fill between transfrags (in bp)   [ default:     50 ]\n");
     
     fprintf(stderr, "\nAdvanced Reference Annotation Guided Assembly Options:\n");
 //    fprintf(stderr, "  --tile-read-len              length of faux-reads                                  [ default:    405 ]\n");
@@ -393,6 +403,31 @@ int parse_options(int argc, char** argv)
                 max_frags_per_bundle = parseInt(0, "--max-bundle-frags must be at least 0", print_usage);
                 break;
             }
+            case OPT_NUM_FRAG_COUNT_DRAWS:
+            {
+                num_frag_count_draws = parseInt(1, "--num-frag-count-draws must be at least 1", print_usage);
+                break;
+            }
+            case OPT_NUM_FRAG_ASSIGN_DRAWS:
+            {
+                num_frag_assignments = parseInt(1, "--num-frag-assign-draws must be at least 1", print_usage);
+                break;
+            }
+            case OPT_MAX_MULTIREAD_FRACTION:
+            {
+                max_multiread_fraction = parseFloat(0, 1.0, "--max-multiread-fraction must be between 0 and 1.0", print_usage);
+                break;
+            }
+            case OPT_FRAG_MAX_MULTIHITS:
+            {
+                max_frag_multihits = parseInt(1, "--max-frag-multihits must be at least 1", print_usage);
+                break;
+            }
+            case OPT_OLAP_RADIUS:
+            {
+                olap_radius = parseInt(1, "--max-multiread-fraction must be at least 1", print_usage);
+                break;
+            }
 			default:
 				print_usage();
 				return 1;
@@ -1138,11 +1173,6 @@ void assemble_bundle(const RefSequenceTable& rt,
 	{
 		case REF_DRIVEN:
 			scaffolds = bundle.ref_scaffolds();
-			if (!final_est_run && scaffolds.size() != 1) // Only learn bias on single isoforms
-			{
-				delete bundle_ptr;
-				return;
-			}
 			break;
 		case REF_GUIDED:
 			successfully_assembled = scaffolds_for_bundle(bundle, scaffolds, &bundle.ref_scaffolds());
@@ -1217,9 +1247,9 @@ void assemble_bundle(const RefSequenceTable& rt,
 	{
 		for (size_t i = 0; i < genes.size(); ++i)
 		{
-			if (genes[i].isoforms().size() == 1)
-			{
-				bl_ptr -> preProcessTranscript(genes[i].isoforms()[0].scaffold()); 
+            for (size_t j = 0; j <genes[i].isoforms().size(); ++j)
+            {
+                bl_ptr -> preProcessTranscript(genes[i].isoforms()[j].scaffold()); 
 			}
 		}
 	}
diff --git a/src/differential.cpp b/src/differential.cpp
index 3e5cff0..cb9276f 100644
--- a/src/differential.cpp
+++ b/src/differential.cpp
@@ -23,6 +23,7 @@
 using namespace std;
 
 double min_read_count = 10;
+double min_outlier_p = 0.01;
 
 #if ENABLE_THREADS
 mutex _launcher_lock;
@@ -38,6 +39,101 @@ void decr_pool_count()
 }
 #endif
 
+void add_to_tracking_table(size_t sample_index,
+                           Abundance& ab,
+						   FPKMTrackingTable& track)
+
+{
+	pair<FPKMTrackingTable::iterator,bool> inserted;
+	pair<string, FPKMTracking > p;
+	p = make_pair(ab.description(), FPKMTracking());
+	inserted = track.insert(p);
+	
+	FPKMTracking& fpkm_track = inserted.first->second;
+	
+	set<string> tss = ab.tss_id();
+    set<string> gene_ids = ab.gene_id();
+	set<string> genes = ab.gene_name();
+	set<string> proteins = ab.protein_id();
+	
+	fpkm_track.tss_ids.insert(tss.begin(), tss.end());
+    fpkm_track.gene_ids.insert(gene_ids.begin(), gene_ids.end());
+	fpkm_track.gene_names.insert(genes.begin(), genes.end());
+	fpkm_track.protein_ids.insert(proteins.begin(), proteins.end());
+	
+	if (inserted.second)
+	{
+		fpkm_track.locus_tag = ab.locus_tag();
+		fpkm_track.description = ab.description();
+		shared_ptr<Scaffold> transfrag = ab.transfrag();
+		if (transfrag && transfrag->nearest_ref_id() != "")
+		{
+			fpkm_track.classcode = transfrag->nearest_ref_classcode();
+			fpkm_track.ref_match = transfrag->nearest_ref_id();
+		}
+		else
+		{
+			fpkm_track.classcode = 0;
+			fpkm_track.ref_match = "-";
+		}
+        if (transfrag)
+        {
+            fpkm_track.length = transfrag->length(); 
+        }
+        else
+        {
+            fpkm_track.length = 0;
+        }
+	}
+	
+	FPKMContext r1 = FPKMContext(ab.num_fragments(), 
+                                 ab.num_fragment_var(),
+                                 ab.num_fragment_uncertainty_var(),
+                                 ab.mass_variance(),
+                                 ab.num_fragments_by_replicate(),
+								 ab.FPKM(), 
+								 ab.FPKM_by_replicate(),
+                                 ab.FPKM_variance(),
+                                 ab.status(),
+                                 ab.status_by_replicate());
+    
+    
+	
+    vector<FPKMContext>& fpkms = inserted.first->second.fpkm_series;
+    if (sample_index < fpkms.size())
+    {
+        // if the fpkm series already has an entry matching this description
+        // for this sample index, then we are dealing with a group of transcripts
+        // that occupies multiple (genomically disjoint) bundles.  We need
+        // to add this bundle's contribution to the FPKM, fragments, and variance 
+        // to whatever's already there.  
+        
+        // NOTE: we can simply sum the FKPM_variances, because we are currently
+        // assuming that transcripts in disjoint bundles share no alignments and 
+        // thus have FPKM covariance == 0;  This assumption will no longer be
+        // true if we decide to do multireads the right way.
+        
+        FPKMContext& existing = fpkms[sample_index];
+        existing.FPKM += r1.FPKM;
+        existing.count_mean += r1.count_mean;
+        existing.FPKM_variance += r1.FPKM_variance;
+        if (existing.status == NUMERIC_FAIL || r1.status == NUMERIC_FAIL)
+        {
+            existing.status = NUMERIC_FAIL;
+        }
+        else 
+        {
+            existing.status = NUMERIC_OK;
+        }
+        
+    }
+    else 
+    {
+        fpkms.push_back(r1);
+    }
+}
+
+
 TestLauncher::launcher_sample_table::iterator TestLauncher::find_locus(const string& locus_id)
 {
     launcher_sample_table::iterator itr = _samples.begin();
@@ -94,6 +190,10 @@ bool TestLauncher::all_samples_reported_in(vector<shared_ptr<SampleAbundances> >
     return true;
 }
 
+#if ENABLE_THREADS
+mutex test_storage_lock; // don't modify the above struct without locking here
+#endif
+
 // Note: this routine should be called under lock - it doesn't
 // acquire the lock itself. 
 void TestLauncher::perform_testing(vector<shared_ptr<SampleAbundances> >& abundances)
@@ -122,6 +222,71 @@ void TestLauncher::perform_testing(vector<shared_ptr<SampleAbundances> >& abunda
     test_differential(abundances.front()->locus_tag, abundances, *_tests, *_tracking, _samples_are_time_series);
 }
 
+// Note: this routine should be called under lock - it doesn't
+// acquire the lock itself. 
+void TestLauncher::record_tracking_data(vector<shared_ptr<SampleAbundances> >& abundances)
+{
+    assert (abundances.size() == _orig_workers);
+    
+    // Just verify that all the loci from each factory match up.
+    for (size_t i = 1; i < abundances.size(); ++i)
+    {
+        const SampleAbundances& curr = *(abundances[i]);
+        const SampleAbundances& prev = *(abundances[i-1]);
+        
+        assert (curr.locus_tag == prev.locus_tag);
+        
+        const AbundanceGroup& s1 = curr.transcripts;
+        const AbundanceGroup& s2 =  prev.transcripts;
+        
+        assert (s1.abundances().size() == s2.abundances().size());
+        
+        for (size_t j = 0; j < s1.abundances().size(); ++j)
+        {
+            assert (s1.abundances()[j]->description() == s2.abundances()[j]->description());
+        }
+    }
+    
+#if ENABLE_THREADS
+	test_storage_lock.lock();
+#endif
+    
+    // Add all the transcripts, CDS groups, TSS groups, and genes to their
+    // respective FPKM tracking table.  Whether this is a time series or an
+    // all pairs comparison, we should be calculating and reporting FPKMs for 
+    // all objects in all samples
+	for (size_t i = 0; i < abundances.size(); ++i)
+	{
+		const AbundanceGroup& ab_group = abundances[i]->transcripts;
+        //fprintf(stderr, "[%d] count = %lg\n",i,  ab_group.num_fragments());
+		foreach (shared_ptr<Abundance> ab, ab_group.abundances())
+		{
+			add_to_tracking_table(i, *ab, _tracking->isoform_fpkm_tracking);
+            //assert (_tracking->isoform_fpkm_tracking.num_fragments_by_replicate().empty() == false);
+		}
+		
+		foreach (AbundanceGroup& ab, abundances[i]->cds)
+		{
+			add_to_tracking_table(i, ab, _tracking->cds_fpkm_tracking);
+		}
+		
+		foreach (AbundanceGroup& ab, abundances[i]->primary_transcripts)
+		{
+			add_to_tracking_table(i, ab, _tracking->tss_group_fpkm_tracking);
+		}
+		
+		foreach (AbundanceGroup& ab, abundances[i]->genes)
+		{
+			add_to_tracking_table(i, ab, _tracking->gene_fpkm_tracking);
+		}
+	}
+    
+#if ENABLE_THREADS
+    test_storage_lock.unlock();
+#endif
+    
+}
+
 void TestLauncher::test_finished_loci()
 {
 #if ENABLE_THREADS
@@ -143,6 +308,7 @@ void TestLauncher::test_finished_loci()
                     verbose_msg("Testing for differential expression and regulation in locus [%s]\n", itr->second.front()->locus_tag.c_str());
                     _p_bar->update(itr->second.front()->locus_tag.c_str(), 1);
                 }
+                record_tracking_data(itr->second);
                 perform_testing(itr->second);
             }
             else
@@ -152,6 +318,7 @@ void TestLauncher::test_finished_loci()
                     //verbose_msg("Testing for differential expression and regulation in locus [%s]\n", abundances.front()->locus_tag.c_str());
                     _p_bar->update(itr->second.front()->locus_tag.c_str(), 1);
                 }
+                record_tracking_data(itr->second);
             }
             itr = _samples.erase(itr);
         }
@@ -304,22 +471,16 @@ shared_ptr<SampleDifferenceMetaData> get_metadata(const string description)
 
 // This performs between-group tests on isoforms or TSS groupings in a single
 // locus, on two different samples.
-pair<int, SampleDiffs::iterator>  get_de_tests(const string& description,
+SampleDifference get_de_tests(const string& description,
                  const FPKMContext& prev_abundance,
 				 const FPKMContext& curr_abundance,
-				 SampleDiffs& de_tests,
+				 //SampleDiffs& de_tests,
 				 bool enough_reads)
 {
 	int total_iso_de_tests = 0;
 			
 	SampleDifference test;
     
-	pair<SampleDiffs::iterator, bool> inserted;
-//	inserted = de_tests.insert(make_pair(curr_abundance.description(),
-//										 SampleDifference())); 
-    inserted = de_tests.insert(make_pair(description,
-    									 SampleDifference())); 
-    
     const FPKMContext& r1 = curr_abundance;
     const FPKMContext& r2 = prev_abundance;
     
@@ -378,9 +539,10 @@ pair<int, SampleDiffs::iterator>  get_de_tests(const string& description,
 	}
 	
     
-	inserted.first->second = test;
+	//inserted.first->second = test;
 	
-	return make_pair(total_iso_de_tests, inserted.first);
+	//return make_pair(total_iso_de_tests, inserted.first);
+    return test;
 }
 
 
@@ -521,96 +683,24 @@ pair<int, SampleDiffs::iterator>  get_de_tests(const string& description,
 //    return true;
 //}
 
-bool generate_null_js_samples(const AbundanceGroup& null_abundance,
-                              size_t num_js_samples,
-                              multinormal_generator<double>& generator,
-                              vector<double>& js_samples)
-{
-    ublas::vector<double> null_kappa_mean(null_abundance.abundances().size());
-    for (size_t i = 0; i < null_abundance.abundances().size(); ++i)
-    {
-        null_kappa_mean(i) = null_abundance.abundances()[i]->kappa();
-    }
-    
-    ublas::matrix<double> null_kappa_cov = null_abundance.kappa_cov();
-    
-    double prev_ret = cholesky_factorize(null_kappa_cov);
-    if (prev_ret != 0)
-        return false;
-    
-//    cerr << endl << null_kappa_mean << endl;
-//    for (unsigned i = 0; i < null_kappa_cov.size1 (); ++ i) 
-//    {
-//        ublas::matrix_row<ublas::matrix<double> > mr (null_kappa_cov, i);
-//        std::cerr << i << " : " << mr << std::endl;
-//    }
-//    cerr << "======" << endl;
-    
-    vector<ublas::vector<double> > null_samples;
-    
-    // It's a little silly that we have to do this, but since we always initialize
-    // the random number generators to random_seed, instead of time(NULL), simply
-    // creating a new generator (rather than re-using it) 
-    generator.set_parameters(null_kappa_mean, null_kappa_cov);
-    
-    generate_importance_samples(generator, null_samples, num_js_samples, false);
-    if (null_samples.size() == 0)
-        return false;
-    
-    js_samples.clear();
-    
-    //size_t num_samples = std::min(prev_samples.size(), curr_samples.size());
-    size_t num_samples = num_js_samples;
-    vector<ublas::vector<double> > sample_kappas(2);
-    
-    boost::uniform_int<> null_uniform_dist(0,null_samples.size()-1);
-    boost::mt19937 null_rng; 
-    boost::variate_generator<boost::mt19937&, boost::uniform_int<> > null_uniform_gen(null_rng, null_uniform_dist); 
-    
-    for (size_t i = 0; i < num_samples; ++i)
-    {
-		sample_kappas[0] = null_samples[null_uniform_gen()];
-        sample_kappas[1] = null_samples[null_uniform_gen()];
-        
-		double js = jensen_shannon_distance(sample_kappas);  
-        //cerr << sample_kappas[0] << " vs. " <<  sample_kappas[1] << " = " << js << endl;
-        js_samples.push_back(js);
-    }
-
-    sort(js_samples.begin(), js_samples.end());
-    
-    //    for (size_t i = 0; i < 100; ++i)
-    //    {
-    //        fprintf(stderr, "%lg\n", js_samples[i]);
-    //    }
-    return true;
-}
-
 // Calculates the probability that drawing two samples from the provided
 // relative abundance distribution would have produced a value at least as
 // extreme as the given js value.
 bool one_sided_js_test(const AbundanceGroup& null_abundances,
-                       size_t num_samples,
-                       multinormal_generator<double>& generator,
                        double js,
                        double& p_val)
 {
-    vector<double> js_samples;
-    
+    const vector<double>& js_samples = null_abundances.null_js_samples();
     
-    bool success = generate_null_js_samples(null_abundances, num_samples, generator, js_samples);
-    if (success == false)
-        return false;
-    
-    vector<double>::iterator lb = lower_bound(js_samples.begin(), js_samples.end(), js);
+    vector<double>::const_iterator lb = lower_bound(js_samples.begin(), js_samples.end(), js);
     if (lb != js_samples.end())
     {
         size_t num_less_extreme_samples = lb - js_samples.begin();
         p_val =  1.0  - ((double)num_less_extreme_samples/js_samples.size());
     }
-    else if (num_samples)
+    else if (js_samples.size())
     {
-        p_val = 1.0/num_samples;
+        p_val = 1.0/js_samples.size();
     }
     else
     {
@@ -625,14 +715,14 @@ bool test_js(const AbundanceGroup& prev_abundance,
              double& js,
              double& p_val)
 {
-    vector<ublas::vector<double> > sample_kappas;
-    ublas::vector<double> curr_kappas(curr_abundance.abundances().size());
+    vector<Eigen::VectorXd> sample_kappas;
+    Eigen::VectorXd curr_kappas(Eigen::VectorXd::Zero(curr_abundance.abundances().size()));
     for (size_t i = 0; i < curr_abundance.abundances().size(); ++i)
     {
         curr_kappas(i) = curr_abundance.abundances()[i]->kappa();
     }
     
-    ublas::vector<double> prev_kappas(prev_abundance.abundances().size());
+    Eigen::VectorXd prev_kappas(Eigen::VectorXd::Zero(prev_abundance.abundances().size()));
     for (size_t i = 0; i < prev_abundance.abundances().size(); ++i)
     {
         prev_kappas(i) = prev_abundance.abundances()[i]->kappa();
@@ -646,21 +736,11 @@ bool test_js(const AbundanceGroup& prev_abundance,
     if (isinf(js) || isnan(js))
         return false;
     
-    static const int num_samples = 100000;
-    
-//    bool success = generate_js_samples(prev_abundance, curr_abundance, num_samples, js_samples);
-//    if (success == false)
-//        return false;
-
-    multinormal_generator<double> gen(ublas::zero_vector<double>(prev_abundance.kappa_cov().size1()),
-                                      ublas::zero_matrix<double>(prev_abundance.kappa_cov().size1(),
-                                                                 prev_abundance.kappa_cov().size2()));
-    
     double prev_p_val = 1.0;
-    bool prev_succ = one_sided_js_test(prev_abundance, num_samples, gen, js, prev_p_val);
+    bool prev_succ = one_sided_js_test(prev_abundance, js, prev_p_val);
     
     double curr_p_val = 1.0;
-    bool curr_succ = one_sided_js_test(curr_abundance, num_samples, gen, js, curr_p_val);
+    bool curr_succ = one_sided_js_test(curr_abundance, js, curr_p_val);
 
     if (!curr_succ || !prev_succ)
         return false;
@@ -702,83 +782,48 @@ bool test_js(const AbundanceGroup& prev_abundance,
 // This performs within-group tests on a set of isoforms or a set of TSS groups.
 // This is a way of looking for meaningful differential splicing or differential
 // promoter use.
-void get_ds_tests(const AbundanceGroup& prev_abundance,
-				  const AbundanceGroup& curr_abundance,
-				  SampleDiffs& diff_tests,
-				  bool enough_reads)
+SampleDifference get_ds_tests(const AbundanceGroup& prev_abundance,
+                              const AbundanceGroup& curr_abundance,
+//                              SampleDiffs& diff_tests,
+                              bool enough_reads)
 {	
 	const string& name = curr_abundance.description();
 	
-	pair<SampleDiffs::iterator, bool> inserted;
-	inserted = diff_tests.insert(make_pair(name,SampleDifference())); 
 	SampleDifference test;
-	
-    shared_ptr<SampleDifferenceMetaData> meta_data = get_metadata(name);
-    
-    meta_data->gene_ids = curr_abundance.gene_id();
-    meta_data->gene_names = curr_abundance.gene_name();
-    meta_data->protein_ids = curr_abundance.protein_id();
-    meta_data->locus_desc = curr_abundance.locus_tag();
-    meta_data->description = curr_abundance.description();
     
-    test.meta_data = meta_data;
-	
 	test.test_status = NOTEST;
 	
 	AbundanceStatus prev_status = curr_abundance.status();
 	AbundanceStatus curr_status = prev_abundance.status();
     
-    vector<bool> to_keep(curr_abundance.abundances().size(), false);
-    //vector<bool> to_keep(curr_abundance.abundances().size(), false);
-    
-    for (size_t k = 0; k < prev_abundance.abundances().size(); ++k)
+    if (prev_abundance.abundances().size() == 1 ||
+        (prev_status == NUMERIC_OK && prev_abundance.num_fragments() == 0) ||
+        (curr_status == NUMERIC_OK && curr_abundance.num_fragments() == 0))
     {
-        // assert (false);
-        
-        bool prev_enough_reads = false;
-        // do both curr and prev so that groups have the same number of slices.
-        if (prev_abundance.abundances()[k]->num_fragments() && prev_abundance.abundances()[k]->effective_length())
-        {
-            double frags_per_kb = prev_abundance.abundances()[k]->num_fragments() / (prev_abundance.abundances()[k]->effective_length() / 1000.0);
-            if (frags_per_kb >= min_read_count)
-                prev_enough_reads = true;
-        }
-        
-        bool curr_enough_reads = false;
-        if (curr_abundance.abundances()[k]->num_fragments() && curr_abundance.abundances()[k]->effective_length())
-        {
-            double frags_per_kb = curr_abundance.abundances()[k]->num_fragments() / (curr_abundance.abundances()[k]->effective_length() / 1000.0);
-            if (frags_per_kb >= min_read_count)
-                curr_enough_reads = true;
-        }
-        
-        if (curr_enough_reads || prev_enough_reads)
-            to_keep[k] = true;
+        test.p_value = 1;
+        test.value_1 = 0;
+        test.value_2 = 0;
+        test.differential = 0;
+        test.test_status = NOTEST;
     }
-    
-    AbundanceGroup filtered_prev;
-    prev_abundance.filter_group(to_keep, filtered_prev);
-    
-    AbundanceGroup filtered_curr;
-    curr_abundance.filter_group(to_keep, filtered_curr);
-    
-	if (filtered_prev.abundances().size() > 1 &&
-        /*filtered_prev.has_member_with_status(NUMERIC_LOW_DATA) == false &&
+	else if (prev_abundance.abundances().size() > 1 &&
+        /*prev_abundance.has_member_with_status(NUMERIC_LOW_DATA) == false &&
         filtered_curr.has_member_with_status(NUMERIC_LOW_DATA) == false &&*/ 
-        prev_status == NUMERIC_OK && filtered_prev.num_fragments() > 0 &&
-		curr_status == NUMERIC_OK && filtered_curr.num_fragments() > 0)
+        prev_status == NUMERIC_OK && prev_abundance.num_fragments() > 0 &&
+		curr_status == NUMERIC_OK && curr_abundance.num_fragments() > 0)
 	{
 		vector<ublas::vector<double> > sample_kappas;
-		ublas::vector<double> curr_kappas(filtered_curr.abundances().size());
-		for (size_t i = 0; i < filtered_curr.abundances().size(); ++i)
+		ublas::vector<double> curr_kappas(curr_abundance.abundances().size());
+        
+        for (size_t i = 0; i < curr_abundance.abundances().size(); ++i)
 		{
-			curr_kappas(i) = filtered_curr.abundances()[i]->kappa();
+			curr_kappas(i) = curr_abundance.abundances()[i]->kappa();
 		}
 		
-		ublas::vector<double> prev_kappas(filtered_prev.abundances().size());
-		for (size_t i = 0; i < filtered_prev.abundances().size(); ++i)
+		ublas::vector<double> prev_kappas(prev_abundance.abundances().size());
+        for (size_t i = 0; i < prev_abundance.abundances().size(); ++i)
 		{
-			prev_kappas(i) = filtered_prev.abundances()[i]->kappa();
+			prev_kappas(i) = prev_abundance.abundances()[i]->kappa();
 		}
 		
 		sample_kappas.push_back(prev_kappas);
@@ -787,7 +832,9 @@ void get_ds_tests(const AbundanceGroup& prev_abundance,
         double js = 0.0;
         double p_val = 1.0;
         
-		bool success = test_js(filtered_prev, filtered_curr, js, p_val);
+        bool success;
+        success = test_js(prev_abundance, curr_abundance, js, p_val);
+        
 		if (js == 0.0 || success == false)
 		{
 			test.test_stat = 0;
@@ -799,122 +846,19 @@ void get_ds_tests(const AbundanceGroup& prev_abundance,
 		}
 		else
 		{
-            test.test_stat = 0;
+            //test.test_stat = 0;
 			test.p_value = p_val;
 			test.value_1 = 0;
 			test.value_2 = 0;
 			test.differential = js;
 			test.test_status = enough_reads ? OK : NOTEST;
-            
-            ///////////////////
-#if 1
-            ublas::vector<double> js_gradient;
-            jensen_shannon_gradient(sample_kappas, js, js_gradient);
-            
-            vector<ublas::matrix<double> > covariances;
-            
-            covariances.push_back(filtered_prev.kappa_cov());
-            covariances.push_back(filtered_curr.kappa_cov());
-            
-            ublas::matrix<double> js_covariance;
-            assert (covariances.size() > 0);
-            for (size_t i = 0; i < covariances.size(); ++i)
-            {
-                assert (covariances[i].size1() > 0 && covariances[i].size2() > 0);
-            }
-            make_js_covariance_matrix(covariances,js_covariance);
-            assert (js_covariance.size1() > 0 && js_covariance.size2() > 0);
-            
-            double js_var = inner_prod(js_gradient, 
-                                       prod(js_covariance, js_gradient));
-            assert (!isinf(js_var) && !isnan(js_var));
-
-            if (js_var > 0.0)
-            {
-                // We're dealing with a standard normal that's been truncated below zero
-                // so pdf(js) is twice the standard normal, and cdf is 0.5 * (cdf of normal - 1)
-                
-                normal test_dist(0,1.0);
-                //double denom = sqrt(js_var);
-                double p = js/sqrt(js_var);
-                //test.test_stat = 2 * pdf(test_dist, p);
-                // analytic p_value:
-                test.test_stat = 1.0 - ((cdf(test_dist, p) - 0.5) / 0.5);
-            }
-
-#endif
-            ///////////////////
-            
-            
-            
-//			ublas::vector<double> js_gradient;
-//			jensen_shannon_gradient(sample_kappas, js, js_gradient);
-//			
-//			vector<ublas::matrix<double> > covariances;
-//			
-//			covariances.push_back(filtered_prev.kappa_cov());
-//			covariances.push_back(filtered_curr.kappa_cov());
-//			
-//			ublas::matrix<double> js_covariance;
-//			assert (covariances.size() > 0);
-//			for (size_t i = 0; i < covariances.size(); ++i)
-//			{
-//				assert (covariances[i].size1() > 0 && covariances[i].size2() > 0);
-//			}
-//			make_js_covariance_matrix(covariances,js_covariance);
-//			assert (js_covariance.size1() > 0 && js_covariance.size2() > 0);
-//			
-//			double js_var = inner_prod(js_gradient, 
-//									   prod(js_covariance, js_gradient));
-//            assert (!isinf(js_var) && !isnan(js_var));
-//
-//#ifdef DEBUG
-//			if (isinf(js_var) || isnan(js_var))
-//			{
-//				cerr << "grad: " << js_gradient << endl;
-//				cerr << "js_cov: " << js_covariance << endl;
-//				cerr << prod(js_covariance, js_gradient) << endl;	
-//			}
-//#endif
-//			if (js_var <= 0.0)
-//			{
-//                
-//				test.test_stat = 0;
-//				test.p_value = 1.0;
-//				test.value_1 = 0;
-//				test.value_2 = 0;
-//				test.differential = 0;
-//				test.test_status = NOTEST;
-//			}
-//			else
-//			{
-//                // We're dealing with a standard normal that's been truncated below zero
-//                // so pdf(js) is twice the standard normal, and cdf is 0.5 * (cdf of normal - 1)
-//                
-//				normal test_dist(0,1.0);
-//				//double denom = sqrt(js_var);
-//				double p = js/sqrt(js_var);
-//                test.test_stat = 2 * pdf(test_dist, p);
-//				test.p_value = 1.0 - ((cdf(test_dist, p) - 0.5) / 0.5);
-//				test.value_1 = 0;
-//				test.value_2 = 0;
-//				test.differential = js;
-//				test.test_status = enough_reads ? OK : NOTEST;
-//			}
-//			if (isinf(test.test_stat) || isnan(test.test_stat))
-//			{
-//				fprintf(stderr, "Warning: test stat is invalid!\n");
-//				exit(1);
-//			}
-		}
-
-		inserted.first->second = test;
+        }
 	}
 	else // we won't even bother with the JS-based testing in LOWDATA cases.
 	{
         if (prev_status == NUMERIC_OK && curr_status == NUMERIC_OK && 
-            filtered_prev.has_member_with_status(NUMERIC_LOW_DATA) == false &&
-            filtered_curr.has_member_with_status(NUMERIC_LOW_DATA) == false)
+            prev_abundance.has_member_with_status(NUMERIC_LOW_DATA) == false &&
+            curr_abundance.has_member_with_status(NUMERIC_LOW_DATA) == false)
             test.test_status = NOTEST;
         else if (prev_status == NUMERIC_FAIL || curr_status == NUMERIC_FAIL)
             test.test_status = FAIL;
@@ -924,8 +868,9 @@ void get_ds_tests(const AbundanceGroup& prev_abundance,
 		test.test_stat = 0;
 		test.p_value = 0.0;
 		test.differential = 0.0;
-		inserted.first->second = test;
 	}
+    
+    return test;
 }
 
 string make_ref_tag(const string& ref, char classcode)
@@ -939,116 +884,26 @@ string make_ref_tag(const string& ref, char classcode)
 	
 	return string(tag_buf);
 }
-void add_to_tracking_table(size_t sample_index,
-                           Abundance& ab,
-						   FPKMTrackingTable& track)
 
+string bundle_locus_tag(const RefSequenceTable& rt, 
+						const HitBundle& bundle)
 {
-	pair<FPKMTrackingTable::iterator,bool> inserted;
-	pair<string, FPKMTracking > p;
-	p = make_pair(ab.description(), FPKMTracking());
-	inserted = track.insert(p);
-	
-	FPKMTracking& fpkm_track = inserted.first->second;
-	
-	set<string> tss = ab.tss_id();
-    set<string> gene_ids = ab.gene_id();
-	set<string> genes = ab.gene_name();
-	set<string> proteins = ab.protein_id();
+	char locus_buf[1024];
+	RefID bundle_chr_id = bundle.ref_id();
+	assert (bundle_chr_id != 0);
+	const char* chr_name = rt.get_name(bundle_chr_id);
 	
-	fpkm_track.tss_ids.insert(tss.begin(), tss.end());
-    fpkm_track.gene_ids.insert(gene_ids.begin(), gene_ids.end());
-	fpkm_track.gene_names.insert(genes.begin(), genes.end());
-	fpkm_track.protein_ids.insert(proteins.begin(), proteins.end());
-	
-	if (inserted.second)
-	{
-		fpkm_track.locus_tag = ab.locus_tag();
-		fpkm_track.description = ab.description();
-		shared_ptr<Scaffold> transfrag = ab.transfrag();
-		if (transfrag && transfrag->nearest_ref_id() != "")
-		{
-			fpkm_track.classcode = transfrag->nearest_ref_classcode();
-			fpkm_track.ref_match = transfrag->nearest_ref_id();
-		}
-		else
-		{
-			fpkm_track.classcode = 0;
-			fpkm_track.ref_match = "-";
-		}
-        if (transfrag)
-        {
-            fpkm_track.length = transfrag->length(); 
-        }
-        else
-        {
-            fpkm_track.length = 0;
-        }
-	}
-	
-	FPKMContext r1 = FPKMContext(ab.num_fragments(), 
-								 ab.FPKM(), 
-								 ab.FPKM_variance(),
-                                 ab.status());
-    
-    
-	
-    vector<FPKMContext>& fpkms = inserted.first->second.fpkm_series;
-    if (sample_index < fpkms.size())
-    {
-        // if the fpkm series already has an entry matching this description
-        // for this sample index, then we are dealing with a group of transcripts
-        // that occupies multiple (genomically disjoint) bundles.  We need
-        // to add this bundle's contribution to the FPKM, fragments, and variance 
-        // to whatever's already there.  
-        
-        // NOTE: we can simply sum the FKPM_variances, because we are currently
-        // assuming that transcripts in disjoint bundles share no alignments and 
-        // thus have FPKM covariance == 0;  This assumption will no longer be
-        // true if we decide to do multireads the right way.
-        
-        FPKMContext& existing = fpkms[sample_index];
-        existing.FPKM += r1.FPKM;
-        existing.counts += r1.counts;
-        existing.FPKM_variance += r1.FPKM_variance;
-        if (existing.status == NUMERIC_FAIL || r1.status == NUMERIC_FAIL)
-        {
-            existing.status = NUMERIC_FAIL;
-        }
-        else 
-        {
-            existing.status = NUMERIC_OK;
-        }
-
-    }
-    else 
-    {
-        fpkms.push_back(r1);
-    }
-}
-
-string bundle_locus_tag(const RefSequenceTable& rt, 
-						const HitBundle& bundle)
-{
-	char locus_buf[1024];
-	RefID bundle_chr_id = bundle.ref_id();
-	assert (bundle_chr_id != 0);
-	const char* chr_name = rt.get_name(bundle_chr_id);
-	
-	sprintf(locus_buf, 
-			"%s:%d-%d",
-			chr_name,
-			bundle.left(),
-			bundle.right());
+	sprintf(locus_buf, 
+			"%s:%d-%d",
+			chr_name,
+			bundle.left(),
+			bundle.right());
 	
 	return string(locus_buf);
 }
 
-#if ENABLE_THREADS
-mutex test_storage_lock; // don't modify the above struct without locking here
-#endif
-
 void sample_abundance_worker(const string& locus_tag,
+                             const set<shared_ptr<ReadGroupProperties const> >& rg_props,
                              SampleAbundances& sample,
                              HitBundle* sample_bundle,
                              bool perform_cds_analysis,
@@ -1067,10 +922,11 @@ void sample_abundance_worker(const string& locus_tag,
     }
     
     sample.transcripts = AbundanceGroup(abundances);
+    sample.transcripts.init_rg_props(rg_props);
     
     vector<MateHit> hits_in_cluster;
     
-    if (sample_bundle->hits().size() < max_frags_per_bundle)
+    if (sample_bundle->hits().size() < (size_t)max_frags_per_bundle)
     {
         get_alignments_from_scaffolds(sample.transcripts.abundances(),
                                       hits_in_cluster);
@@ -1108,25 +964,42 @@ void sample_abundance_worker(const string& locus_tag,
         // Cluster transcripts by CDS
         vector<AbundanceGroup> transcripts_by_cds;
         ublas::matrix<double> cds_gamma_cov;
-        ublas::matrix<double> cds_gamma_boot_cov;
         ublas::matrix<double> cds_count_cov;
         ublas::matrix<double> cds_iterated_exp_count_cov;
         ublas::matrix<double> cds_fpkm_cov;
-        cluster_transcripts<ConnectByAnnotatedProteinId>(sample.transcripts,
+        vector<Eigen::VectorXd> cds_assigned_counts;
+        
+        vector<bool> mask(sample.transcripts.abundances().size(), true);
+        for (size_t i = 0; i < sample.transcripts.abundances().size(); ++i)
+        {
+            if (*(sample.transcripts.abundances()[i]->protein_id().begin()) == "")
+            {
+                mask[i] = false;
+            }
+        }
+        
+        AbundanceGroup trans_with_p_id; 
+        sample.transcripts.filter_group(mask, trans_with_p_id);
+        
+        cluster_transcripts<ConnectByAnnotatedProteinId>(trans_with_p_id,
                                                          transcripts_by_cds,
                                                          &cds_gamma_cov,
                                                          &cds_iterated_exp_count_cov,
                                                          &cds_count_cov,
                                                          &cds_fpkm_cov,
-                                                         &cds_gamma_boot_cov);
+                                                         &cds_assigned_counts);
+        
         foreach(AbundanceGroup& ab_group, transcripts_by_cds)
         {
             ab_group.locus_tag(locus_tag);
             set<string> protein_ids = ab_group.protein_id();
             assert (protein_ids.size() == 1);
             string desc = *(protein_ids.begin()); 
+            //if (desc != "")
+            //{
             assert (desc != "");
             ab_group.description(*(protein_ids.begin()));
+            //}
         }
         
         sample.cds = transcripts_by_cds;
@@ -1137,18 +1010,21 @@ void sample_abundance_worker(const string& locus_tag,
         set<shared_ptr<ReadGroupProperties const> > rg_props;
         foreach (AbundanceGroup& ab_group, sample.cds)
         {
-            cds_abundances.push_back(shared_ptr<Abundance>(new AbundanceGroup(ab_group)));
-            max_cds_mass_variance = max(ab_group.max_mass_variance(), max_cds_mass_variance);
-            rg_props.insert(ab_group.rg_props().begin(), ab_group.rg_props().end()); 
+            //if (ab_group.description() != "")
+            {
+                cds_abundances.push_back(shared_ptr<Abundance>(new AbundanceGroup(ab_group)));
+                max_cds_mass_variance = max(ab_group.max_mass_variance(), max_cds_mass_variance);
+                rg_props.insert(ab_group.rg_props().begin(), ab_group.rg_props().end()); 
+            }
         }
         AbundanceGroup cds(cds_abundances,
                            cds_gamma_cov,
-                           cds_gamma_boot_cov,
                            cds_iterated_exp_count_cov,
                            cds_count_cov,
                            cds_fpkm_cov,
                            max_cds_mass_variance,
-                           rg_props);
+                           rg_props,
+                           cds_assigned_counts);
         
         vector<AbundanceGroup> cds_by_gene;
         
@@ -1172,19 +1048,32 @@ void sample_abundance_worker(const string& locus_tag,
         vector<AbundanceGroup> transcripts_by_tss;
         
         ublas::matrix<double> tss_gamma_cov;
-        ublas::matrix<double> tss_gamma_boot_cov;
         ublas::matrix<double> tss_count_cov;
         ublas::matrix<double> tss_iterated_exp_count_cov;
         ublas::matrix<double> tss_fpkm_cov;
-        cluster_transcripts<ConnectByAnnotatedTssId>(sample.transcripts,
+        vector<Eigen::VectorXd> tss_assigned_counts;
+        
+        vector<bool> mask(sample.transcripts.abundances().size(), true);
+        for (size_t i = 0; i < sample.transcripts.abundances().size(); ++i)
+        {
+            if (*(sample.transcripts.abundances()[i]->tss_id().begin()) == "")
+            {
+                mask[i] = false;
+            }
+        }
+        
+        AbundanceGroup trans_with_tss; 
+        sample.transcripts.filter_group(mask, trans_with_tss);
+        
+        cluster_transcripts<ConnectByAnnotatedTssId>(trans_with_tss,
                                                      transcripts_by_tss,
                                                      &tss_gamma_cov,
                                                      &tss_iterated_exp_count_cov,
                                                      &tss_count_cov,
                                                      &tss_fpkm_cov,
-                                                     &tss_gamma_boot_cov);
+                                                     &tss_assigned_counts);
+        
         
-       
         foreach(AbundanceGroup& ab_group, transcripts_by_tss)
         {
             ab_group.locus_tag(locus_tag);
@@ -1211,12 +1100,12 @@ void sample_abundance_worker(const string& locus_tag,
         
         AbundanceGroup primary_transcripts(primary_transcript_abundances,
                                            tss_gamma_cov,
-                                           tss_gamma_boot_cov,
                                            tss_iterated_exp_count_cov,
                                            tss_count_cov,
                                            tss_fpkm_cov,
                                            max_tss_mass_variance,
-                                           rg_props);
+                                           rg_props,
+                                           tss_assigned_counts);
         
         vector<AbundanceGroup> primary_transcripts_by_gene;
         
@@ -1246,7 +1135,7 @@ void sample_abundance_worker(const string& locus_tag,
 struct LocusVarianceInfo
 {
     int factory_id;
-    double mean_count;
+    double count_mean;
     double count_empir_var;
     double locus_count_fitted_var;
     double isoform_fitted_var_sum;
@@ -1270,6 +1159,9 @@ mutex variance_info_lock; // don't modify the above struct without locking here
 
 vector<LocusVarianceInfo> locus_variance_info_table;
 
+// We'll use this tracking table to collect per replicate counts for each 
+// transcript, so we can re-fit the variance model.
+FPKMTrackingTable transcript_count_tracking; 
 
 void sample_worker(const RefSequenceTable& rt,
                    ReplicatedBundleFactory& sample_factory,
@@ -1284,7 +1176,7 @@ void sample_worker(const RefSequenceTable& rt,
     HitBundle bundle;
     bool non_empty = sample_factory.next_bundle(bundle);
     
-    if (!non_empty || (!corr_multi && !final_est_run && bundle.ref_scaffolds().size() != 1)) // Only learn on single isoforms
+    if (!non_empty || (bias_run && bundle.ref_scaffolds().size() != 1)) // Only learn on single isoforms
     {
 #if !ENABLE_THREADS
         // If Cuffdiff was built without threads, we need to manually invoke 
@@ -1311,22 +1203,30 @@ void sample_worker(const RefSequenceTable& rt,
     
     abundance->locus_tag = locus_tag;
     
-    bool perform_cds_analysis = final_est_run;
-    bool perform_tss_analysis = final_est_run;
+    bool perform_cds_analysis = false;
+    bool perform_tss_analysis = false;
 
     foreach(shared_ptr<Scaffold> s, bundle.ref_scaffolds())
     {
-        if (s->annotated_tss_id() == "")
+        if (s->annotated_tss_id() != "")
         {
-            perform_tss_analysis = false;
+            perform_tss_analysis = final_est_run;
         }
-        if (s->annotated_protein_id() == "")
+        if (s->annotated_protein_id() != "")
         {
-            perform_cds_analysis = false;
+            perform_cds_analysis = final_est_run;
         }
     }
 
+    set<shared_ptr<ReadGroupProperties const> > rg_props;
+    for (size_t i = 0; i < sample_factory.factories().size(); ++i)
+    {
+        shared_ptr<BundleFactory> bf = sample_factory.factories()[i];
+        rg_props.insert(bf->read_group_properties());
+    }
+    
     sample_abundance_worker(boost::cref(locus_tag),
+                            boost::cref(rg_props),
                             boost::ref(*abundance),
                             &bundle,
                             perform_cds_analysis,
@@ -1336,101 +1236,106 @@ void sample_worker(const RefSequenceTable& rt,
     variance_info_lock.lock();
 #endif
     
-    ///////////////////////////////////////////////
-    shared_ptr<MassDispersionModel const> disperser = sample_factory.mass_dispersion_model();
-    pair<double, double> locus_mv = disperser->get_raw_mean_and_var(locus_tag);
-    if (locus_mv.first != 0 && locus_mv.second != 0)
-    {
-        LocusVarianceInfo info;
-        info.factory_id = factory_id;
-        info.mean_count = locus_mv.first;
-        info.count_empir_var = locus_mv.second;
-        info.locus_count_fitted_var = disperser->scale_mass_variance(info.mean_count);
-        
-        double total_iso_scaled_var = 0.0;
-        
-        const AbundanceGroup& ab_group = abundance->transcripts;
-        info.locus_total_frags = ab_group.total_frags();
-        info.locus_salient_frags = ab_group.salient_frags();
-        //double group_counts = ab_group.total_frags();
-        ublas::matrix<double> cov = ab_group.iterated_count_cov();
-        if (ab_group.num_fragments())
-            cov /= ab_group.num_fragments();
-        
-        double total_length = 0.0;
-        for (unsigned i = 0; i < ab_group.abundances().size(); ++ i) 
-        {
-            total_length += ab_group.abundances()[i]->effective_length();
-        }
-        
-//        if (total_length)
+    //fprintf(stderr, "\nTesting in %s (%d total tests)\n", locus_tag.c_str(), total_tests);
+    
+	// Add all the transcripts, CDS groups, TSS groups, and genes to their
+    // respective FPKM tracking table.  Whether this is a time series or an
+    // all pairs comparison, we should be calculating and reporting FPKMs for 
+    // all objects in all samples
+    
+//    ///////////////////////////////////////////////
+//    shared_ptr<MassDispersionModel const> disperser = sample_factory.mass_dispersion_model();
+//    pair<double, double> locus_mv = disperser->get_raw_mean_and_var(locus_tag);
+//    if (locus_mv.first != 0 && locus_mv.second != 0)
+//    {
+//        LocusVarianceInfo info;
+//        info.factory_id = factory_id;
+//        info.count_mean = locus_mv.first;
+//        info.count_empir_var = locus_mv.second;
+//        info.locus_count_fitted_var = disperser->scale_mass_variance(info.count_mean);
+//        
+//        double total_iso_scaled_var = 0.0;
+//        
+//        const AbundanceGroup& ab_group = abundance->transcripts;
+//        info.locus_total_frags = ab_group.total_frags();
+//        info.locus_salient_frags = ab_group.salient_frags();
+//        //double group_counts = ab_group.total_frags();
+//        ublas::matrix<double> cov = ab_group.iterated_count_cov();
+//        if (ab_group.num_fragments())
+//            cov /= ab_group.num_fragments();
+//        
+//        double total_length = 0.0;
+//        for (unsigned i = 0; i < ab_group.abundances().size(); ++ i) 
 //        {
-//            for (unsigned i = 0; i < ab_group.abundances().size(); ++ i) 
-//            {
-//                fprintf(stderr, 
-//                        "%lg, %lg, %lg\n", 
-//                        _abundances[i]->gamma(), 
-//                        _abundances[i]->effective_length()/total_length, 
-//                        log2(_abundances[i]->gamma()/(_abundances[i]->effective_length()/total_length)));
-//            }
+//            total_length += ab_group.abundances()[i]->effective_length();
 //        }
-        
-		for (size_t i = 0; i < ab_group.abundances().size(); ++i)
-		{
-            
-//            double count_var = cov(i,i);
-//            double max_count_covar = 0.0;
-//            size_t max_covar_idx = 0.0;
-//            for (size_t j = 0; j < cov.size1(); ++j)
-//            {
-//                if (j != i && abs(cov(i,j)) > max_count_covar)
-//                {
-//                    max_count_covar = abs(cov(i,j));
-//                    max_covar_idx = j;
-//                }
-//            }
-            double count_sharing = 0.0;
-//            if (cov(i,i) != 0 && cov(max_covar_idx,max_covar_idx) != 0)
-//                count_sharing = -1.0 * cov(i,max_covar_idx) / sqrt(cov(i,i) * cov(max_covar_idx,max_covar_idx));
-            
-            
-            if (total_length)
-                count_sharing = log2(ab_group.abundances()[i]->gamma()/(ab_group.abundances()[i]->effective_length()/total_length));
-            
-            shared_ptr<Abundance> ab = ab_group.abundances()[i];
-            double scaled_var = disperser->scale_mass_variance(ab->num_fragments());
-			total_iso_scaled_var += scaled_var;
-            info.gamma.push_back(ab->gamma());
-            info.gamma_var.push_back(ab_group.gamma_cov()(i,i));
-            info.gamma_bootstrap_var.push_back(ab_group.gamma_bootstrap_cov()(i,i));
-            info.count_sharing.push_back(count_sharing);
-            info.transcript_ids.push_back(ab->description());
-		}
-
-        const ublas::matrix<double>& bs_gamma_cov = ab_group.gamma_bootstrap_cov();
-        const ublas::matrix<double>& gamma_cov = ab_group.gamma_cov();
-        info.bayes_gamma_trace = 0;
-        info.empir_gamma_trace = 0;
-        for (size_t i = 0; i < ab_group.abundances().size(); ++i)
-        {
-            //for (size_t j = 0; j < ab_group.abundances().size(); ++j)
-            {
-                info.bayes_gamma_trace += gamma_cov(i,i);
-                info.empir_gamma_trace += bs_gamma_cov(i,i);
-            }
-        }
-
-        
-        info.cross_replicate_js = 30;
-        //assert (abundance->cluster_mass == locus_mv.first);
-        //assert (total_iso_scaled_var >= info.mean_count);
-        
-        info.isoform_fitted_var_sum = total_iso_scaled_var;
-        info.num_transcripts = ab_group.abundances().size();
+//        
+////        if (total_length)
+////        {
+////            for (unsigned i = 0; i < ab_group.abundances().size(); ++ i) 
+////            {
+////                fprintf(stderr, 
+////                        "%lg, %lg, %lg\n", 
+////                        _abundances[i]->gamma(), 
+////                        _abundances[i]->effective_length()/total_length, 
+////                        log2(_abundances[i]->gamma()/(_abundances[i]->effective_length()/total_length)));
+////            }
+////        }
+//        
+//		for (size_t i = 0; i < ab_group.abundances().size(); ++i)
+//		{
+//            
+////            double count_var = cov(i,i);
+////            double max_count_covar = 0.0;
+////            size_t max_covar_idx = 0.0;
+////            for (size_t j = 0; j < cov.size1(); ++j)
+////            {
+////                if (j != i && abs(cov(i,j)) > max_count_covar)
+////                {
+////                    max_count_covar = abs(cov(i,j));
+////                    max_covar_idx = j;
+////                }
+////            }
+//            double count_sharing = 0.0;
+////            if (cov(i,i) != 0 && cov(max_covar_idx,max_covar_idx) != 0)
+////                count_sharing = -1.0 * cov(i,max_covar_idx) / sqrt(cov(i,i) * cov(max_covar_idx,max_covar_idx));
+//            
+//            
+//            if (total_length)
+//                count_sharing = log2(ab_group.abundances()[i]->gamma()/(ab_group.abundances()[i]->effective_length()/total_length));
+//            
+//            shared_ptr<Abundance> ab = ab_group.abundances()[i];
+//            double scaled_var = disperser->scale_mass_variance(ab->num_fragments());
+//			total_iso_scaled_var += scaled_var;
+//            info.gamma.push_back(ab->gamma());
+//            info.gamma_var.push_back(ab_group.gamma_cov()(i,i));
+//            info.count_sharing.push_back(count_sharing);
+//            info.transcript_ids.push_back(ab->description());
+//		}
+//
+//        
+//        const ublas::matrix<double>& gamma_cov = ab_group.gamma_cov();
 //        info.bayes_gamma_trace = 0;
 //        info.empir_gamma_trace = 0;
-        locus_variance_info_table.push_back(info);
-    }
+//        for (size_t i = 0; i < ab_group.abundances().size(); ++i)
+//        {
+//            //for (size_t j = 0; j < ab_group.abundances().size(); ++j)
+//            {
+//                info.bayes_gamma_trace += gamma_cov(i,i);
+//            }
+//        }
+//
+//        
+//        info.cross_replicate_js = 30;
+//        //assert (abundance->cluster_mass == locus_mv.first);
+//        //assert (total_iso_scaled_var >= info.count_mean);
+//        
+//        info.isoform_fitted_var_sum = total_iso_scaled_var;
+//        info.num_transcripts = ab_group.abundances().size();
+////        info.bayes_gamma_trace = 0;
+////        info.empir_gamma_trace = 0;
+//        locus_variance_info_table.push_back(info);
+//    }
     
 #if ENABLE_THREADS
     variance_info_lock.unlock();
@@ -1464,12 +1369,12 @@ void dump_locus_variance_info(const string& filename)
     FILE* fdump = fopen(filename.c_str(), "w");
     
     fprintf(fdump, 
-            "condition\tdescription\tlocus_counts\tempir_var\tlocus_fit_var\tsum_iso_fit_var\tcross_replicate_js\tnum_transcripts\tbayes_gamma_trace\tempir_gamma_trace\tcount_mean\tgamma_var\tgamma_bootstrap_var\tlocus_salient_frags\tlocus_total_frags\tcount_sharing\n");
+            "condition\tdescription\tlocus_counts\tempir_var\tlocus_fit_var\tsum_iso_fit_var\tcross_replicate_js\tnum_transcripts\tbayes_gamma_trace\tempir_gamma_trace\tcount_mean\tgamma_var\tlocus_salient_frags\tlocus_total_frags\tcount_sharing\n");
     foreach (LocusVarianceInfo& L, locus_variance_info_table)
     {
         for (size_t i = 0; i < L.gamma.size(); ++i)
         {
-            fprintf(fdump, "%d\t%s\t%lg\t%lg\t%lg\t%lg\t%lg\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n", L.factory_id, L.transcript_ids[i].c_str(), L.mean_count, L.count_empir_var, L.locus_count_fitted_var, L.isoform_fitted_var_sum, L.cross_replicate_js, L.num_transcripts, L.bayes_gamma_trace, L.empir_gamma_trace,L.gamma[i],L.gamma_var[i],L.gamma_bootstrap_var[i], L.locus_salient_frags, L.locus_total_frags, L.count_sharing[i]);
+            fprintf(fdump, "%d\t%s\t%lg\t%lg\t%lg\t%lg\t%lg\t%d\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\t%lg\n", L.factory_id, L.transcript_ids[i].c_str(), L.count_mean, L.count_empir_var, L.locus_count_fitted_var, L.isoform_fitted_var_sum, L.cross_replicate_js, L.num_transcripts, L.bayes_gamma_trace, L.empir_gamma_trace,L.gamma[i],L.gamma_var[i], L.locus_salient_frags, L.locus_total_frags, L.count_sharing[i]);
         }
         
     }
@@ -1479,6 +1384,91 @@ void dump_locus_variance_info(const string& filename)
 #endif
 }
 
+void filter_group_for_js_testing(vector<vector<AbundanceGroup> >& source_groups)
+{
+    if (source_groups.empty())
+        return;
+    
+    // iterate over transcript groups
+    for (size_t ab_group_idx = 0; ab_group_idx < source_groups[0].size(); ++ab_group_idx)
+    {
+        vector<bool> to_keep(source_groups[0][ab_group_idx].abundances().size(), false);
+        // iterate over samples
+        for (size_t sample_idx = 0;  sample_idx < source_groups.size(); ++sample_idx)
+        {
+            // iterate over each member of the current abundance group
+            AbundanceGroup& ab_group = source_groups[sample_idx][ab_group_idx];
+            for (size_t ab_idx = 0; ab_idx < ab_group.abundances().size(); ++ab_idx)
+            {
+                const Abundance& ab = *(ab_group.abundances()[ab_idx]);
+                if (ab.num_fragments() && ab.effective_length())
+                {
+                    double frags_per_kb = ab.num_fragments() / (ab.effective_length() / 1000.0);
+                    if (frags_per_kb >= min_read_count)
+                        to_keep[ab_idx] = true;
+                }
+            }
+        }
+        
+        // Now that we know which ones we want to keep, get rid of the rest
+        for (size_t sample_idx = 0;  sample_idx < source_groups.size(); ++sample_idx)
+        {
+            AbundanceGroup& ab_group = source_groups[sample_idx][ab_group_idx];
+            AbundanceGroup f = ab_group;
+            ab_group.filter_group(to_keep, f);
+            ab_group = f;
+        }
+    }
+}
+
+bool group_has_record_above_thresh(const AbundanceGroup& ab_group)
+{
+    for (size_t ab_idx = 0; ab_idx < ab_group.abundances().size(); ++ab_idx)
+    {
+        const Abundance& ab = *(ab_group.abundances()[ab_idx]);
+        if (ab.num_fragments() && ab.effective_length())
+        {
+            double frags_per_kb = ab.num_fragments() / (ab.effective_length() / 1000.0);
+            if (frags_per_kb >= min_read_count)
+                return true;
+        }
+    }
+    return false;
+}
+
+bool is_badly_fit(const Abundance& ab)
+{
+    double pooled_fpkm = ab.FPKM();
+    double pooled_fpkm_var = ab.FPKM_variance();
+    if (pooled_fpkm == 0 || pooled_fpkm_var <= 0)
+        return false;
+    normal norm(pooled_fpkm, sqrt(pooled_fpkm_var));
+    FPKMPerReplicateTable fpkm_by_rep = ab.FPKM_by_replicate();
+    for (FPKMPerReplicateTable::const_iterator f_itr = fpkm_by_rep.begin();
+         f_itr != fpkm_by_rep.end(); ++f_itr)
+    {
+        double rep_fpkm = f_itr->second;
+        double p_value = cdf(norm, rep_fpkm);
+        if (p_value < min_outlier_p)
+            return true;
+    }
+    return false;
+}
+
+bool group_has_record_badly_fit(const AbundanceGroup& ab_group)
+{
+    for (size_t ab_idx = 0; ab_idx < ab_group.abundances().size(); ++ab_idx)
+    {
+        const Abundance& ab = *(ab_group.abundances()[ab_idx]);
+        if (ab.num_fragments() && ab.effective_length())
+        {
+            if (is_badly_fit(ab))
+                return true;
+        }
+    }
+    return false;
+}
+
 int total_tests = 0;
 void test_differential(const string& locus_tag,
 					   const vector<shared_ptr<SampleAbundances> >& samples,
@@ -1489,41 +1479,30 @@ void test_differential(const string& locus_tag,
 	if (samples.empty())
 		return;
     
-#if ENABLE_THREADS
-	test_storage_lock.lock();
-    total_tests++;
-#endif
+    if (no_differential == true)
+    {
+//#if ENABLE_THREADS
+//        test_storage_lock.unlock();
+//#endif
+        return;
+    }
+	
+    vector<vector<AbundanceGroup> > filtered_primary_trans_groups;
+    vector<vector<AbundanceGroup> > filtered_promoter_groups;
+    vector<vector<AbundanceGroup> > filtered_cds_groups;
+
+    for (size_t i = 0; i < samples.size(); ++i)
+    {
+        filtered_primary_trans_groups.push_back(samples[i]->primary_transcripts);
+        filtered_promoter_groups.push_back(samples[i]->gene_primary_transcripts);
+        filtered_cds_groups.push_back(samples[i]->gene_cds);
+    }
+    
+    filter_group_for_js_testing(filtered_primary_trans_groups);
+    filter_group_for_js_testing(filtered_promoter_groups);
+    filter_group_for_js_testing(filtered_cds_groups);
     
-    //fprintf(stderr, "\nTesting in %s (%d total tests)\n", locus_tag.c_str(), total_tests);
     
-	// Add all the transcripts, CDS groups, TSS groups, and genes to their
-    // respective FPKM tracking table.  Whether this is a time series or an
-    // all pairs comparison, we should be calculating and reporting FPKMs for 
-    // all objects in all samples
-	for (size_t i = 0; i < samples.size(); ++i)
-	{
-		const AbundanceGroup& ab_group = samples[i]->transcripts;
-		foreach (shared_ptr<Abundance> ab, ab_group.abundances())
-		{
-			add_to_tracking_table(i, *ab, tracking.isoform_fpkm_tracking);
-		}
-		
-		foreach (AbundanceGroup& ab, samples[i]->cds)
-		{
-			add_to_tracking_table(i, ab, tracking.cds_fpkm_tracking);
-		}
-		
-		foreach (AbundanceGroup& ab, samples[i]->primary_transcripts)
-		{
-			add_to_tracking_table(i, ab, tracking.tss_group_fpkm_tracking);
-		}
-		
-		foreach (AbundanceGroup& ab, samples[i]->genes)
-		{
-			add_to_tracking_table(i, ab, tracking.gene_fpkm_tracking);
-		}
-	}
-	
     // Perform pairwise significance testing between samples. If this is a
     // time series, only test between successive pairs of samples, as supplied 
     // by the user.
@@ -1562,13 +1541,25 @@ void test_differential(const string& locus_tag,
                     if (frags_per_kb >= min_read_count)
                         enough_reads = true;
                 }
+                
+                if (enough_reads)
+                {
+                    if (is_badly_fit(curr_abundance) || is_badly_fit(prev_abundance))
+                        enough_reads = false;
+                }
 
-                pair<int, SampleDiffs::iterator> result;
-                result = get_de_tests(desc,
+                SampleDifference test;
+                test = get_de_tests(desc,
                                       itr->second.fpkm_series[j], 
                                       itr->second.fpkm_series[i],
-                                      tests.isoform_de_tests[i][j],
+                                      //tests.isoform_de_tests[i][j],
                                       enough_reads);
+#if ENABLE_THREADS
+                test_storage_lock.lock();
+#endif
+                pair<SampleDiffs::iterator, bool> inserted; 
+                inserted = tests.isoform_de_tests[i][j].insert(make_pair(desc,
+                                                                     test)); 
                 
                 shared_ptr<SampleDifferenceMetaData> meta_data = get_metadata(desc);
                 
@@ -1577,13 +1568,16 @@ void test_differential(const string& locus_tag,
                 meta_data->protein_ids = curr_abundance.protein_id();
                 meta_data->locus_desc = curr_abundance.locus_tag();
                 meta_data->description = curr_abundance.description();
-                result.second->second.meta_data = meta_data;
+                inserted.first->second.meta_data = meta_data;
+#if ENABLE_THREADS
+                test_storage_lock.unlock();
+#endif
             }
             
             for (size_t k = 0; k < samples[i]->cds.size(); ++k)
             {
-                const Abundance& curr_abundance = samples[j]->cds[k];
-                const Abundance& prev_abundance = samples[i]->cds[k];
+                const Abundance& curr_abundance = samples[i]->cds[k];
+                const Abundance& prev_abundance = samples[j]->cds[k];
                 
                 const string& desc = curr_abundance.description();
                 FPKMTrackingTable::iterator itr = tracking.cds_fpkm_tracking.find(desc);
@@ -1603,12 +1597,26 @@ void test_differential(const string& locus_tag,
                         enough_reads = true;
                 }
                 
-                pair<int, SampleDiffs::iterator> result;
-                result = get_de_tests(desc,
-                             itr->second.fpkm_series[j], 
-                             itr->second.fpkm_series[i],
-                             tests.cds_de_tests[i][j],
-                             enough_reads);
+                if (enough_reads)
+                {
+                    if (is_badly_fit(curr_abundance) || is_badly_fit(prev_abundance))
+                        enough_reads = false;
+                }
+
+                
+                SampleDifference test;
+                test = get_de_tests(desc,
+                                    itr->second.fpkm_series[j], 
+                                    itr->second.fpkm_series[i],
+                                    //tests.cds_de_tests[i][j],
+                                    enough_reads);
+#if ENABLE_THREADS
+                test_storage_lock.lock();
+#endif
+                
+                pair<SampleDiffs::iterator, bool> inserted; 
+                inserted = tests.cds_de_tests[i][j].insert(make_pair(desc,
+                                                                           test)); 
                 
                 shared_ptr<SampleDifferenceMetaData> meta_data = get_metadata(desc);
                 
@@ -1617,13 +1625,16 @@ void test_differential(const string& locus_tag,
                 meta_data->protein_ids = curr_abundance.protein_id();
                 meta_data->locus_desc = curr_abundance.locus_tag();
                 meta_data->description = curr_abundance.description();
-                result.second->second.meta_data = meta_data;
+                inserted.first->second.meta_data = meta_data;
+#if ENABLE_THREADS
+                test_storage_lock.unlock();
+#endif
             }
             
             for (size_t k = 0; k < samples[i]->primary_transcripts.size(); ++k)
             {
-                const Abundance& curr_abundance = samples[j]->primary_transcripts[k];
-                const Abundance& prev_abundance = samples[i]->primary_transcripts[k];
+                const Abundance& curr_abundance = samples[i]->primary_transcripts[k];
+                const Abundance& prev_abundance = samples[j]->primary_transcripts[k];
                 
                 const string& desc = curr_abundance.description();
                 FPKMTrackingTable::iterator itr = tracking.tss_group_fpkm_tracking.find(desc);
@@ -1643,12 +1654,26 @@ void test_differential(const string& locus_tag,
                         enough_reads = true;
                 }
                 
-                pair<int, SampleDiffs::iterator> result;
-                result = get_de_tests(desc,
+                if (enough_reads)
+                {
+                    if (is_badly_fit(curr_abundance) || is_badly_fit(prev_abundance))
+                        enough_reads = false;
+                }
+
+                
+                SampleDifference test;
+                test = get_de_tests(desc,
                              itr->second.fpkm_series[j], 
                              itr->second.fpkm_series[i],
-                             tests.tss_group_de_tests[i][j],
+                             //tests.tss_group_de_tests[i][j],
                              enough_reads);
+#if ENABLE_THREADS
+                test_storage_lock.lock();
+#endif
+                pair<SampleDiffs::iterator, bool> inserted; 
+                inserted = tests.tss_group_de_tests[i][j].insert(make_pair(desc,
+                                                                      test)); 
+                
                 
                 shared_ptr<SampleDifferenceMetaData> meta_data = get_metadata(desc);
                 
@@ -1657,13 +1682,16 @@ void test_differential(const string& locus_tag,
                 meta_data->protein_ids = curr_abundance.protein_id();
                 meta_data->locus_desc = curr_abundance.locus_tag();
                 meta_data->description = curr_abundance.description();
-                result.second->second.meta_data = meta_data;
+                inserted.first->second.meta_data = meta_data;
+#if ENABLE_THREADS
+                test_storage_lock.unlock();
+#endif
             }
             
             for (size_t k = 0; k < samples[i]->genes.size(); ++k)
             {
-                const Abundance& curr_abundance = samples[j]->genes[k];
-                const Abundance& prev_abundance = samples[i]->genes[k];
+                const AbundanceGroup& curr_abundance = samples[i]->genes[k];
+                const AbundanceGroup& prev_abundance = samples[j]->genes[k];
                 const string& desc = curr_abundance.description();
                 FPKMTrackingTable::iterator itr = tracking.gene_fpkm_tracking.find(desc);
                 assert (itr != tracking.gene_fpkm_tracking.end());
@@ -1682,12 +1710,18 @@ void test_differential(const string& locus_tag,
                         enough_reads = true;
                 }
                     
-                pair<int, SampleDiffs::iterator> result;
-                result = get_de_tests(desc,
+                SampleDifference test;
+                test = get_de_tests(desc,
                              itr->second.fpkm_series[j], 
                              itr->second.fpkm_series[i],
-                             tests.gene_de_tests[i][j],
+                             //tests.gene_de_tests[i][j],
                              enough_reads);
+#if ENABLE_THREADS
+                test_storage_lock.lock();
+#endif
+                pair<SampleDiffs::iterator, bool> inserted; 
+                inserted = tests.gene_de_tests[i][j].insert(make_pair(desc,
+                                                                      test)); 
                 
                 shared_ptr<SampleDifferenceMetaData> meta_data = get_metadata(desc);
                 
@@ -1696,7 +1730,10 @@ void test_differential(const string& locus_tag,
                 meta_data->protein_ids = curr_abundance.protein_id();
                 meta_data->locus_desc = curr_abundance.locus_tag();
                 meta_data->description = curr_abundance.description();
-                result.second->second.meta_data = meta_data;
+                inserted.first->second.meta_data = meta_data;
+#if ENABLE_THREADS
+                test_storage_lock.unlock();
+#endif
             }
             
             // FIXME: the code below will not properly test for differential
@@ -1707,85 +1744,130 @@ void test_differential(const string& locus_tag,
             // Differential promoter use
             for (size_t k = 0; k < samples[i]->gene_primary_transcripts.size(); ++k)
             {
-                const Abundance& curr_abundance = samples[j]->gene_primary_transcripts[k];
-                const Abundance& prev_abundance = samples[j]->gene_primary_transcripts[k];
+                const AbundanceGroup& curr_abundance = filtered_promoter_groups[i][k];
+                const AbundanceGroup& prev_abundance = filtered_promoter_groups[j][k];
+                const string& desc = curr_abundance.description();
                 
-                bool enough_reads = false;
-                if (curr_abundance.num_fragments() && curr_abundance.effective_length())
-                {
-                    double frags_per_kb = curr_abundance.num_fragments() / (curr_abundance.effective_length() / 1000.0);
-                    if (frags_per_kb >= min_read_count)
-                        enough_reads = true;
-                }
-                if (prev_abundance.num_fragments() && prev_abundance.effective_length())
-                {
-                    double frags_per_kb = prev_abundance.num_fragments() / (prev_abundance.effective_length() / 1000.0);
-                    if (frags_per_kb >= min_read_count)
-                        enough_reads = true;
-                }
+                bool enough_reads = (group_has_record_above_thresh(curr_abundance) &&
+                                     group_has_record_above_thresh(prev_abundance) &&
+                                     group_has_record_badly_fit(curr_abundance) == false &&
+                                     group_has_record_badly_fit(prev_abundance) == false &&
+                                     curr_abundance.FPKM_by_replicate().size() >= min_reps_for_js_test && 
+                                     prev_abundance.FPKM_by_replicate().size() >= min_reps_for_js_test);
+                SampleDifference test;
+                test = get_ds_tests(prev_abundance, 
+                                    curr_abundance,
+                                    enough_reads);
                 
-                get_ds_tests(samples[j]->gene_primary_transcripts[k], 
-                             samples[i]->gene_primary_transcripts[k],
-                             tests.diff_promoter_tests[i][j],
-                             enough_reads);
+                // The filtered group might be empty, so let's grab metadata from
+                // the unfiltered group
+                shared_ptr<SampleDifferenceMetaData> meta_data = get_metadata(desc);
+                
+                meta_data->gene_ids = samples[i]->gene_primary_transcripts[k].gene_id();
+                meta_data->gene_names = samples[i]->gene_primary_transcripts[k].gene_name();
+                meta_data->protein_ids = samples[i]->gene_primary_transcripts[k].protein_id();
+                meta_data->locus_desc = samples[i]->gene_primary_transcripts[k].locus_tag();
+                meta_data->description = samples[i]->gene_primary_transcripts[k].description();
+                
+                test.meta_data = meta_data;
+                
+#if ENABLE_THREADS
+                test_storage_lock.lock();
+#endif
+                
+                pair<SampleDiffs::iterator, bool> inserted;
+                inserted = tests.diff_promoter_tests[i][j].insert(make_pair(desc,test)); 
+                inserted.first->second = test;
+                
+#if ENABLE_THREADS
+                test_storage_lock.unlock();
+#endif
             }
             
             // Differential coding sequence output
             for (size_t k = 0; k < samples[i]->gene_cds.size(); ++k)
             {
-                const Abundance& curr_abundance = samples[j]->gene_cds[k];
-                const Abundance& prev_abundance = samples[j]->gene_cds[k];
+                const AbundanceGroup& curr_abundance = filtered_cds_groups[i][k];
+                const AbundanceGroup& prev_abundance = filtered_cds_groups[j][k];
+                const string& desc = curr_abundance.description();
                 
-                bool enough_reads = false;
-                if (curr_abundance.num_fragments() && curr_abundance.effective_length())
-                {
-                    double frags_per_kb = curr_abundance.num_fragments() / (curr_abundance.effective_length() / 1000.0);
-                    if (frags_per_kb >= min_read_count)
-                        enough_reads = true;
-                }
-                if (prev_abundance.num_fragments() && prev_abundance.effective_length())
-                {
-                    double frags_per_kb = prev_abundance.num_fragments() / (prev_abundance.effective_length() / 1000.0);
-                    if (frags_per_kb >= min_read_count)
-                        enough_reads = true;
-                }
+                bool enough_reads = (group_has_record_above_thresh(curr_abundance) &&
+                                     group_has_record_above_thresh(prev_abundance) &&
+                                     group_has_record_badly_fit(curr_abundance) == false &&
+                                     group_has_record_badly_fit(prev_abundance) == false &&
+                                     curr_abundance.FPKM_by_replicate().size() >= min_reps_for_js_test && 
+                                     prev_abundance.FPKM_by_replicate().size() >= min_reps_for_js_test);                
+                SampleDifference test;
+                test = get_ds_tests(prev_abundance, 
+                                    curr_abundance,
+                                    enough_reads);
                 
-                get_ds_tests(samples[j]->gene_cds[k], 
-                             samples[i]->gene_cds[k],
-                             tests.diff_cds_tests[i][j],
-                             enough_reads);
+                // The filtered group might be empty, so let's grab metadata from
+                // the unfiltered group
+                shared_ptr<SampleDifferenceMetaData> meta_data = get_metadata(desc);
+                
+                meta_data->gene_ids = samples[i]->gene_cds[k].gene_id();
+                meta_data->gene_names = samples[i]->gene_cds[k].gene_name();
+                meta_data->protein_ids = samples[i]->gene_cds[k].protein_id();
+                meta_data->locus_desc = samples[i]->gene_cds[k].locus_tag();
+                meta_data->description = samples[i]->gene_cds[k].description();
+                
+                test.meta_data = meta_data;
+                
+#if ENABLE_THREADS
+                test_storage_lock.lock();
+#endif
+                pair<SampleDiffs::iterator, bool> inserted;
+                inserted = tests.diff_cds_tests[i][j].insert(make_pair(desc,test)); 
+                inserted.first->second = test;
+                
+#if ENABLE_THREADS
+                test_storage_lock.unlock();
+#endif
             }
             
             // Differential splicing of primary transcripts
             for (size_t k = 0; k < samples[i]->primary_transcripts.size(); ++k)
             {
+                const AbundanceGroup& curr_abundance = filtered_primary_trans_groups[i][k];
+                const AbundanceGroup& prev_abundance = filtered_primary_trans_groups[j][k];
+                const string& desc = curr_abundance.description();
                 
-                const Abundance& curr_abundance = samples[j]->primary_transcripts[k];
-                const Abundance& prev_abundance = samples[j]->primary_transcripts[k];
+                bool enough_reads = (group_has_record_above_thresh(curr_abundance) &&
+                                     group_has_record_above_thresh(prev_abundance) &&
+                                     group_has_record_badly_fit(curr_abundance) == false &&
+                                     group_has_record_badly_fit(prev_abundance) == false &&
+                                     curr_abundance.FPKM_by_replicate().size() >= min_reps_for_js_test && 
+                                     prev_abundance.FPKM_by_replicate().size() >= min_reps_for_js_test);
                 
-                bool enough_reads = false;
-                if (curr_abundance.num_fragments() && curr_abundance.effective_length())
-                {
-                    double frags_per_kb = curr_abundance.num_fragments() / (curr_abundance.effective_length() / 1000.0);
-                    if (frags_per_kb >= min_read_count)
-                        enough_reads = true;
-                }
-                if (prev_abundance.num_fragments() && prev_abundance.effective_length())
-                {
-                    double frags_per_kb = prev_abundance.num_fragments() / (prev_abundance.effective_length() / 1000.0);
-                    if (frags_per_kb >= min_read_count)
-                        enough_reads = true;
-                }
+                SampleDifference test;
+                test = get_ds_tests(prev_abundance, 
+                                    curr_abundance,
+                                    enough_reads);
                 
-                get_ds_tests(samples[j]->primary_transcripts[k], 
-                             samples[i]->primary_transcripts[k],
-                             tests.diff_splicing_tests[i][j],
-                             enough_reads);
+                // The filtered group might be empty, so let's grab metadata from
+                // the unfiltered group
+                shared_ptr<SampleDifferenceMetaData> meta_data = get_metadata(desc);
+                
+                meta_data->gene_ids = samples[i]->primary_transcripts[k].gene_id();
+                meta_data->gene_names = samples[i]->primary_transcripts[k].gene_name();
+                meta_data->protein_ids = samples[i]->primary_transcripts[k].protein_id();
+                meta_data->locus_desc = samples[i]->primary_transcripts[k].locus_tag();
+                meta_data->description = samples[i]->primary_transcripts[k].description();
+                
+                test.meta_data = meta_data;
+                
+#if ENABLE_THREADS
+                test_storage_lock.lock();
+#endif
+                pair<SampleDiffs::iterator, bool> inserted;
+                inserted = tests.diff_splicing_tests[i][j].insert(make_pair(desc,test)); 
+                inserted.first->second = test;
+                
+#if ENABLE_THREADS
+                test_storage_lock.unlock();
+#endif
             }
         }
 	}
-	
-#if ENABLE_THREADS
-	test_storage_lock.unlock();
-#endif
 }
diff --git a/src/differential.h b/src/differential.h
index 9b2b246..872f287 100644
--- a/src/differential.h
+++ b/src/differential.h
@@ -99,6 +99,19 @@ struct Outfiles
 	FILE* tss_group_fpkm_tracking_out;
 	FILE* gene_fpkm_tracking_out;
 	FILE* cds_fpkm_tracking_out;
+    
+    FILE* isoform_count_tracking_out;
+	FILE* tss_group_count_tracking_out;
+	FILE* gene_count_tracking_out;
+	FILE* cds_count_tracking_out;
+    
+    FILE* isoform_rep_tracking_out;
+	FILE* tss_group_rep_tracking_out;
+	FILE* gene_rep_tracking_out;
+	FILE* cds_rep_tracking_out;
+    
+    FILE* run_info_out;
+    FILE* read_group_info_out;
 };
 
 struct Tests
@@ -115,9 +128,15 @@ struct Tests
 
 struct FPKMContext
 {
-	FPKMContext(double c, double r, double v, AbundanceStatus s)
-		: counts(c), FPKM(r), FPKM_variance(v), status(s) {}
-	double counts;
+	FPKMContext(double cm, double cv, double cuv, double cdv, const CountPerReplicateTable& cpr, double r, const FPKMPerReplicateTable& fpr, double v, AbundanceStatus s, const StatusPerReplicateTable& spr)
+		: count_mean(cm), count_var(cv), count_uncertainty_var(cuv), count_dispersion_var(cdv), count_per_rep(cpr), fpkm_per_rep(fpr), FPKM(r), FPKM_variance(v), status(s), status_per_rep(spr) {}
+	double count_mean;
+    double count_var;
+    double count_uncertainty_var;
+    double count_dispersion_var;
+    CountPerReplicateTable count_per_rep;
+    FPKMPerReplicateTable fpkm_per_rep;
+    StatusPerReplicateTable status_per_rep;
 	double FPKM;
 	double FPKM_variance;
     AbundanceStatus status;
@@ -148,6 +167,14 @@ struct Tracking
 	FPKMTrackingTable tss_group_fpkm_tracking;
 	FPKMTrackingTable gene_fpkm_tracking;
 	FPKMTrackingTable cds_fpkm_tracking;
+    
+    void clear() 
+    {
+        isoform_fpkm_tracking.clear();
+        tss_group_fpkm_tracking.clear();
+        gene_fpkm_tracking.clear();
+        cds_fpkm_tracking.clear();
+    }
 };
 
 struct SampleAbundances
@@ -194,9 +221,12 @@ public:
                          size_t factory_id);
     void test_finished_loci();
     void perform_testing(vector<shared_ptr<SampleAbundances> >& abundances);
+    void record_tracking_data(vector<shared_ptr<SampleAbundances> >& abundances);
     bool all_samples_reported_in(vector<shared_ptr<SampleAbundances> >& abundances);
     bool all_samples_reported_in(const string& locus_id);
     
+    void clear_tracking_data() { _tracking->clear(); }
+    
     typedef list<pair<string, vector<shared_ptr<SampleAbundances> > > > launcher_sample_table;
     
 private:
@@ -213,6 +243,7 @@ private:
 };
 
 extern double min_read_count;
+extern double min_outlier_p;
 
 void sample_worker(const RefSequenceTable& rt,
                    ReplicatedBundleFactory& sample_factory,
diff --git a/src/filters.cpp b/src/filters.cpp
index 0a10b50..89c1e12 100644
--- a/src/filters.cpp
+++ b/src/filters.cpp
@@ -163,31 +163,31 @@ void pre_mrna_filter(int bundle_length,
 	vector<Scaffold> filtered_hits;
 	vector<bool> toss(hits.size(), false);
 	vector<float> through_introns; //for each location, how many introns pass through
-
+    
 	vector<int> scaff_intron_status;
 	// Make sure the avg only uses stuff we're sure isn't pre-mrna fragments
-  double bundle_avg_doc = compute_doc(bundle_left,
+    double bundle_avg_doc = compute_doc(bundle_left,
 										hits, 
 										depth_of_coverage, 
 										intron_doc,
 										true,
 										&through_introns,
 										&scaff_intron_status);
-   verbose_msg("Pre-mRNA flt: bundle average doc = %lf\n", bundle_avg_doc);
-  /*
-   //2nd call not needed, the vectors won't change, only the return value
-	compute_doc(bundle_left, 
-                hits, 
-                depth_of_coverage, 
-                intron_doc,
-                false);
-  */
+    verbose_msg("Pre-mRNA flt: bundle average doc = %lf\n", bundle_avg_doc);
+    /*
+     //2nd call not needed, the vectors won't change, only the return value
+     compute_doc(bundle_left, 
+     hits, 
+     depth_of_coverage, 
+     intron_doc,
+     false);
+     */
 	record_doc_for_scaffolds(bundle_left, 
 							 hits, 
 							 depth_of_coverage, 
 							 intron_doc,
 							 scaff_doc);
-
+    
 	for(map<pair<int, int>, float >::const_iterator itr = intron_doc.begin();
 		itr != intron_doc.end(); 
 		++itr)
@@ -195,38 +195,37 @@ void pre_mrna_filter(int bundle_length,
 		int i_left = itr->first.first;
 		int i_right = itr->first.second;
 		int i_doc   = itr->second;
-    double intron_background = background_rate(depth_of_coverage,
-                                               i_left - bundle_left,
-                                               i_right - bundle_left);
-    double cumul_cov = 0;
-    for (int i = 0; i < i_right - i_left; ++i)
-    {
-        size_t pos = (i_left - bundle_left) + i;
-        cumul_cov += depth_of_coverage[pos];
-    }
-    cumul_cov /= i_right - i_left;
-    verbose_msg("Pre-mRNA flt: intron %d-%d : background: %lf, inner coverage: %lf, junction coverage: %f\n",
-                 i_left, i_right, intron_background, cumul_cov, i_doc);
-    if (cumul_cov / bundle_avg_doc >= pre_mrna_fraction)
-    {
-        //fprintf(stderr, "\tskipping\n");
-        continue;
-    }
+        double intron_background = background_rate(depth_of_coverage,
+                                                   i_left - bundle_left,
+                                                   i_right - bundle_left);
+        double cumul_cov = 0;
+        for (int i = 0; i < i_right - i_left; ++i)
+        {
+            size_t pos = (i_left - bundle_left) + i;
+            cumul_cov += depth_of_coverage[pos];
+        }
+        cumul_cov /= i_right - i_left;
+        verbose_msg("Pre-mRNA flt: intron %d-%d : background: %lf, inner coverage: %lf, junction coverage: %f\n",
+                    i_left, i_right, intron_background, cumul_cov, i_doc);
+        if (cumul_cov / bundle_avg_doc >= pre_mrna_fraction)
+        {
+            //fprintf(stderr, "\tskipping\n");
+            continue;
+        }
         
-		////double thresh = (1.0/pre_mrna_fraction) * intron_background;
-		double thresh = pre_mrna_fraction * intron_background;
-    float min_flt_fraction = min(pre_mrna_fraction, min_isoform_fraction);
-    //double thresh = min_flt_fraction * i_doc;
-
-    for (size_t j = 0; j < hits.size(); ++j)
+        ////double thresh = (1.0/pre_mrna_fraction) * intron_background;
+        double thresh = pre_mrna_fraction * intron_background;
+        
+        
+        for (size_t j = 0; j < hits.size(); ++j)
         {
-           if (hits[j].left()>i_right) break;
+            if (hits[j].left()>i_right) break;
             if (hits[j].is_ref())
                 continue;
-			      if (toss[j])
-			          continue;
-			      //find maximum intron support in the hit region
-
+            if (toss[j])
+                continue;
+            //find maximum intron support in the hit region
+            
             int len = 0;
             double doc = 0.0;
             size_t curr_op = 0;
@@ -294,10 +293,10 @@ void pre_mrna_filter(int bundle_length,
                     toss[j] = true;
                     if (hits[j].has_intron())
                     {
-                    //    fprintf(stderr, "\t$$$ Filtering intron scaff [%d-%d]\n", hits[j].left(), hits[j].right());
-
-                       verbose_msg("\t@@@ Filtering intron scaff [%d-%d] (scaff_doc=%lf, doc_in_region=%lf)\n",
-                            hits[j].left(), hits[j].right(), scaff_doc[j], hit_doc_in_region);
+                        //    fprintf(stderr, "\t$$$ Filtering intron scaff [%d-%d]\n", hits[j].left(), hits[j].right());
+                        
+                        verbose_msg("\t@@@ Filtering intron scaff [%d-%d] (scaff_doc=%lf, doc_in_region=%lf)\n",
+                                    hits[j].left(), hits[j].right(), scaff_doc[j], hit_doc_in_region);
                     }
                 }
             }
@@ -310,18 +309,18 @@ void pre_mrna_filter(int bundle_length,
 			filtered_hits.push_back(hits[j]);
 		}
 		/*else
-		{
-			if (hits[j].has_intron())
-			{
-				
-                verbose_msg( "\t@@@ Filtering intron scaff [%d-%d]\n", hits[j].left(), hits[j].right());
-			}
-		}
-		*/
+         {
+         if (hits[j].has_intron())
+         {
+         
+         verbose_msg( "\t@@@ Filtering intron scaff [%d-%d]\n", hits[j].left(), hits[j].right());
+         }
+         }
+         */
 	}
     
 	if (cuff_verbose && hits.size()>filtered_hits.size())
-	  verbose_msg("\tPre-mRNA flt tossed %lu fragments\n", hits.size() - filtered_hits.size());
+        verbose_msg("\tPre-mRNA flt tossed %lu fragments\n", hits.size() - filtered_hits.size());
 	
 	hits = filtered_hits;
 }
@@ -629,20 +628,19 @@ void filter_junk_isoforms(vector<shared_ptr<Abundance> >& transcripts,
 			
             if (library_type != "transfrags")
             {
-                double low_qual_hits = 0.0;
-                static const double low_qual_err_prob = high_phred_err_prob; // hits with error_prob() above this are low quality;
-                static const double low_qual_thresh = 0.75; // hits with more than this fraction of low qual hits are repeats
+                double multi_hits = 0.0;
+                //static const double low_qual_err_prob = high_phred_err_prob; // hits with error_prob() above this are low quality;
+                //static const double low_qual_thresh = 0.75; // hits with more than this fraction of low qual hits are repeats
                 for (vector<const MateHit*>::const_iterator itr = hits.begin();
                      itr != hits.end();
                      ++itr)
                 {
-                    double e = 1-(*itr)->mass();
-                    if (e >= low_qual_err_prob)
-                        low_qual_hits += 1.0;
+                    if ((*itr)->is_multi())
+                        multi_hits += 1.0;
                 }
             
-                double low_qual_frac = low_qual_hits / (double)hits.size();
-                if (low_qual_frac > low_qual_thresh)
+                double low_qual_frac = multi_hits / (double)hits.size();
+                if (low_qual_frac > max_multiread_fraction)
                     repeats[t] = true;
             }
             if (scaff->strand() == CUFF_FWD &&
@@ -661,11 +659,6 @@ void filter_junk_isoforms(vector<shared_ptr<Abundance> >& transcripts,
                     chaff[t] = true;
             }
 		}
-//        else // we should still filter things that are zero to improve robustness of MAP estimation
-//        {
-//            if (abundances[t] == 0.0)
-//                too_rare[t] = true;
-//        }
 	}
 	
 	vector<shared_ptr<Abundance> > non_junk_transcripts;
@@ -831,7 +824,7 @@ void clip_by_3_prime_dropoff(vector<Scaffold>& scaffolds)
             {
                 tmp_mean_to_trim = 0.0;
                 tmp_mean_to_keep = 0.0;
-                for (size_t i = 0; i < exon_3->genomic_length; i++)
+                for (int i = 0; i < exon_3->genomic_length; i++)
                 {
                     if (i <= to_remove)
                     {
@@ -933,9 +926,6 @@ void clip_by_3_prime_dropoff(vector<Scaffold>& scaffolds)
                     total += hit->mass();
                 }
             }
-            double avg_cov = total/scaff_len;
-            //        if (avg_cov < trim_3_avgcov_thresh)
-            //            continue;
             
             const AugmentedCuffOp* exon_3 = NULL;
             int mult;
diff --git a/src/gdna.cpp b/src/gdna.cpp
index 6b250d0..4d8a4b0 100644
--- a/src/gdna.cpp
+++ b/src/gdna.cpp
@@ -1,17 +1,52 @@
 #include "gdna.h"
 #include <string.h>
 
-#define IUPAC_DEFS "AaCcTtGgUuMmRrWwSsYyKkVvHhDdBbNnXx-*"
-#define IUPAC_COMP "TtGgAaCcAaKkYyWwSsRrMmBbDdHhVvNnXx-*"
+const char* IUPAC_2BIT  ="AACCTTGGTTAAAAAACCCCGGAAAAAACCAAAAAA";
+const char* IUPAC_2BITN ="001133223300000011112200000011000000";
+const char* IUPAC_DEFS  ="AaCcTtGgUuMmRrWwSsYyKkVvHhDdBbNnXx-*";
+const char* IUPAC_COMP  ="TtGgAaCcAaKkYyWwSsRrMmBbDdHhVvNnXx-*";
 
-unsigned char ntCompTable[256];
+#define A_2BIT 0 // 00
+#define C_2BIT 1 // 01
+#define G_2BIT 2 // 10
+#define T_2BIT 3 // 11
+
+static byte ntCompTable[256];
+static byte nt2bit[256]; //maps any character to a 2bit base value (with N = A)
+static char v_2bit2nt[4] = {'A','C','G','T'};
+
+//----------------------
+
+static bool gdna_Ready=gDnaInit();
+
+//----------------------
+
+byte gdna2bit(char* &nt, int n) {
+// Pack n bases into a byte (n can be 1..4)
+byte out = 0;
+while (n && *nt) {
+    n--;
+    out <<= 2;
+    out += nt2bit[(int)*nt];
+    nt++;
+    }
+#ifdef GDEBUG
+if (n) {
+     GError("Error: attempt to read 6-mer beyond the end of the string!\n");
+     }
+#endif
+return out;
+}
 
-static bool gdna_ntCompTableReady=ntCompTableInit();
 
 char ntComplement(char c) {
  return ntCompTable[(int)c];
  }
 
+char g2bit2base(byte v2bit) {
+ return v_2bit2nt[v2bit & 0x03 ];
+}
+
 //in place reverse complement of nucleotide (sub)sequence
 char* reverseComplement(char* seq, int slen) {
    if (slen==0) slen=strlen(seq);
@@ -21,30 +56,32 @@ char* reverseComplement(char* seq, int slen) {
    register char c;
    while (l<r) {
       c=seq[l];seq[l]=seq[r];
-      seq[r]=c;   //this was: swap(str[l],str[r]);
+      seq[r]=c;   //this was: Gswap(str[l],str[r]);
       l++;r--;
       }
    for (int i=0;i<slen;i++) seq[i]=ntComplement(seq[i]);
    return seq;
  }
 
-bool ntCompTableInit() {
-       //if (gdna_ntCompTableReady) return true;
-       char n[]=IUPAC_DEFS;
-       char c[]=IUPAC_COMP;
+bool gDnaInit() {
+       if (gdna_Ready) return true;
        int l=strlen(IUPAC_DEFS);
        ntCompTable[0]=0;
+       nt2bit[0]=0;
        for (int ch=1;ch<256;ch++) {
           ntCompTable[ch]=0;
+          nt2bit[ch]=0;
           for (int i=0;i<l;i++)
-                if (ch==n[i]) {
-                  ntCompTable[ch]=c[i];
+                if (ch==IUPAC_DEFS[i]) {
+                  ntCompTable[ch]=IUPAC_COMP[i];
+                  nt2bit[ch] = IUPAC_2BITN[i]-'0';
                   break;
                   }
-          if (ntCompTable[ch]==0)
+          if (ntCompTable[ch]==0) {
               ntCompTable[ch]='N';
+              }
           }
-      //gdna_ntCompTableReady=true;
+      gdna_Ready=true;
       return true;
      }
 
diff --git a/src/gdna.h b/src/gdna.h
index 9a7eea9..1f923ed 100644
--- a/src/gdna.h
+++ b/src/gdna.h
@@ -7,6 +7,9 @@ char ntComplement(char c);
 //in-place reverse complement of a nucleotide (sub)sequence
 char* reverseComplement(char* seq, int slen=0);
 
-bool ntCompTableInit();
+bool gDnaInit();
+
+byte gdna2bit(char* &nt, int n=4); //pack n bases into a byte (n can be 1..4)
+char g2bit2base(byte v2bit); //convert the 2-bit value into 'A', 'C', 'G' or 'T'
 
 #endif
diff --git a/src/gff.cpp b/src/gff.cpp
index c950f89..24453b3 100644
--- a/src/gff.cpp
+++ b/src/gff.cpp
@@ -17,7 +17,7 @@ const uint gfo_flag_HAS_ERRORS       = 0x00000001;
 const uint gfo_flag_CHILDREN_PROMOTED= 0x00000002;
 const uint gfo_flag_IS_GENE          = 0x00000004;
 const uint gfo_flag_IS_TRANSCRIPT    = 0x00000008;
-const uint gfo_flag_FROM_GFF3        = 0x00000010;
+const uint gfo_flag_HAS_GFF_ID       = 0x00000010; //found GFF3 feature line with its own ID
 const uint gfo_flag_BY_EXON          = 0x00000020; //created by subfeature (exon) directly
 const uint gfo_flag_DISCARDED        = 0x00000100;
 const uint gfo_flag_LST_KEEP         = 0x00000200;
@@ -52,40 +52,57 @@ int gfo_cmpByLoc(const pointer p1, const pointer p2) {
              else return (int)(g1.gseq_id-g2.gseq_id);
 }
 
-char* GffLine::extractAttr(const char* pre, bool caseStrict, bool enforce_GTF2) {
+char* GffLine::extractAttr(const char* attr, bool caseStrict, bool enforce_GTF2) {
  //parse a key attribute and remove it from the info string
  //(only works for attributes that have values following them after ' ' or '=')
  static const char GTF2_ERR[]="Error parsing attribute %s ('\"' required) at GTF line:\n%s\n";
- int lpre=strlen(pre);
- char cend=pre[lpre-1];
- char* pos = (caseStrict) ? strstr(info, pre) : strifind(info, pre);
- if (pos==NULL) return NULL;
- char* findstart=info;
- //require word boundary on the left:
- while (pos!=NULL && pos!=info && *(pos-1)!=';' && *(pos-1)!=' ') {
-    findstart=pos+lpre;
-    pos = (caseStrict) ? strstr(findstart, pre) : strifind(findstart, pre);
-    }
- if (pos==NULL) return NULL;
- if (cend!=' ' && cend!='=') {
-    //require word boundary on the right:
-    while (pos!=NULL && *(pos+lpre)!=' ' && *(pos+lpre)!='=') {
-       findstart=pos+lpre;
-       pos = (caseStrict) ? strstr(findstart, pre) : strifind(findstart, pre);
-       }
-    }
- if (pos==NULL) return NULL;
- char* vp=pos+lpre;
+ int attrlen=strlen(attr);
+ char cend=attr[attrlen-1];
+ //char* pos = (caseStrict) ? strstr(info, attr) : strifind(info, attr);
+ //must make sure attr is not found in quoted text
+ char* pos=info;
+ char prevch=0;
+ bool in_str=false;
+ bool notfound=true;
+ int (*strcmpfn)(const char*, const char*, int) = caseStrict ? Gstrcmp : Gstricmp;
+ while (notfound && *pos) {
+   char ch=*pos;
+   if (ch=='"') {
+     in_str=!in_str;
+     pos++;
+     prevch=ch;
+     continue;
+     }
+   if (!in_str && (prevch==0 || prevch==' ' || prevch == ';')
+          && strcmpfn(attr, pos, attrlen)==0) {
+      //attr match found
+      //check for word boundary on right
+      char* epos=pos+attrlen;
+      if (cend=='=' || cend==' ' || *epos==0 || *epos==' ') {
+        notfound=false;
+        break;
+        }
+      //not a perfect match, move on
+      pos=epos;
+      prevch=*(pos-1);
+      continue;
+      }
+   //not a match or in_str
+   prevch=ch;
+   pos++;
+   }
+ if (notfound) return NULL;
+ char* vp=pos+attrlen;
  while (*vp==' ') vp++;
  if (*vp==';' || *vp==0)
-      GError("Error parsing value of GFF attribute \"%s\", line:\n%s\n", pre, dupline);
+      GError("Error parsing value of GFF attribute \"%s\", line:\n%s\n", attr, dupline);
  bool dq_enclosed=false; //value string enclosed by double quotes
  if (*vp=='"') {
      dq_enclosed=true;
      vp++;
      }
  if (enforce_GTF2 && !dq_enclosed)
-      GError(GTF2_ERR,pre, dupline);
+      GError(GTF2_ERR,attr, dupline);
  char* vend=vp;
  if (dq_enclosed) {
     while (*vend!='"' && *vend!=';' && *vend!=0) vend++;
@@ -94,7 +111,7 @@ char* GffLine::extractAttr(const char* pre, bool caseStrict, bool enforce_GTF2)
     while (*vend!=';' && *vend!=0) vend++;
     }
  if (enforce_GTF2 && *vend!='"')
-     GError(GTF2_ERR, pre, dupline);
+     GError(GTF2_ERR, attr, dupline);
  char *r=Gstrdup(vp, vend-1);
  //-- now remove this attribute from the info string
  while (*vend!=0 && (*vend=='"' || *vend==';' || *vend==' ')) vend++;
@@ -169,7 +186,7 @@ GffLine::GffLine(GffReader* reader, const char* l) {
    GMessage("Warning: invalid end coordinate at line:\n%s\n",l);
    return;
    }
- if (fend<fstart) swap(fend,fstart); //make sure fstart>=fend, always
+ if (fend<fstart) Gswap(fend,fstart); //make sure fstart>=fend, always
  p=t[5];
  if (p[0]=='.' && p[1]==0) {
   score=0;
@@ -234,27 +251,27 @@ if (reader->transcriptsOnly && !is_t_data) {
           }
         return; //skip this line, unwanted feature name
         }
- ID=extractAttr("ID=");
- char* Parent=extractAttr("Parent=");
+ ID=extractAttr("ID=",true);
+ char* Parent=extractAttr("Parent=",true);
  is_gff3=(ID!=NULL || Parent!=NULL);
  if (is_gff3) {
    //parse as GFF3
     if (ID!=NULL) {
        //has ID attr so it's likely to be a parent feature
        //look for explicit gene name
-       gene_name=extractAttr("gene_name=",false);
+       gene_name=extractAttr("gene_name=");
        if (gene_name==NULL) {
-           gene_name=extractAttr("geneName=",false);
+           gene_name=extractAttr("geneName=");
            if (gene_name==NULL) {
-               gene_name=extractAttr("gene_sym=",false);
+               gene_name=extractAttr("gene_sym=");
                if (gene_name==NULL) {
-                   gene_name=extractAttr("gene=",false);
+                   gene_name=extractAttr("gene=");
                    }
                }
            }
-       gene_id=extractAttr("geneID=",false);
+       gene_id=extractAttr("geneID=");
        if (gene_id==NULL) {
-          gene_id=extractAttr("gene_id=",false);
+          gene_id=extractAttr("gene_id=");
           }
        if (is_gene) {
          //special case: keep the Name and ID attributes of the gene feature
@@ -299,7 +316,7 @@ if (reader->transcriptsOnly && !is_t_data) {
          } //has Parent field
    } //GFF3
   else { // GTF-like expected
-   Parent=extractAttr("transcript_id");
+   Parent=extractAttr("transcript_id",true);
    if (Parent!=NULL) { //GTF2 format detected
      if (is_transcript) {
          // atypical GTF with a parent transcript line declared
@@ -307,11 +324,17 @@ if (reader->transcriptsOnly && !is_t_data) {
          Parent=NULL;
          }
      gene_id=extractAttr("gene_id"); // for GTF this is the only attribute accepted as geneID
+     if (gene_id==NULL)
+       gene_id=extractAttr("geneid");
      gene_name=extractAttr("gene_name");
      if (gene_name==NULL) {
+
            gene_name=extractAttr("gene_sym");
-           if (gene_name==NULL)
+           if (gene_name==NULL) {
                gene_name=extractAttr("gene");
+               if (gene_name==NULL)
+                  gene_name=extractAttr("genesymbol");
+               }
            }
      //prepare for parseAttr by adding '=' character instead of spaces for all attributes
      //after the attribute name
@@ -531,7 +554,7 @@ int GffObj::addExon(uint segstart, uint segend, double sc, char fr, int qs, int
      isCDS=false;
      }
   if (qs || qe) {
-    if (qs>qe) swap(qs,qe);
+    if (qs>qe) Gswap(qs,qe);
     if (qs==0) qs=1;
 	}
   int ovlen=0;
@@ -763,9 +786,9 @@ GffObj::GffObj(GffReader *gfrd, GffLine* gffline, bool keepAttr, bool noExonAttr
   isCDS=gffline->is_cds; //for now
   isGene(gffline->is_gene);
   isTranscript(gffline->is_transcript || gffline->exontype!=0);
-  fromGff3(gffline->is_gff3);
+  //fromGff3(gffline->is_gff3);
 
-  if (gffline->parents!=NULL) {
+  if (gffline->parents!=NULL && !gffline->is_transcript) {
     //GTF style -- create a GffObj directly by subfeature
     //(also possible orphan GFF3 exon line, or an exon given before its parent (chado))
     if (gffline->exontype!=0) { //recognized exon-like feature
@@ -776,13 +799,13 @@ GffObj::GffObj(GffReader *gfrd, GffLine* gffline, bool keepAttr, bool noExonAttr
        //make this GffObj of the same feature type
        ftype_id=names->feats.addName(gffline->ftype);
        }
-    if (gffline->ID==NULL) { //typical GTF
+    if (gffline->ID==NULL) { //typical GTF2 without "transcript" line
         gffID=Gstrdup(gffline->parents[0]);
         this->createdByExon(true);
         //this is likely the first exon/segment of the feature
         addExon(gfrd, gffline, keepAttr, noExonAttr);
         }
-      else { //a parented feature with an ID -- probably an orphan GFF3 line
+      else { //a parented feature with an ID: orphan or premature GFF3 subfeature line
         if (gffline->is_gff3 && gffline->exontype!=0) {
              //premature exon given before its parent transcript
              //create the transcript entry here
@@ -791,35 +814,41 @@ GffObj::GffObj(GffReader *gfrd, GffLine* gffline, bool keepAttr, bool noExonAttr
              //this is the first exon/segment of the transcript
              addExon(gfrd, gffline, keepAttr, noExonAttr);
              }
-            else { //unrecognized non-exon feature ? use the ID instead
+        else { //unrecognized non-exon feature ? use the ID instead
+             this->hasGffID(true);
              gffID=Gstrdup(gffline->ID);
              if (keepAttr) this->parseAttrs(attrs, gffline->info);
              }
         }
-    } //subfeature given directly
-  else { //gffline->parents==NULL
+    } //non-transcript parented subfeature given directly
+  else {
+	//non-parented feature OR a recognizable transcript
     //create a parent feature in its own right
     gscore=gffline->score;
     if (gffline->ID==NULL || gffline->ID[0]==0)
       GError("Error: no ID found for GFF record start\n");
+    this->hasGffID(true);
     gffID=Gstrdup(gffline->ID); //there must be an ID here
     //if (gffline->is_transcript) ftype_id=gff_fid_mRNA;
       //else
     ftype_id=names->feats.addName(gffline->ftype);
     if (gffline->is_transcript)
       exon_ftype_id=gff_fid_exon;
-
     if (keepAttr) this->parseAttrs(attrs, gffline->info);
     }//no parent
 
   if (gffline->gene_name!=NULL) {
      gene_name=Gstrdup(gffline->gene_name);
      }
-  if (gffline->gene_id!=NULL) {
+  if (gffline->gene_id) {
      geneID=Gstrdup(gffline->gene_id);
      }
+  else if (gffline->is_transcript && gffline->parents) {
+	 geneID=Gstrdup(gffline->parents[0]);
+     }
 
-  GSeqStat* gsd=gfrd->gseqstats.AddIfNew(new GSeqStat(gseq_id,names->gseqs.lastNameUsed()),true);
+  //GSeqStat* gsd=gfrd->gseqstats.AddIfNew(new GSeqStat(gseq_id,names->gseqs.lastNameUsed()),true);
+  GSeqStat* gsd=gfrd->gseqstats.AddIfNew(new GSeqStat(gseq_id,gffline->gseqname), true);
   uptr=gsd;
   if (start<gsd->mincoord) gsd->mincoord=start;
   if (end>gsd->maxcoord) gsd->maxcoord=end;
@@ -859,6 +888,7 @@ GffLine* GffReader::nextGffLine() {
 return gffline;
 }
 
+
 char* GffReader::gfoBuildId(const char* id, const char* ctg) {
 //caller must free the returned pointer
  char* buf=NULL;
@@ -869,27 +899,54 @@ char* GffReader::gfoBuildId(const char* id, const char* ctg) {
  strcpy(buf+idlen+1, ctg);
  return buf;
 }
-
+/*
 void GffReader::gfoRemove(const char* id, const char* ctg) {
  char* buf=gfoBuildId(id,ctg);
  phash.Remove(buf);
  GFREE(buf);
 }
+*/
+GfoHolder* GffReader::gfoAdd(GffObj* gfo, int idx) {
+ //Warning: if gflst gets altered, idx becomes obsolete
+ GVec<GfoHolder>* glst=phash.Find(gfo->gffID);
+ if (glst==NULL)
+	 glst=new GVec<GfoHolder>(1);
+ GfoHolder gh(gfo,idx);
+ int i=glst->Add(gh);
+ phash.Add(gfo->gffID, glst);
+ return &(glst->Get(i));
+}
 
-//Warning: if gflst gets altered, idx becomes obsolete
-GfoHolder* GffReader::gfoAdd(const char* id, const char* ctg, GffObj* gfo, int idx) {
- char* buf=gfoBuildId(id,ctg);
- GfoHolder* r=new GfoHolder(gfo,idx);
- phash.Add(buf, r);
- GFREE(buf);
- return r;
+GfoHolder* GffReader::gfoAdd(GVec<GfoHolder>& glst, GffObj* gfo, int idx) {
+ GfoHolder gh(gfo,idx);
+ int i=glst.Add(gh);
+ return &(glst[i]);
 }
 
-GfoHolder* GffReader::gfoFind(const char* id, const char* ctg) {
- char* buf=gfoBuildId(id,ctg);
- GfoHolder* r=phash.Find(buf);
- GFREE(buf);
- return r;
+GfoHolder* GffReader::gfoFind(const char* id, const char* ctg,
+	            GVec<GfoHolder>** glst, char strand, uint start, uint end) {
+ GVec<GfoHolder>* gl=phash.Find(id);
+ GfoHolder* gh=NULL;
+ if (gl) {
+   for (int i=0;i<gl->Count();i++) {
+      GfoHolder& gfo = gl->Get(i);
+      if (ctg!=NULL && strcmp(ctg, gfo.gffobj->getGSeqName())!=0)
+           continue;
+      if (strand && gfo.gffobj->strand!='.' && strand != gfo.gffobj->strand)
+           continue;
+      if (start>0) {
+    	   if (abs((int)start-(int)gfo.gffobj->start)>GFF_MAX_LOCUS)
+               continue;
+           if (end>0 && (gfo.gffobj->start>end || gfo.gffobj->end<start))
+        	   continue;
+           }
+      //must be the same transcript, according to given comparison criteria
+      gh=&gfo;
+      break;
+      }
+   }
+ if (glst) *glst=gl;
+ return gh;
 }
 
 GfoHolder* GffReader::replaceGffRec(GffLine* gffline, bool keepAttr, bool noExonAttr, int replaceidx) {
@@ -897,22 +954,24 @@ GfoHolder* GffReader::replaceGffRec(GffLine* gffline, bool keepAttr, bool noExon
   GfoHolder* r=NULL;
   if (replaceidx>=0) {
      gflst.Put(replaceidx,newgfo);
-     r=gfoAdd(newgfo->gffID, gffline->gseqname, newgfo, replaceidx);
+     r=gfoAdd(newgfo, replaceidx);
      }
    else {
      int gfoidx=gflst.Add(newgfo);
-     r=gfoAdd(newgfo->gffID, gffline->gseqname, newgfo, gfoidx);
+     r=gfoAdd(newgfo, gfoidx);
      }
+  /*
   if (gff_warns) {
     int* pcount=tids.Find(newgfo->gffID);
     if (pcount!=NULL) {
-       if (gff_warns) GMessage("Warning: duplicate GFF ID: %s\n", newgfo->gffID);
+      if (gff_warns) GMessage("Warning: duplicate GFF ID: %s\n", newgfo->gffID);
        (*pcount)++;
        }
      else {
        tids.Add(newgfo->gffID,new int(1));
        }
     }
+   */
   return r;
 }
 
@@ -933,15 +992,16 @@ GfoHolder* GffReader::updateParent(GfoHolder* newgfh, GffObj* parent) {
 }
 
 GfoHolder* GffReader::newGffRec(GffLine* gffline, bool keepAttr, bool noExonAttr,
-                          GffObj* parent, GffExon* pexon) {
+                          GffObj* parent, GffExon* pexon, GVec<GfoHolder>* glst) {
   GffObj* newgfo=new GffObj(this, gffline, keepAttr, noExonAttr);
   GfoHolder* r=NULL;
   int gfoidx=gflst.Add(newgfo);
-  r=gfoAdd(newgfo->gffID, gffline->gseqname, newgfo, gfoidx);
+  r=(glst) ? gfoAdd(*glst, newgfo, gfoidx) : gfoAdd(newgfo, gfoidx);
   if (parent!=NULL) {
     updateParent(r, parent);
     if (pexon!=NULL) parent->removeExon(pexon);
     }
+  /*
   if (gff_warns) {
     int* pcount=tids.Find(newgfo->gffID);
     if (pcount!=NULL) {
@@ -952,19 +1012,20 @@ GfoHolder* GffReader::newGffRec(GffLine* gffline, bool keepAttr, bool noExonAttr
        tids.Add(newgfo->gffID,new int(1));
        }
     }
+  */
   return r;
 }
 
 GfoHolder* GffReader::updateGffRec(GfoHolder* prevgfo, GffLine* gffline, 
                                          bool keepAttr) {
  if (prevgfo==NULL) return NULL;
- prevgfo->gffobj->createdByExon(false);
+ //prevgfo->gffobj->createdByExon(false);
  prevgfo->gffobj->ftype_id=prevgfo->gffobj->names->feats.addName(gffline->ftype);
  prevgfo->gffobj->start=gffline->fstart;
  prevgfo->gffobj->end=gffline->fend;
  prevgfo->gffobj->isGene(gffline->is_gene);
  prevgfo->gffobj->isTranscript(gffline->is_transcript || gffline->exontype!=0);
- prevgfo->gffobj->fromGff3(gffline->is_gff3);
+ prevgfo->gffobj->hasGffID(gffline->ID!=NULL);
  if (keepAttr) {
    if (prevgfo->gffobj->attrs!=NULL) prevgfo->gffobj->attrs->Clear();
    prevgfo->gffobj->parseAttrs(prevgfo->gffobj->attrs, gffline->info);
@@ -976,8 +1037,8 @@ GfoHolder* GffReader::updateGffRec(GfoHolder* prevgfo, GffLine* gffline,
 bool GffReader::addExonFeature(GfoHolder* prevgfo, GffLine* gffline, GHash<CNonExon>& pex, bool noExonAttr) {
   bool r=true;
   if (gffline->strand!=prevgfo->gffobj->strand) {
-  //TODO: add support for trans-splicing and even inter-chromosomal fusions
-     if (prevgfo->gffobj->strand=='.') {
+     //TODO: add support for trans-splicing and even inter-chromosomal fusions
+        if (prevgfo->gffobj->strand=='.') {
             prevgfo->gffobj->strand=gffline->strand;
         }
      else {
@@ -1041,39 +1102,70 @@ GfoHolder* GffReader::promoteFeature(CNonExon* subp, char*& subp_name, GHash<CNo
 }
 
 //have to parse the whole file because exons can be scattered all over
+//trans-splicing and fusions are only accepted in proper GFF3 format, with a single parent feature ID entry
 void GffReader::readAll(bool keepAttr, bool mergeCloseExons, bool noExonAttr) {
   bool validation_errors = false;
   //loc_debug=false;
   GHash<CNonExon> pex; //keep track of any "exon"-like features that have an ID
                      //and thus could become promoted to parent features
   while (nextGffLine()!=NULL) {
-       //seen this gff ID before?
      GfoHolder* prevseen=NULL;
-     if (gffline->ID) //GFF3
-         prevseen=gfoFind(gffline->ID, gffline->gseqname);
-     if (prevseen!=NULL) {
-            if (prevseen->gffobj->createdByExon()) {
-                updateGffRec(prevseen, gffline, keepAttr);
-                }
-             else {
-                GMessage("Error: duplicate GFF ID '%s' encountered!\n",gffline->ID);
-                validation_errors = true;
-                if (gff_warns) { 
-                       delete gffline; gffline=NULL; continue;
-                       }
-                   else exit(1);
-                }
-            }
+     GVec<GfoHolder>* prevgflst=NULL;
+     if (gffline->ID && gffline->exontype==0) {
+	 //>> for a parent-like IDed feature (mRNA, gene, etc.)
+		 //look for same ID on the same chromosome/strand/locus
+		 prevseen=gfoFind(gffline->ID, gffline->gseqname, &prevgflst, gffline->strand, gffline->fstart);
+		 if (prevseen!=NULL) {
+				//same ID/chromosome combo encountered before
+				if (prevseen->gffobj->createdByExon() &&
+					  prevseen->gffobj->start>=gffline->fstart &&
+					  prevseen->gffobj->end<=gffline->fend) {
+					//an exon of this ID was given before
+					//this line has the main attributes for this ID
+					updateGffRec(prevseen, gffline, keepAttr);
+					}
+				 else {
+					//- duplicate ID -- this must be a discontiguous feature
+				   //   e.g. a trans-spliced transcript
+				   if (prevseen->gffobj->overlap(gffline->fstart, gffline->fend)) {
+					  //overlapping with same ID not allowed
+					 GMessage("Error: duplicate GFF ID '%s' encountered!\n",gffline->ID);
+					 //validation_errors = true;
+					 if (gff_warns) {
+					 	   delete gffline;
+					 	   gffline=NULL;
+					 	   continue;
+					 	   }
+					 else exit(1);
+				     }
+				    //create a new entry with the same ID
+                    prevseen=newGffRec(gffline, keepAttr, noExonAttr,
+                    	    prevseen->gffobj->parent, NULL, prevgflst);
+					} //duplicate ID on the same chromosome
+				} //prevseeen != NULL
+        } //parent-like ID feature
     if (gffline->parents==NULL) {//start GFF3-like record with no parent (mRNA, gene)
-       if (!prevseen) newGffRec(gffline, keepAttr, noExonAttr);
+       if (!prevseen) newGffRec(gffline, keepAttr, noExonAttr, NULL, NULL, prevgflst);
        }
-    else { //--- it's a parented feature (could still be a mRNA)
+    else { //--- it's a child feature (exon/CDS but could still be a mRNA with gene(s) as parent)
+       //updates all the declared parents with this child
        bool found_parent=false;
        GfoHolder* newgfo=prevseen;
+       GVec<GfoHolder>* newgflst=NULL;
        for (int i=0;i<gffline->num_parents;i++) {
             if (transcriptsOnly && discarded_ids.Find(gffline->parents[i])!=NULL)
                 continue; //skipping discarded parent feature
-            GfoHolder* parentgfo=gfoFind(gffline->parents[i], gffline->gseqname);
+            GfoHolder* parentgfo=NULL;
+            if (gffline->is_transcript || gffline->exontype==0) {//possibly a transcript
+               parentgfo=gfoFind(gffline->parents[i], gffline->gseqname,
+                                    &newgflst, gffline->strand, gffline->fstart, gffline->fend);
+               }
+            else {
+               //for exon-like entities we only need a parent to be in locus distance,
+               //on the same strand
+               parentgfo=gfoFind(gffline->parents[i], gffline->gseqname,
+                                     &newgflst, gffline->strand, gffline->fstart);
+               }
             if (parentgfo!=NULL) { //parent GffObj parsed earlier
                    found_parent=true;
                    if (parentgfo->gffobj->isGene() && gffline->is_transcript
@@ -1090,10 +1182,10 @@ void GffReader::readAll(bool keepAttr, bool mergeCloseExons, bool noExonAttr) {
                        if (!addExonFeature(parentgfo, gffline, pex, noExonAttr))
                          validation_errors=true;
                        }
-                   }
+                   } //overlapping parent feature found
             } //for each parsed parent Id
        if (!found_parent) { //new GTF-like record starting here with a subfeature directly
-             //or it could be some chado GFF3 barf with exons declared BEFORE their parent :(
+             //or it could be some chado GFF3 barf with exons coming BEFORE their parent :(
             //check if this feature isn't parented by a previously stored "exon" subfeature
             char* subp_name=NULL;
             CNonExon* subp=subfPoolCheck(gffline, pex, subp_name);
@@ -1104,11 +1196,17 @@ void GffReader::readAll(bool keepAttr, bool mergeCloseExons, bool noExonAttr) {
                if (!addExonFeature(gfoh, gffline, pex, noExonAttr))
                       validation_errors=true;
                }
-              else { //no parent seen before, create one directly with this exon
+              else { //no parent seen before,
                //loc_debug=true;
-               GfoHolder* newgfo=prevseen ? prevseen : newGffRec(gffline, keepAttr, noExonAttr);
-               if (gffline->ID!=NULL && gffline->exontype==0)
-                     subfPoolAdd(pex, newgfo);
+               GfoHolder* ngfo=prevseen;
+               if (ngfo==NULL) {
+                   //if it's an exon type, create directly the parent with this exon
+            	   //but if it's recognized as a transcript, the object itself is created
+            	   ngfo=newGffRec(gffline, keepAttr, noExonAttr, NULL, NULL, newgflst);
+                   }
+               if (!ngfo->gffobj->isTranscript() &&
+            	     gffline->ID!=NULL && gffline->exontype==0)
+                     subfPoolAdd(pex, ngfo);
                //even those with errors will be added here!
                }
             GFREE(subp_name);
@@ -1122,7 +1220,7 @@ void GffReader::readAll(bool keepAttr, bool mergeCloseExons, bool noExonAttr) {
  // all gff records are now loaded in GList gflst
  // so we can free the hash
   phash.Clear();
-  tids.Clear();
+  //tids.Clear();
   if (validation_errors) {
     exit(1);
     }
@@ -1141,37 +1239,41 @@ GffObj* GffObj::finalize(GffReader* gfr, bool mergeCloseExons, bool keepAttrs, b
     ftype_id=gff_fid_mRNA;
     //exon_ftype_id=gff_fid_exon;
     }
- //if (ftype_id==gff_fid_mRNA || exon_ftype_id==gff_fid_exon || mergeCloseExons) {
- if (isTranscript() || exon_ftype_id==gff_fid_exon || mergeCloseExons) {
-   int mindist=mergeCloseExons ? 5:1;
-   for (int i=0;i<exons.Count()-1;i++) {
-     int ni=i+1;
-     uint mend=exons[i]->end;
-     while (ni<exons.Count()) {
-       int dist=(int)(exons[ni]->start-mend);
-       if (dist>mindist) break; //no merging with next segment
-       if (gfr!=NULL && gfr->gff_warns && dist!=0 && (exons[ni]->exontype!=exgffUTR && exons[i]->exontype!=exgffUTR)) {
-          GMessage("GFF warning: merging adjacent/overlapping segments of %s on %s (%d-%d, %d-%d)\n",
-               gffID, getGSeqName(), exons[i]->start, exons[i]->end,exons[ni]->start, exons[ni]->end);
-          }
-       mend=exons[ni]->end;
-       covlen-=exons[i]->len();
-       exons[i]->end=mend;
-       covlen+=exons[i]->len();
-       covlen-=exons[ni]->len();
-       if (exons[ni]->attrs!=NULL && (exons[i]->attrs==NULL || 
-            exons[i]->attrs->Count()<exons[ni]->attrs->Count())) {
-              //use the other exon attributes, if more
-              delete(exons[i]->attrs);
-              exons[i]->attrs=exons[ni]->attrs;
-              exons[ni]->attrs=NULL;
-              }
-       exons.Delete(ni);
-       } //check for merge with next exon
+ if (exons.Count()>0 && (isTranscript() || exon_ftype_id==gff_fid_exon)) {
+   if (mergeCloseExons) {
+     int mindist=mergeCloseExons ? 5:1;
+     for (int i=0;i<exons.Count()-1;i++) {
+       int ni=i+1;
+       uint mend=exons[i]->end;
+       while (ni<exons.Count()) {
+         int dist=(int)(exons[ni]->start-mend);
+         if (dist>mindist) break; //no merging with next segment
+         if (gfr!=NULL && gfr->gff_warns && dist!=0 && (exons[ni]->exontype!=exgffUTR && exons[i]->exontype!=exgffUTR)) {
+            GMessage("GFF warning: merging adjacent/overlapping segments of %s on %s (%d-%d, %d-%d)\n",
+                 gffID, getGSeqName(), exons[i]->start, exons[i]->end,exons[ni]->start, exons[ni]->end);
+            }
+         mend=exons[ni]->end;
+         covlen-=exons[i]->len();
+         exons[i]->end=mend;
+         covlen+=exons[i]->len();
+         covlen-=exons[ni]->len();
+         if (exons[ni]->attrs!=NULL && (exons[i]->attrs==NULL ||
+              exons[i]->attrs->Count()<exons[ni]->attrs->Count())) {
+                //use the other exon attributes, if more
+                delete(exons[i]->attrs);
+                exons[i]->attrs=exons[ni]->attrs;
+                exons[ni]->attrs=NULL;
+                }
+         exons.Delete(ni);
+         } //check for merge with next exon
      } //for each exon
-   }
+   } //merge close exons
+   //shrink transcript to the exons' span
+   this->start=exons.First()->start;
+   this->end=exons.Last()->end;
+ }
  //attribute reduction for GTF records
- if (keepAttrs && !noExonAttr && !fromGff3() 
+ if (keepAttrs && !noExonAttr && !hasGffID()
           && exons.Count()>0 && exons[0]->attrs!=NULL) {
    bool attrs_discarded=false;
    for (int a=0;a<exons[0]->attrs->Count();a++) {
diff --git a/src/gff.h b/src/gff.h
index ee3eadb..a4e8f6e 100644
--- a/src/gff.h
+++ b/src/gff.h
@@ -29,7 +29,7 @@ extern const uint GFF_MAX_INTRON;
 extern const uint gfo_flag_CHILDREN_PROMOTED;
 extern const uint gfo_flag_HAS_ERRORS;
 extern const uint gfo_flag_IS_GENE;
-extern const uint gfo_flag_FROM_GFF3; //parsed from GFF3 formatted record
+extern const uint gfo_flag_HAS_GFF_ID; //found a GFF3 formatted main feature with its own ID
 extern const uint gfo_flag_BY_EXON;  //created by subfeature (exon) directly
                       //(GTF2 and some chado gff3 dumps with exons given before their mRNA)
 extern const uint gfo_flag_IS_TRANSCRIPT; //recognized as '*RNA' or '*transcript'
@@ -98,7 +98,7 @@ class GffLine {
        num_parents=0;
        parents=NULL;
        }
-    char* extractAttr(const char* pre, bool caseStrict=true, bool enforce_GTF2=false);
+    char* extractAttr(const char* pre, bool caseStrict=false, bool enforce_GTF2=false);
     GffLine(GffLine* l) { //a copy constructor
       memcpy((void*)this, (void*)l, sizeof(GffLine));
       line=NULL;
@@ -235,9 +235,6 @@ protected:
    bool operator==(GffNameInfo& d){
        return (strcmp(this->name, d.name)==0);
        }
-   bool operator>(GffNameInfo& d){
-      return (strcmp(this->name, d.name)>0);
-      }
    bool operator<(GffNameInfo& d){
      return (strcmp(this->name, d.name)<0);
      }
@@ -256,8 +253,9 @@ protected:
      byName.shkAdd(f->name,f);
      }
 public:
- GffNameList():GList<GffNameInfo>(false,true,true), byName(false) {
+ GffNameList(int init_capacity=6):GList<GffNameInfo>(init_capacity, false,true,true), byName(false) {
     idlast=-1;
+    setCapacity(init_capacity);
     }
  char* lastNameUsed() { return idlast<0 ? NULL : Get(idlast)->name; }
  int lastNameId() { return idlast; }
@@ -269,8 +267,8 @@ public:
 
  int addName(const char* tname) {//returns or create an id for the given name
    //check idlast first, chances are it's the same feature name checked
-   if (idlast>=0 && strcmp(fList[idlast]->name,tname)==0)
-       return idlast;
+   /*if (idlast>=0 && strcmp(fList[idlast]->name,tname)==0)
+       return idlast;*/
    GffNameInfo* f=byName.Find(tname);
    int fidx=-1;
    if (f!=NULL) fidx=f->idx;
@@ -472,10 +470,10 @@ public:
       if (v) flags |= gfo_flag_HAS_ERRORS;
         else flags &= ~gfo_flag_HAS_ERRORS;
       }
-  bool fromGff3() { return ((flags & gfo_flag_FROM_GFF3)!=0); }
-  void fromGff3(bool v) {
-      if (v) flags |= gfo_flag_FROM_GFF3;
-        else flags &= ~gfo_flag_FROM_GFF3;
+  bool hasGffID() { return ((flags & gfo_flag_HAS_GFF_ID)!=0); }
+  void hasGffID(bool v) {
+      if (v) flags |= gfo_flag_HAS_GFF_ID;
+        else flags &= ~gfo_flag_HAS_GFF_ID;
       }
   bool createdByExon() { return ((flags & gfo_flag_BY_EXON)!=0); }
   void createdByExon(bool v) {
@@ -674,7 +672,7 @@ public:
      }
    bool exonOverlap(uint s, uint e) {//check if ANY exon overlaps given segment
       //ignores strand!
-      if (s>e) swap(s,e);
+      if (s>e) Gswap(s,e);
       for (int i=0;i<exons.Count();i++) {
          if (exons[i]->overlap(s,e)) return true;
          }
@@ -697,7 +695,7 @@ public:
     int exonOverlapIdx(uint s, uint e, int* ovlen=NULL) {
       //return the exons' index for the overlapping OR ADJACENT exon
       //ovlen, if given, will return the overlap length
-      if (s>e) swap(s,e);
+      if (s>e) Gswap(s,e);
       s--;e++; //to also catch adjacent exons
       for (int i=0;i<exons.Count();i++) {
             if (exons[i]->start>e) break;
@@ -975,10 +973,9 @@ class GfList: public GList<GffObj> {
 
 };
 
-class GfoHolder {
- public:
+struct GfoHolder {
    int idx; //position in GffReader::gflst array
-   GffObj* gffobj; 
+   GffObj* gffobj;
    GfoHolder(GffObj* gfo=NULL, int i=0) {
      idx=i;
      gffobj=gfo;
@@ -1018,12 +1015,15 @@ class GffReader {
   bool transcriptsOnly; //keep only transcripts w/ their exon/CDS features
   GHash<int> discarded_ids; //for transcriptsOnly mode, keep track
                             // of discarded parent IDs
-  GHash<GfoHolder> phash; //transcript_id+contig (Parent~Contig) => [gflst index, GffObj]
-  GHash<int> tids; //transcript_id uniqueness
+  GHash< GVec<GfoHolder> > phash; //transcript_id+contig (Parent~Contig) => [gflst index, GffObj]
+  //GHash<int> tids; //just for transcript_id uniqueness
   char* gfoBuildId(const char* id, const char* ctg);
-  void gfoRemove(const char* id, const char* ctg);
-  GfoHolder* gfoAdd(const char* id, const char* ctg, GffObj* gfo, int idx);
-  GfoHolder* gfoFind(const char* id, const char* ctg);
+  //void gfoRemove(const char* id, const char* ctg);
+  GfoHolder* gfoAdd(GffObj* gfo, int idx);
+  GfoHolder* gfoAdd(GVec<GfoHolder>& glst, GffObj* gfo, int idx);
+  // const char* id, const char* ctg, char strand, GVec<GfoHolder>** glst, uint start, uint end
+  GfoHolder* gfoFind(const char* id, const char* ctg=NULL, GVec<GfoHolder>** glst=NULL,
+	                                         char strand=0, uint start=0, uint end=0);
   CNonExon* subfPoolCheck(GffLine* gffline, GHash<CNonExon>& pex, char*& subp_name);
   void subfPoolAdd(GHash<CNonExon>& pex, GfoHolder* newgfo);
   GfoHolder* promoteFeature(CNonExon* subp, char*& subp_name, GHash<CNonExon>& pex,
@@ -1031,7 +1031,7 @@ class GffReader {
  public:
   GfList gflst; //accumulate GffObjs being read
   GfoHolder* newGffRec(GffLine* gffline, bool keepAttr, bool noExonAttr,
-                               GffObj* parent=NULL, GffExon* pexon=NULL);
+                               GffObj* parent=NULL, GffExon* pexon=NULL, GVec<GfoHolder>* glst=NULL);
   GfoHolder* replaceGffRec(GffLine* gffline, bool keepAttr, bool noExonAttr, int replaceidx);
   GfoHolder* updateGffRec(GfoHolder* prevgfo, GffLine* gffline, 
                                          bool keepAttr);
@@ -1039,7 +1039,7 @@ class GffReader {
   bool addExonFeature(GfoHolder* prevgfo, GffLine* gffline, GHash<CNonExon>& pex, bool noExonAttr);
   GList<GSeqStat> gseqstats; //list of all genomic sequences seen by this reader, accumulates stats
   GffReader(FILE* f=NULL, bool t_only=false, bool sortbyloc=false):discarded_ids(true),
-                       phash(true), tids(true), gflst(sortbyloc), gseqstats(true,true,true) {
+                       phash(true), gflst(sortbyloc), gseqstats(true,true,true) {
       gff_warns=gff_show_warnings;
       names=NULL;
       gffline=NULL;
@@ -1059,7 +1059,7 @@ class GffReader {
       gflst.sortedByLoc(sortbyloc);
       }
   GffReader(char* fn, bool t_only=false, bool sort=false):discarded_ids(true), phash(true),
-                             tids(true),gflst(sort),gseqstats(true,true,true) {
+                             gflst(sort),gseqstats(true,true,true) {
       gff_warns=gff_show_warnings;
       names=NULL;
       fname=Gstrdup(fn);
diff --git a/src/gff_utils.h b/src/gff_utils.h
index 4d9b934..1708ec5 100644
--- a/src/gff_utils.h
+++ b/src/gff_utils.h
@@ -228,7 +228,6 @@ class GTData { //transcript associated data
             rna->uptr=this;
             }
         }
-   bool operator>(GTData& b) { return (rna > b.rna); }
    bool operator<(GTData& b) { return (rna < b.rna); }
    bool operator==(GTData& b) { return (rna==b.rna); }
 };
@@ -240,10 +239,6 @@ class CGeneSym {
   CGeneSym(const char* n=NULL, int f=0):name(n) {
     freq=f;
     }
-  bool operator>(CGeneSym& b) {
-     return (freq==b.freq) ? ( (name.length()==b.name.length()) ? (name>b.name) :
-               (name.length()>b.name.length()) ) : ( freq<b.freq );
-     }
   bool operator<(CGeneSym& b) {
      return (freq==b.freq)? ( (name.length()==b.name.length()) ? (name<b.name) :
          (name.length()<b.name.length()) ) : ( freq>b.freq );
@@ -271,13 +266,6 @@ public:
    bool operator==(GffLocus& d){
        return (gseq_id==d.gseq_id && strand==d.strand && start==d.start && end==d.end);
        }
-   bool operator>(GffLocus& d){
-      if (gseq_id!=d.gseq_id) return (gseq_id>d.gseq_id);
-      if (start==d.start) {
-         if (end==d.end) return (strand>d.strand);
-                      else return (end>d.end);
-         } else return (start>d.start);
-      }
    bool operator<(GffLocus& d){
      if (gseq_id!=d.gseq_id) return (gseq_id<d.gseq_id);
      if (start==d.start) {
@@ -498,9 +486,6 @@ class GenomicSeqData {
   bool operator==(GenomicSeqData& d){
     return gseq_id==d.gseq_id;
   }
-  bool operator>(GenomicSeqData& d){
-    return (gseq_id>d.gseq_id);
-  }
   bool operator<(GenomicSeqData& d){
     return (gseq_id<d.gseq_id);
   }
@@ -588,13 +573,13 @@ struct GffLoader {
       noExonAttrs=false;
       mergeCloseExons=false;
       showWarnings=false;
-      if (fname=="-") {
+      if (fname=="-" || fname=="stdin") {
          f=stdin;
          fname="stdin";
          }
         else {
           if ((f=fopen(fname.chars(), "r"))==NULL) {
-            GError("Error: cannot open file %s!\n",fname.chars());
+            GError("Error: cannot open gff file %s!\n",fname.chars());
             }
           }
       }
diff --git a/src/gtf_tracking.cpp b/src/gtf_tracking.cpp
index 213f60f..042838d 100644
--- a/src/gtf_tracking.cpp
+++ b/src/gtf_tracking.cpp
@@ -562,6 +562,10 @@ void read_mRNAs(FILE* f, GList<GSeqData>& seqdata, GList<GSeqData>* ref_data,
 	         bool check_for_dups, int qfidx, const char* fname, bool only_multiexon) {
 	//>>>>> read all transcripts/features from a GTF/GFF3 file
 	//int imrna_counter=0;
+#ifdef HEAPROFILE
+    if (IsHeapProfilerRunning())
+      HeapProfilerDump("00");
+#endif
 	int loci_counter=0;
 	if (ref_data==NULL) ref_data=&seqdata;
 	bool isRefData=(&seqdata==ref_data);
@@ -571,14 +575,26 @@ void read_mRNAs(FILE* f, GList<GSeqData>& seqdata, GList<GSeqData>* ref_data,
 	//            keepAttrs   mergeCloseExons   noExonAttrs
 	gffr->readAll(!isRefData,          true,        isRefData || gtf_tracking_largeScale);
 	//so it will read exon attributes only for low number of Cufflinks files
-	
+#ifdef HEAPROFILE
+    if (IsHeapProfilerRunning())
+      HeapProfilerDump("post_readAll");
+#endif
+
 	int d=parse_mRNAs(gffr->gflst, seqdata, isRefData, check_for_dups, qfidx,only_multiexon);
+#ifdef HEAPROFILE
+    if (IsHeapProfilerRunning())
+      HeapProfilerDump("post_parse_mRNAs");
+#endif
 	if (gtf_tracking_verbose && d>0) {
 	  if (isRefData) GMessage(" %d duplicate reference transcripts discarded.\n",d);
 	            else GMessage(" %d redundant cufflinks transfrags discarded.\n",d);
 	  }
 	//imrna_counter=gffr->mrnas.Count();
 	delete gffr; //free the extra memory and unused GffObjs
+#ifdef HEAPROFILE
+    if (IsHeapProfilerRunning())
+      HeapProfilerDump("post_del_gffr");
+#endif
 	
 	//for each genomic sequence, cluster transcripts
 	int discarded=0;
@@ -627,6 +643,10 @@ void read_mRNAs(FILE* f, GList<GSeqData>& seqdata, GList<GSeqData>* ref_data,
 		if (gtf_tracking_verbose) GMessage("Found %d transcripts with undetermined strand.\n", discarded);
 	}
 	else { if (fdis!=NULL) remove(s.chars()); }
+#ifdef HEAPROFILE
+    if (IsHeapProfilerRunning())
+      HeapProfilerDump("post_cluster");
+#endif
 }
 
 int qsearch_mrnas(uint x, GList<GffObj>& mrnas) {
diff --git a/src/gtf_tracking.h b/src/gtf_tracking.h
index 6629d52..486e0ed 100644
--- a/src/gtf_tracking.h
+++ b/src/gtf_tracking.h
@@ -9,6 +9,10 @@
  *
  */
 
+#ifdef HEAPROFILE
+#include "gperftools/heap-profiler.h"
+#endif
+
 #include "gff.h"
 #include "GFaSeqGet.h"
 #include "GFastaIndex.h"
@@ -181,11 +185,6 @@ public:
 			return (ovlen==b.ovlen)? betterRef(mrna, b.mrna) : (ovlen>b.ovlen);
 		else return rank<b.rank;
 	}
-    bool operator>(COvLink& b) {
-		if (rank==b.rank)
-			return (ovlen==b.ovlen)? betterRef(b.mrna, mrna) : (ovlen<b.ovlen);
-		else return rank>b.rank;
-	}
     bool operator==(COvLink& b) {
 		return (rank==b.rank && mrna==b.mrna);
 	}
@@ -236,6 +235,7 @@ public:
 	GffObj* eqref; //ref transcript having an ichain match
 	int qset; //qry set index (qfidx), -1 means reference dataset
 	//GffObj* eqnext; //next GffObj in the linked list of matching transfrags
+	bool eqhead;
 	CEqList* eqlist; //keep track of matching transfrags
 	//int eqdata; // flags for EQ list (is it a list head?)
 	// Cufflinks specific data:
@@ -250,9 +250,8 @@ public:
 		locus=l;
 		classcode=0;
 		eqref=NULL;
-		//eqnext=NULL;
+		eqhead=false;
 		eqlist=NULL;
-		//eqdata=0;
 		qset=-2;
 		FPKM=0;
 		conf_lo=0;
@@ -263,41 +262,50 @@ public:
 	~CTData() {
 		ovls.Clear();
 		//if ((eqdata & EQHEAD_TAG)!=0) delete eqlist;
-		if (isEqHead()) delete eqlist;
+		//if (isEqHead()) delete eqlist;
+		if (eqhead) delete eqlist;
 	}
 
   //inline bool eqHead() { return ((eqdata & EQHEAD_TAG)!=0); }
-  bool isEqHead() { 
+ /*  bool isEqHead() {
       if (eqlist==NULL) return false;
       return (eqlist->head==this->mrna);
       }
-    
+  */
   void joinEqList(GffObj* m) { //add list from m
    //list head is set to the transfrag with the lower qset#
   CTData* md=(CTData*)(m->uptr);
   //ASSERT(md);
-  if (eqlist==NULL) {
-     if (md->eqlist!=NULL) {
+  if (eqlist==NULL) { //no eqlist yet for this node
+     if (md->eqlist!=NULL) { //m in an eqlist already
           eqlist=md->eqlist;
           eqlist->Add(this->mrna);
           CTData* md_head_d=(CTData*)(md->eqlist->head->uptr);
-          if (this->qset < md_head_d->qset)
+          if (this->qset < md_head_d->qset) {
                eqlist->head=this->mrna;
-          }
-        else { //m was not in an EQ list
-          //eqlist=new GList<GffObj>((GCompareProc*)cmpByPtr, (GFreeProc*)NULL, true);
+               eqhead=true;
+               md_head_d->eqhead=false;
+               }
+        }
+        else { //m was not in an EQ list either
           eqlist=new CEqList();
           eqlist->Add(this->mrna);
           eqlist->Add(m);
           md->eqlist=eqlist;
-          if (qset<md->qset) eqlist->head=this->mrna;
-                       else  eqlist->head=m;
+          if (qset<md->qset) {
+        	eqlist->head=this->mrna;
+        	eqhead=true;
+          }
+          else  {
+        	eqlist->head=m;
+        	md->eqhead=true;
           }
+        }
       }//no eqlist before
      else { //merge two eqlists
       if (eqlist==md->eqlist) //already in the same eqlist, nothing to do
          return;
-      if (md->eqlist!=NULL) { //copy elements of m's eqlist
+      if (md->eqlist!=NULL) {
         //copy the smaller list into the larger one
         CEqList* srclst, *destlst;
         if (md->eqlist->Count()<eqlist->Count()) {
@@ -312,23 +320,31 @@ public:
            destlst->Add(srclst->Get(i));
            CTData* od=(CTData*)((*srclst)[i]->uptr);
            od->eqlist=destlst;
-           //od->eqdata=od->qset+1;
            }
         this->eqlist=destlst;
         CTData* s_head_d=(CTData*)(srclst->head->uptr);
         CTData* d_head_d=(CTData*)(destlst->head->uptr);
-        if (s_head_d->qset < d_head_d->qset )
-             this->eqlist->head=srclst->head; 
-        delete srclst;
+        if (s_head_d->qset < d_head_d->qset ) {
+             this->eqlist->head=srclst->head;
+             s_head_d->eqhead=true;
+             d_head_d->eqhead=false;
+        }
+        else {
+          s_head_d->eqhead=false;
+          d_head_d->eqhead=true;
         }
-       else { //md->eqlist==NULL
+        delete srclst;
+      }
+      else { //md->eqlist==NULL
         eqlist->Add(m);
         md->eqlist=eqlist;
         CTData* head_d=(CTData*)(eqlist->head->uptr);
-        if (md->qset<head_d->qset)
-            eqlist->head=m;
+        if (md->qset<head_d->qset) {
+          eqlist->head=m;
+          md->eqhead=true;
         }
       }
+    }
   }
 
 	void addOvl(char code,GffObj* target=NULL, int ovlen=0) {
@@ -337,7 +353,6 @@ public:
 	char getBestCode() {
 		return (ovls.Count()>0) ? ovls[0]->code : 0 ;
     }
-	bool operator>(CTData& b) { return (mrna > b.mrna); }
 	bool operator<(CTData& b) { return (mrna < b.mrna); }
 	bool operator==(CTData& b) { return (mrna==b.mrna); }
 };
@@ -975,7 +990,7 @@ class GTrackLocus:public GSeg {
    void addQCl(int q, GQCluster* qcl, GLocus* lnkloc) {
       for (int i=0;i<qcl->qloci.Count();i++) {
          GLocus* loc=qcl->qloci[i];
-         if (loc==lnkloc || loc->t_ptr==this) continue;
+         if (loc==lnkloc) continue; // or if loc->t_ptr==this ?
          hasQloci=true;
          loc->t_ptr=this;
          qcls[q]->addLocus(loc);
diff --git a/src/hits.cpp b/src/hits.cpp
index 910ba0f..31aca08 100644
--- a/src/hits.cpp
+++ b/src/hits.cpp
@@ -242,7 +242,7 @@ void collapse_hits(const vector<MateHit>& hits,
 	{
 		if (hits_eq_non_multi_non_replicate(non_redundant[curr_unique_aln], hits[curr_aln]) || hits_eq_non_multi_non_replicate(non_redundant[++curr_unique_aln], hits[curr_aln]))
 		{
-            double more_mass = hits[curr_aln].common_scale_mass();
+            double more_mass = hits[curr_aln].internal_scale_mass();
 			//assert(non_redundant[curr_unique_aln].collapse_mass() == 0 || !non_redundant[curr_unique_aln].is_multi());
 			non_redundant[curr_unique_aln].incr_collapse_mass(more_mass);
 		}
diff --git a/src/hits.h b/src/hits.h
index ee1331e..5ad9a48 100644
--- a/src/hits.h
+++ b/src/hits.h
@@ -997,10 +997,10 @@ public:
 		return base_mass;
 	}
     
-	double common_scale_mass() const
+	double internal_scale_mass() const
 	{
        	double m = mass();
-        m *= _rg_props->mass_scale_factor();
+        m *= 1.0 / _rg_props->internal_scale_factor();
         
         return m;
 	}
diff --git a/src/jensen_shannon.cpp b/src/jensen_shannon.cpp
index e3e669f..91839ea 100644
--- a/src/jensen_shannon.cpp
+++ b/src/jensen_shannon.cpp
@@ -15,7 +15,7 @@ using namespace std;
 using namespace boost;
 
 
-double entropy(const ublas::vector<double>& p)
+double entropy(const Eigen::VectorXd& p)
 {
 	double e = 0;  
 	for (size_t i = 0; i < p.size(); ++i)
@@ -26,25 +26,15 @@ double entropy(const ublas::vector<double>& p)
             e -= (P * log(P));
         }
 	}
+    if (e < 0)
+        e = 0;
 	return e;
 }
 
-double jensen_shannon_distance(std::vector<ublas::vector<double> >& sample_kappas)
+double jensen_shannon_distance(std::vector<Eigen::VectorXd>& sample_kappas)
 {
 	assert (sample_kappas.size() > 1);
 	
-	for (size_t i = 0; i < sample_kappas.size(); ++i)
-	{
-		//cerr << sample_kappas[i] << endl;
-		double kappa_sum = accumulate(sample_kappas[i].begin(), 
-									  sample_kappas[i].end(), 0.0);
-		if (abs(kappa_sum - 1.0) > 1e-10)
-		{
-			//cerr << kappa_sum << " " << sample_kappas[i] << endl;
-		}
-		assert (abs(kappa_sum - 1.0) < 1e-10);
-	}
-	
 	size_t kappa_length = 0;
 	for (size_t i = 1; i < sample_kappas.size(); ++i)
 	{
@@ -52,7 +42,7 @@ double jensen_shannon_distance(std::vector<ublas::vector<double> >& sample_kappa
 		kappa_length = sample_kappas[i].size();
 	}
 	
-	ublas::vector<double> avg_kappas = ublas::zero_vector<double>(kappa_length);
+    Eigen::VectorXd avg_kappas = Eigen::VectorXd::Zero(kappa_length);
 	for (size_t i = 0; i < sample_kappas.size(); ++i)
 	{
 		//cout << "kappa " << i<< " "<< sample_kappas[i] << endl;
@@ -72,100 +62,12 @@ double jensen_shannon_distance(std::vector<ublas::vector<double> >& sample_kappa
 	double entropy_avg = entropy(avg_kappas);
 	
 	double js = entropy_avg - avg_entropy;
-
+    if (js < 0) // can happen due to underflow or rounding errors.
+        return 0;
 	return sqrt(js);
 }
 
-//void alt_jensen_shannon_gradient(vector<ublas::vector<double> >& sample_kappas,
-//                                 double js,
-//                                 ublas::vector<double>& gradient)
-//{
-//	assert (sample_kappas.size() > 1);
-//	size_t kappa_length = sample_kappas.front().size();
-//	for (size_t i = 1; i < sample_kappas.size(); ++i)
-//	{
-//		assert (sample_kappas[i].size() == sample_kappas[i-1].size());
-//		kappa_length = sample_kappas[i].size();
-//	}
-//	
-//	if (kappa_length == 0)
-//		return;
-//	
-//	gradient = ublas::zero_vector<double>(sample_kappas.size() * kappa_length);
-//	for (size_t i = 0; i < sample_kappas.size(); ++i)
-//	{
-//		for (size_t k = 0; k < kappa_length; ++k)
-//		{
-//			gradient(i*kappa_length + k) = sample_kappas[i](k);
-//		}
-//	}
-//	
-//	//cout << "t1: " << gradient<< endl;
-//	
-//	ublas::vector<double> p_bar = ublas::zero_vector<double>(kappa_length);
-//	for (size_t i = 0; i < sample_kappas.size(); ++i)
-//	{
-//		p_bar += sample_kappas[i];
-//	}
-//	p_bar /= sample_kappas.size();
-//	
-//	
-//	//cout << "t2 " << denoms << endl;
-//	
-//	for (size_t i = 0; i < sample_kappas.size(); ++i)
-//	{
-//		for (size_t k = 0; k < kappa_length; ++k)
-//		{
-//			if (p_bar(k) == 0.0 || gradient(i*kappa_length + k) == 0.0)
-//			{
-//				gradient(i*kappa_length + k) = 0.0;
-//			}
-//			else
-//			{
-//#ifdef DEBUG
-//				ublas::vector<double>& grad_tmp = gradient;
-//#endif
-////                double alt_grad = 0.0;
-////                double m = 2.0;
-////                alt_grad = js / (2.0 * m);
-////                double A = log(gradient(i*kappa_length + k)) + (1.0 / gradient(i*kappa_length + k));
-////                double B = log(p_bar[k]) + (1.0 / p_bar[k]);
-////                alt_grad *= (A - B);
-//                
-//                double alt_grad = 0.0;
-//                
-//                alt_grad /= p_bar(k);
-//				alt_grad = log(gradient(i*kappa_length + k));
-//				alt_grad /= sample_kappas.size(); // m in paper notation
-//				alt_grad *= (1.0/(2.0 * js)); // This is supposed to use the square root of the distance (it's not a typo)
-//				
-//
-//                
-//				gradient(i*kappa_length + k) /= p_bar(k);
-//				gradient(i*kappa_length + k) = log(gradient(i*kappa_length + k));
-//				gradient(i*kappa_length + k) /= sample_kappas.size(); // m in paper notation
-//				gradient(i*kappa_length + k) *= (1.0/(2.0 * js)); // This is supposed to use the square root of the distance (it's not a typo)
-//				
-//                double curr_grad = gradient(i*kappa_length + k);
-//                
-//                gradient(i*kappa_length + k) = alt_grad;
-//                //fprintf(stderr, "Curr gradient: %lg, alternate gradient %lg\n", curr_grad, alt_grad);
-//#ifdef DEBUG
-//				if(isinf(gradient(i*kappa_length + k)))
-//				{
-//					cerr << grad_tmp << endl;
-//					cerr << sample_kappas[i] << endl;
-//					assert (false);
-//				}
-//#endif
-//				
-//			}
-//		}
-//	}
-//}
-
-
-void jensen_shannon_gradient(vector<ublas::vector<double> >& sample_kappas,
+void jensen_shannon_gradient(vector<Eigen::VectorXd>& sample_kappas,
 							 double js,
 							 ublas::vector<double>& gradient)
 {
@@ -192,10 +94,13 @@ void jensen_shannon_gradient(vector<ublas::vector<double> >& sample_kappas,
 	
 	//cout << "t1: " << gradient<< endl;
 	
-	ublas::vector<double> p_bar = ublas::zero_vector<double>(kappa_length);
+    ublas::vector<double> p_bar = ublas::zero_vector<double>(kappa_length);
 	for (size_t i = 0; i < sample_kappas.size(); ++i)
 	{
-		p_bar += sample_kappas[i];
+		for (size_t j = 0; j < sample_kappas[i].size(); ++j)
+        {
+            p_bar[j] += sample_kappas[i](j);   
+        }
 	}
 	p_bar /= sample_kappas.size();
 	
@@ -212,9 +117,6 @@ void jensen_shannon_gradient(vector<ublas::vector<double> >& sample_kappas,
 			}
 			else
 			{
-#ifdef DEBUG
-				ublas::vector<double>& grad_tmp = gradient;
-#endif
                 double alt_grad = 0.0;
                 double m = 2.0;
                 alt_grad = js / (2.0 * m);
@@ -231,15 +133,7 @@ void jensen_shannon_gradient(vector<ublas::vector<double> >& sample_kappas,
                 
                 assert (!isinf(curr_grad) && !isnan(curr_grad));
                 //fprintf(stderr, "Curr gradient: %lg, alternate gradient %lg\n", curr_grad, alt_grad);
-#if 0
-				if(isinf(gradient(i*kappa_length + k)))
-				{
-					cerr << grad_tmp << endl;
-					cerr << sample_kappas[i] << endl;
-					assert (false);
-				}
-#endif
-				
+            
 			}
 		}
 	}
diff --git a/src/jensen_shannon.h b/src/jensen_shannon.h
index cb89f0a..96d6132 100644
--- a/src/jensen_shannon.h
+++ b/src/jensen_shannon.h
@@ -14,18 +14,15 @@
 #include <boost/numeric/ublas/io.hpp>
 
 #include <vector>
+#include <Eigen/Dense>
 
 namespace ublas = boost::numeric::ublas;
 
 double entropy(const ublas::vector<double>& p);
 
-double jensen_shannon_distance(std::vector<ublas::vector<double> >& sample_kappas);
+double jensen_shannon_distance(std::vector<Eigen::VectorXd>& sample_kappas);
 
-//void alt_jensen_shannon_gradient(std::vector<ublas::vector<double> >& sample_kappas,
-//                                 double js,
-//                                 ublas::vector<double>& gradient);
-
-void jensen_shannon_gradient(std::vector<ublas::vector<double> >& sample_kappas,
+void jensen_shannon_gradient(std::vector<Eigen::VectorXd>& sample_kappas,
 							 double js,
 							 ublas::vector<double>& gradient);
 
diff --git a/src/locfit/cmd.c b/src/locfit/cmd.c
index cc52b50..ec19da6 100644
--- a/src/locfit/cmd.c
+++ b/src/locfit/cmd.c
@@ -444,7 +444,7 @@ vari *v;
 void setcolor(v)
 vari *v;
 {
-    return NULL;
+    return;
 //   int i;
 //    lfcm[CBAK] = getcolidx(getargval(v,"back",0),lfcm[CBAK]);
 //    
diff --git a/src/locfit/ev_trian.c b/src/locfit/ev_trian.c
index c53369b..fa110d9 100644
--- a/src/locfit/ev_trian.c
+++ b/src/locfit/ev_trian.c
@@ -107,7 +107,7 @@ lfit *tr;
 double *xa;
 INT *ce;
 { double le[(1+MXDIM)*(1+MXDIM)], ml;
-  INT d, vc, i, j, pv[(1+MXDIM)*(1+MXDIM)], im, jm;
+  INT d, vc, i, j, pv[(1+MXDIM)*(1+MXDIM)], im = 0, jm = 0;
   design *des;
   des = NULL;
   if (!triang_split(tr,ce,le)) return;
diff --git a/src/multireads.cpp b/src/multireads.cpp
index 4f43b8c..3dc061c 100644
--- a/src/multireads.cpp
+++ b/src/multireads.cpp
@@ -101,7 +101,8 @@ void MultiReadTable::add_expr(RefID r_id, int left, int right, InsertID mr_id, d
 	boost::mutex::scoped_lock lock(_lock);
 #endif
 	MultiRead* mr = get_read(mr_id);
-	mr->add_expr(r_id, left, right, expr);
+    if (mr)
+        mr->add_expr(r_id, left, right, expr);
 }
 
 double MultiReadTable::get_mass(const MateHit& hit)
diff --git a/src/replicates.cpp b/src/replicates.cpp
index 634f209..ec5c158 100644
--- a/src/replicates.cpp
+++ b/src/replicates.cpp
@@ -18,10 +18,13 @@ extern "C" {
 boost::mutex _locfit_lock;
 #endif
 
-MassDispersionModel::MassDispersionModel(const std::vector<double>& scaled_mass_means, 
+MassDispersionModel::MassDispersionModel(const std::string& name,
+                                         const std::vector<double>& scaled_mass_means, 
                                          const std::vector<double>& scaled_raw_variances,
                                          const std::vector<double>& scaled_mass_variances) 
 {
+    _name = name;
+    
     if (scaled_mass_means.size() != scaled_mass_variances.size())
     {
         fprintf (stderr, "Error: dispersion model table is malformed\n");
@@ -173,10 +176,26 @@ double MassDispersionModel::scale_mass_variance(double scaled_mass) const
     }
 }
 
+void transform_counts_to_common_scale(const vector<double>& scale_factors,
+                                      vector<LocusCountList>& sample_count_table)
+{
+    // Transform raw counts to the common scale
+    for (size_t i = 0; i < sample_count_table.size(); ++i)
+    {
+        LocusCountList& p = sample_count_table[i];
+        for (size_t j = 0; j < p.counts.size(); ++j)
+        {
+            assert (scale_factors.size() > j);
+            p.counts[j] *= (1.0 / scale_factors[j]);
+        }
+    }
+}
+
 void calc_scaling_factors(const vector<LocusCountList>& sample_count_table,
                           vector<double>& scale_factors)
 {
-    vector<double> geom_means(sample_count_table.size(), 0.0);
+    
+    vector<double> log_geom_means(sample_count_table.size(), 0.0);
     
     for (size_t i = 0; i < sample_count_table.size(); ++i)
     {
@@ -184,18 +203,14 @@ void calc_scaling_factors(const vector<LocusCountList>& sample_count_table,
         
         for (size_t j = 0; j < p.counts.size(); ++j)
         {
-            //assert (geom_means.size() > j);
-            if (geom_means[i] > 0  && p.counts[j] > 0)
-            {
-                geom_means[i] *= p.counts[j];
-            }
-            else if (p.counts[j] > 0)
+            //assert (log_geom_means.size() > j);
+            if (p.counts[j] > 0)
             {
-                geom_means[i] = p.counts[j];
+                log_geom_means[i] += (1.0/p.counts.size()) * log(p.counts[j]);
             }
             
         }
-        geom_means[i] = pow(geom_means[i], 1.0/(double)p.counts.size());
+        //log_geom_means[i] = pow(log_geom_means[i], 1.0/(double)p.counts.size());
     }
     
     for (size_t j = 0; j < scale_factors.size(); ++j)
@@ -203,16 +218,16 @@ void calc_scaling_factors(const vector<LocusCountList>& sample_count_table,
         vector<double> tmp_counts;
         for (size_t i = 0; i < sample_count_table.size(); ++i)
         {
-            if (geom_means[i] && !isinf(geom_means[i]) && !isnan(geom_means[i]) && sample_count_table[i].counts[j])
+            if (log_geom_means[i] && !isinf(log_geom_means[i]) && !isnan(log_geom_means[i]) && sample_count_table[i].counts[j])
             {
-                double gm = (double)sample_count_table[i].counts[j] / geom_means[i];
+                double gm = (double)log(sample_count_table[i].counts[j]) - log_geom_means[i];
                 assert (!isinf(gm));
                 tmp_counts.push_back(gm);
             }
         }
         sort(tmp_counts.begin(), tmp_counts.end());
         if (!tmp_counts.empty())
-            scale_factors[j] = tmp_counts[tmp_counts.size()/2];
+            scale_factors[j] = exp(tmp_counts[tmp_counts.size()/2]);
         else
             scale_factors[j] = 1.0;
     }
@@ -223,7 +238,8 @@ static const int min_loci_for_fitting = 30;
 boost::shared_ptr<MassDispersionModel const> 
 fit_dispersion_model_helper(const string& condition_name,
                             const vector<double>& scale_factors,
-                            const vector<LocusCountList>& sample_count_table)
+                            const vector<LocusCountList>& sample_count_table,
+                            bool exclude_zero_samples)
 {
     vector<pair<double, double> > raw_means_and_vars;
     map<string, pair<double, double> > labeled_mv_table;
@@ -236,14 +252,17 @@ fit_dispersion_model_helper(const string& condition_name,
             mean /= p.counts.size();
         
         double var = 0.0;
+        double num_non_zero = 0;
         foreach (double d, p.counts)
         {
+            if (d > 0)
+                num_non_zero++;
             var += (d - mean) * (d - mean);
         }
         if (var > 0.0 && p.counts.size())
             var /= p.counts.size();
         labeled_mv_table[p.locus_desc] = make_pair(mean, var);
-        if (mean > 0 && var > 0.0)
+        if (mean > 0 && var > 0.0 && (!exclude_zero_samples || num_non_zero == p.counts.size()))
         {
             //fprintf(stderr, "%s\t%lg\t%lg\n", p.locus_desc.c_str(), mean, var);
             raw_means_and_vars.push_back(make_pair(mean, var));
@@ -253,7 +272,7 @@ fit_dispersion_model_helper(const string& condition_name,
     if (raw_means_and_vars.size() < min_loci_for_fitting)
     {
         shared_ptr<MassDispersionModel> disperser;
-        disperser = shared_ptr<MassDispersionModel>(new PoissonDispersionModel);
+        disperser = shared_ptr<MassDispersionModel>(new PoissonDispersionModel(condition_name));
         
         for (map<string, pair<double, double> >::iterator itr = labeled_mv_table.begin();
              itr != labeled_mv_table.end();
@@ -321,9 +340,9 @@ fit_dispersion_model_helper(const string& condition_name,
     }
     
     shared_ptr<MassDispersionModel> disperser;
-    disperser = shared_ptr<MassDispersionModel>(new MassDispersionModel(raw_means, raw_variances, fitted_values));
+    disperser = shared_ptr<MassDispersionModel>(new MassDispersionModel(condition_name, raw_means, raw_variances, fitted_values));
     if (poisson_dispersion)
-        disperser = shared_ptr<MassDispersionModel>(new PoissonDispersionModel);
+        disperser = shared_ptr<MassDispersionModel>(new PoissonDispersionModel(condition_name));
     
     for (map<string, pair<double, double> >::iterator itr = labeled_mv_table.begin();
          itr != labeled_mv_table.end();
@@ -342,7 +361,8 @@ fit_dispersion_model_helper(const string& condition_name,
 boost::shared_ptr<MassDispersionModel const> 
 fit_dispersion_model(const string& condition_name,
                      const vector<double>& scale_factors,
-                     const vector<LocusCountList>& sample_count_table)
+                     const vector<LocusCountList>& sample_count_table,
+                     bool exclude_zero_samples)
 {
 //    
 //#if ENABLE_THREADS
@@ -353,7 +373,7 @@ fit_dispersion_model(const string& condition_name,
         if (sample_count_table[i].counts.size() <= 1)
         {
             // only one replicate - no point in fitting variance
-            return shared_ptr<MassDispersionModel const>(new PoissonDispersionModel);
+            return shared_ptr<MassDispersionModel const>(new PoissonDispersionModel(condition_name));
         }
     }
 #if ENABLE_THREADS
@@ -393,7 +413,7 @@ fit_dispersion_model(const string& condition_name,
         }
         else
         {
-            model = fit_dispersion_model_helper(condition_name, scale_factors, sample_count_table);
+            model = fit_dispersion_model_helper(condition_name, scale_factors, sample_count_table, exclude_zero_samples);
         }
         disp_models[i] = model;
     }
diff --git a/src/replicates.h b/src/replicates.h
index ca4484f..21884a1 100644
--- a/src/replicates.h
+++ b/src/replicates.h
@@ -16,10 +16,12 @@ class MassDispersionModel
 {
 public:
     MassDispersionModel() {}
-    MassDispersionModel(const std::vector<double>& scaled_mass_means, 
+    MassDispersionModel(const std::string& name,
+                        const std::vector<double>& scaled_mass_means, 
                         const std::vector<double>& scaled_raw_variances,
                         const std::vector<double>& scaled_mass_variances);
 
+    virtual const std::string& name() const { return _name; }
     
     virtual double scale_mass_variance(double scaled_mass) const;
     
@@ -45,6 +47,7 @@ public:
     }
     
 private:
+    std::string         _name;
     std::vector<double> _scaled_mass_means;
     std::vector<double> _scaled_raw_variances;
     std::vector<double> _scaled_mass_variances;
@@ -54,8 +57,12 @@ private:
 
 class PoissonDispersionModel : public MassDispersionModel
 {
-public:
+    std::string         _name;
     
+public:
+    PoissonDispersionModel(const std::string& name) : _name(name) {}
+        
+        virtual const std::string& name() const { return _name; }
     virtual double scale_mass_variance(double scaled_mass) const 
     { 
         return scaled_mass; 
@@ -71,6 +78,9 @@ struct LocusCountList
     int num_transcripts;
 };
 
+void transform_counts_to_common_scale(const vector<double>& scale_factors,
+                                      vector<LocusCountList>& sample_count_table);
+
 void calc_scaling_factors(const std::vector<LocusCountList>& sample_count_table,
                           std::vector<double>& scale_factors);
 
@@ -78,7 +88,8 @@ void calc_scaling_factors(const std::vector<LocusCountList>& sample_count_table,
 boost::shared_ptr<MassDispersionModel const> 
 fit_dispersion_model(const string& condition_name,
                      const std::vector<double>& scale_factors,
-                     const std::vector<LocusCountList>& sample_count_table);
+                     const std::vector<LocusCountList>& sample_count_table,
+                     bool exclude_zero_samples);
 
 // This factory merges bundles in a requested locus from several replicates
 class ReplicatedBundleFactory
@@ -180,7 +191,7 @@ public:
             BadIntronTable bad_introns;
             
             vector<LocusCount> count_table;
-            inspect_map(*fac, NULL, count_table, false);
+            inspect_map(*fac, NULL, count_table, false, false);
             
             shared_ptr<ReadGroupProperties> rg_props = fac->read_group_properties();
             
@@ -205,6 +216,9 @@ public:
                     sample_count_table[i].counts[fac_idx] = raw_count;
                 }
             }
+            
+            rg_props->raw_counts(count_table);
+            
             sample_masses.push_back(rg_props->total_map_mass());
 			min_len = min(min_len, rg_props->frag_len_dist()->min());
 			max_len = max(max_len, rg_props->frag_len_dist()->max());
@@ -218,33 +232,62 @@ public:
         {
             shared_ptr<ReadGroupProperties> rg_props = _factories[i]->read_group_properties();
             assert (scale_factors[i] != 0);
-            rg_props->mass_scale_factor(scale_factors[i]);
+            rg_props->internal_scale_factor(scale_factors[i]);
         }
         
-        // Transform raw counts to the common scale
-        for (size_t i = 0; i < sample_count_table.size(); ++i)
+        transform_counts_to_common_scale(scale_factors, sample_count_table);
+        for (size_t fac_idx = 0; fac_idx < _factories.size(); ++fac_idx)
         {
-            LocusCountList& p = sample_count_table[i];
-            for (size_t j = 0; j < p.counts.size(); ++j)
+            shared_ptr<ReadGroupProperties> rg_props = _factories[fac_idx]->read_group_properties();
+            assert (scale_factors[fac_idx] != 0);
+            vector<LocusCount> common_scaled_counts;
+            for (size_t j = 0; j < sample_count_table.size(); ++j)
             {
-                assert (scale_factors.size() > j);
-                p.counts[j] *= (1.0 / scale_factors[j]);
+                common_scaled_counts.push_back(LocusCount(sample_count_table[j].locus_desc, sample_count_table[j].counts[fac_idx], sample_count_table[j].num_transcripts));
             }
+            rg_props->common_scale_counts(common_scaled_counts);
         }
+        fit_dispersion_model();
+    }
+
+    void fit_dispersion_model()
+    {
+        vector<LocusCountList> sample_count_table;
+        vector<double> scale_factors;
         
-        for (size_t i = 0; i < _factories.size(); ++i)
+        for (size_t fac_idx = 0; fac_idx < _factories.size(); ++fac_idx)
         {
-            shared_ptr<ReadGroupProperties> rg_props = _factories[i]->read_group_properties();
-            vector<LocusCount> scaled_counts;
-            for (size_t j = 0; j < sample_count_table.size(); ++j)
+            shared_ptr<BundleFactory> fac = _factories[fac_idx];        
+            
+            shared_ptr<ReadGroupProperties> rg_props = fac->read_group_properties();
+            const vector<LocusCount>& count_table = rg_props->common_scale_counts();
+            
+            for (size_t i = 0; i < count_table.size(); ++i)
             {
-                scaled_counts.push_back(LocusCount(sample_count_table[j].locus_desc, sample_count_table[j].counts[i], sample_count_table[j].num_transcripts));
+                const LocusCount& c = count_table[i];
+                double common_scale_count = c.count;
+                
+                if (i >= sample_count_table.size())
+                {
+                    LocusCountList locus_count(c.locus_desc, _factories.size(), c.num_transcripts); 
+                    sample_count_table.push_back(locus_count);
+                    sample_count_table.back().counts[0] = common_scale_count;
+                }
+                else
+                {
+                    if (sample_count_table[i].locus_desc != c.locus_desc)
+                    {
+                        fprintf (stderr, "Error: bundle boundaries don't match across replicates!\n");
+                        exit(1);
+                    }
+                    sample_count_table[i].counts[fac_idx] = common_scale_count;
+                }
             }
-            rg_props->common_scale_counts(scaled_counts);
+            scale_factors.push_back(rg_props->internal_scale_factor());
         }
         
         shared_ptr<MassDispersionModel const> disperser;
-        disperser = fit_dispersion_model(_condition_name,scale_factors, sample_count_table);
+        disperser = ::fit_dispersion_model(_condition_name,scale_factors, sample_count_table, false);
         
         foreach (shared_ptr<BundleFactory> fac, _factories)
         {
@@ -253,6 +296,7 @@ public:
         }
     }
     
+    
     // This function NEEDS to deep copy the ref_mRNAs, otherwise cuffdiff'd
     // samples will clobber each other
     void set_ref_rnas(const vector<shared_ptr<Scaffold> >& mRNAs)
diff --git a/src/rounding.h b/src/rounding.h
new file mode 100644
index 0000000..ca92912
--- /dev/null
+++ b/src/rounding.h
@@ -0,0 +1,214 @@
+// rounding-algorithms.hpp
+//
+// General Rounding Algorithms
+// Copyright (c) 2008 Michael Thomas Greer
+// Boost Software License - Version 1.0 - August 17th, 2003
+//
+// Permission is hereby granted, free of charge, to any person or organization
+// obtaining a copy of the software and accompanying documentation covered by
+// this license (the "Software") to use, reproduce, display, distribute,
+// execute, and transmit the Software, and to prepare derivative works of the
+// Software, and to permit third-parties to whom the Software is furnished to
+// do so, all subject to the following:
+//
+// The copyright notices in the Software and this entire statement, including
+// the above license grant, this restriction and the following disclaimer,
+// must be included in all copies of the Software, in whole or in part, and
+// all derivative works of the Software, unless such copies or derivative
+// works are solely in the form of machine-executable object code generated by
+// a source language processor.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+//
+//----------------------------------------------------------------------------
+// Reference
+// <http://www.pldesignline.com/howto/showArticle.jhtml;?articleID=175801189>
+//
+//----------------------------------------------------------------------------
+// In this library, symmetric functions are indicated by a zero at the end
+// of the function name.
+//
+// If you want a different default epsilon make sure to change
+//
+//   #define ROUNDING_EPSILON 0.001
+//
+// to whatever you want it to be. (I wanted to make it so that you could 
+// define a different default epsilon each time you #included the file, but
+// I haven't figured out how to get around the template restrictions yet.)
+//
+
+#ifndef ROUNDING_ALGORITHMS_HPP
+#define ROUNDING_ALGORITHMS_HPP
+
+#ifndef ROUNDING_EPSILON
+#define ROUNDING_EPSILON 0.0000001
+#endif
+
+#include <cmath>
+#include <cstdlib>
+#include <ciso646>
+
+namespace rounding
+{
+    
+    //--------------------------------------------------------------------------
+    // round down
+    // Bias: -Infinity
+    using std::floor;
+    
+    //--------------------------------------------------------------------------
+    // round up
+    // Bias: +Infinity
+    using std::ceil;
+    
+    //--------------------------------------------------------------------------
+    // symmetric round down
+    // Bias: towards zero
+    template <typename FloatType>
+    FloatType floor0( const FloatType& value )
+    {
+        FloatType result = std::floor( std::fabs( value ) );
+        return (value < 0.0) ? -result : result;
+    }
+    
+    //--------------------------------------------------------------------------
+    // A common alias for floor0()
+    // (notwithstanding hardware quirks)
+    template <typename FloatType>
+    inline
+    FloatType trunc( const FloatType& value )
+    {
+        return floor0( value );
+    }
+    
+    //--------------------------------------------------------------------------
+    // symmetric round up
+    // Bias: away from zero
+    template <typename FloatType>
+    FloatType ceil0( const FloatType& value )
+    {
+        FloatType result = std::ceil( std::fabs( value ) );
+        return (value < 0.0) ? -result : result;
+    }
+    
+    //--------------------------------------------------------------------------
+    // Common rounding: round half up
+    // Bias: +Infinity
+    template <typename FloatType>
+    FloatType roundhalfup( const FloatType& value )
+    {
+        return std::floor( value +0.5 );
+    }
+    
+    //--------------------------------------------------------------------------
+    // Round half down
+    // Bias: -Infinity
+    template <typename FloatType>
+    FloatType roundhalfdown( const FloatType& value )
+    {
+        return std::ceil( value -0.5 );
+    }
+    
+    //--------------------------------------------------------------------------
+    // symmetric round half down
+    // Bias: towards zero
+    template <typename FloatType>
+    FloatType roundhalfdown0( const FloatType& value )
+    {
+        FloatType result = roundhalfdown( std::fabs( value ) );
+        return (value < 0.0) ? -result : result;
+    }
+    
+    //--------------------------------------------------------------------------
+    // symmetric round half up
+    // Bias: away from zero
+    template <typename FloatType>
+    FloatType roundhalfup0( const FloatType& value )
+    {
+        FloatType result = roundhalfup( std::fabs( value ) );
+        return (value < 0.0) ? -result : result;
+    }
+    
+    //--------------------------------------------------------------------------
+    // round half even (banker's rounding)
+    // Bias: none
+    template <typename FloatType>
+    FloatType roundhalfeven(
+                            const FloatType& value,
+                            const FloatType& epsilon = ROUNDING_EPSILON
+                            ) {
+        if (value < 0.0) return -roundhalfeven <FloatType> ( -value, epsilon );
+        
+        FloatType ipart;
+        std::modf( value, &ipart );
+        
+        // If 'value' is exctly halfway between two integers
+        if ((value -(ipart +0.5)) < epsilon)
+        {
+            // If 'ipart' is even then return 'ipart'
+            if (std::fmod( ipart, 2.0 ) < epsilon)
+                return ipart;
+            
+            // Else return the nearest even integer
+            return ceil0( ipart +0.5 );
+        }
+        
+        // Otherwise use the usual round to closest
+        // (Either symmetric half-up or half-down will do0
+        return roundhalfup0( value );
+    }
+    
+    //--------------------------------------------------------------------------
+    // round alternate
+    // Bias: none for sequential calls
+    bool _is_up = false;
+    template <typename FloatType>
+    FloatType roundalternate( const FloatType& value, int& is_up = _is_up )
+    {
+        if ((is_up != is_up))
+            return roundhalfup( value );
+        return roundhalfdown( value );
+    }
+    
+    //--------------------------------------------------------------------------
+    // symmetric round alternate
+    // Bias: none for sequential calls
+    template <typename FloatType>
+    FloatType roundalternate0( const FloatType& value, int& is_up = _is_up )
+    {
+        if ((is_up != is_up))
+            return roundhalfup0( value );
+        return roundhalfdown0( value );
+    }
+    
+    //--------------------------------------------------------------------------
+    // round random
+    // Bias: generator's bias
+    template <typename FloatType, typename RandValue, typename RandomGenerator>
+    FloatType roundrandom(
+                          const FloatType& value,
+                          const RandValue& mid,
+                          RandomGenerator& g
+                          ) {
+        if (g() < mid)
+            return roundhalfup0( value );
+        return roundhalfdown0( value );
+    }
+    
+    //--------------------------------------------------------------------------
+    // default round random
+    // Bias: rand()
+    template <typename FloatType>
+    FloatType roundrandom( const FloatType& value )
+    {
+        return roundrandom <FloatType, int, int(*)()> ( value, RAND_MAX /2, &rand );
+    }
+}
+
+#endif 
diff --git a/src/sampling.cpp b/src/sampling.cpp
index 490cd49..2a89dad 100644
--- a/src/sampling.cpp
+++ b/src/sampling.cpp
@@ -12,34 +12,40 @@
 using namespace std;
 
 void generate_importance_samples(multinormal_generator<double>& generator,
-                                 std::vector<boost::numeric::ublas::vector<double> >& samples, 
+                                 std::vector<Eigen::VectorXd>& samples, 
                                  int num_samples,
                                  bool no_zeros)
 {
 	for (int i = 0; i < num_samples; ++i)
 	{
+        // TODO: we should switch the multinormal generator over to Eigen for
+        // consistency as part of the push to drop uBLAS.
 		boost::numeric::ublas::vector<double> r = generator.next_rand();
         
-		boost::numeric::ublas::vector<double> scaled_sample = r;
+        Eigen::VectorXd scaled_sample = Eigen::VectorXd::Zero(r.size());
 		
-		for (size_t j = 0; j < scaled_sample.size(); ++j) {
-            //			if (scaled_sample(j) < 0)
-            //				scaled_sample(j) = 1e-10;
+		for (int j = 0; j < scaled_sample.size(); ++j) 
+        {
+            scaled_sample(j) = r(j);
+            
             if (scaled_sample(j) < 0)
-                scaled_sample(j) = -scaled_sample(j);
+            {
+                scaled_sample(j) = 0.0;
+                //scaled_sample(j) = -scaled_sample(j);
+            }
 		}
 		
-		double m = sum(scaled_sample);
+		double m = scaled_sample.sum();
 		if (m && !isnan(m))
 		{
-			for (size_t j = 0; j < scaled_sample.size(); ++j) 
+			for (int j = 0; j < scaled_sample.size(); ++j) 
             {
 				scaled_sample(j) = scaled_sample(j) / m;
 			}
 			if (no_zeros)
             {
                 bool has_zero = false;
-                for (size_t j = 0; j < scaled_sample.size(); ++j)
+                for (int j = 0; j < scaled_sample.size(); ++j)
                 {
                     if (scaled_sample[j] == 0)
                     {
@@ -55,7 +61,7 @@ void generate_importance_samples(multinormal_generator<double>& generator,
 		}
 		else
 		{
-            samples.push_back(boost::numeric::ublas::zero_vector<double>(scaled_sample.size()));
+            samples.push_back(Eigen::VectorXd::Zero(scaled_sample.size()));
 			//cerr << r << endl;
 			//cerr << scaled_sample << endl;
 		}
diff --git a/src/sampling.h b/src/sampling.h
index 8616877..d430a34 100644
--- a/src/sampling.h
+++ b/src/sampling.h
@@ -16,6 +16,7 @@
 
 #include <stdint.h>
 #include <vector>
+#include <iostream>
 #include <boost/numeric/ublas/matrix.hpp>
 #include <boost/numeric/ublas/vector.hpp>
 
@@ -34,6 +35,8 @@
 #include <boost/random/variate_generator.hpp>
 #include <boost/math/constants/constants.hpp>
 
+#include <Eigen/Dense>
+
 // Boost Cholesky factorizations in the spirit of lu.hpp
 // Written by Robbie Vogt, found at: 
 // http://lists.boost.org/MailArchives/ublas/2005/07/0568.php
@@ -62,6 +65,17 @@ namespace boost { namespace numeric { namespace ublas {
 				
 				if (i == j) {
 					if (elem <= 0.0) {
+//                        std::cerr << "intermediate: " << std::endl;
+//                        for (unsigned k = 0; k < m.size1 (); ++k) 
+//                        {
+//                            ublas::matrix_row<ublas::matrix<double> > mr (m, k);
+//                            std::cerr << k << " : " << mr << std::endl;
+//                        }
+//                        std::cerr << "======" << std::endl;
+//                        std::cerr << i << " , " << j << " = " << m(i,j) << std::endl; 
+//                        std::cerr << project(mri,range(0,i)) << std::endl;
+//                        std::cerr << project(mrj,range(0,i)) << std::endl;
+//                        std::cerr << inner_prod(project(mri,range(0,i)), project(mrj,range(0,i))) << std::endl;
 						// matrix after rounding errors is not positive definite
 						return elem;
 					}
@@ -286,7 +300,7 @@ float_type log_space_add(float_type log_p, float_type log_q)
 }
 
 void generate_importance_samples(multinormal_generator<double>& generator,
-                                 std::vector<boost::numeric::ublas::vector<double> >& samples, 
+                                 std::vector<Eigen::VectorXd>& samples, 
                                  int num_samples,
                                  bool no_zeros = true);
 
diff --git a/src/scaffolds.cpp b/src/scaffolds.cpp
index 096f58a..92ffbd4 100644
--- a/src/scaffolds.cpp
+++ b/src/scaffolds.cpp
@@ -832,6 +832,9 @@ void Scaffold::fill_gaps(int filled_gap_size)
 {
 	OpList ops;
 	
+    if (filled_gap_size <= 0)
+        return;
+    
 	const vector<AugmentedCuffOp>& orig_ops = augmented_ops();
 	for (size_t i = 0; i < orig_ops.size(); ++i)
 	{

-- 
Transcript assembly, differential expression, and differential regulation for RNA-Seq.



More information about the debian-med-commit mailing list