[pynac] 01/01: Imported Upstream version 0.4.1

Julien Puydt julien.puydt at laposte.net
Mon Jun 15 18:38:24 UTC 2015


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

jpuydt-guest pushed a commit to annotated tag upstream/0.4.1
in repository pynac.

commit bec9f19e9df7b7efe0e672f0fe84eaa0dc8ecf97
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Mon Jun 15 20:29:27 2015 +0200

    Imported Upstream version 0.4.1
---
 configure.ac                   |    2 +-
 ginac/Makefile.am              |   17 +-
 ginac/add.cpp                  |  191 ++---
 ginac/add.h                    |    2 +-
 ginac/archive.cpp              |  101 +--
 ginac/basic.cpp                |   55 +-
 ginac/class_info.h             |   12 +-
 ginac/clifford.cpp             |   27 +-
 ginac/color.cpp                |  647 --------------
 ginac/color.h                  |  194 -----
 ginac/container.h              |   71 +-
 ginac/excompiler.h             |  128 ---
 ginac/expairseq.cpp            |  192 ++---
 ginac/fderivative.cpp          |   23 +-
 ginac/function.cpp             |   60 +-
 ginac/function.h               |    1 +
 ginac/ginac.h                  |    3 -
 ginac/hash_map.h               |  597 -------------
 ginac/indexed.cpp              |   18 +-
 ginac/infinity.cpp             |    9 +-
 ginac/inifcns.cpp              |   68 +-
 ginac/inifcns_nstdsums.cpp     |  139 +--
 ginac/input_lexer.cc           | 1824 ----------------------------------------
 ginac/input_lexer.h            |   69 --
 ginac/input_lexer.ll           |  211 -----
 ginac/matrix.cpp               |   98 +--
 ginac/mul.cpp                  |  376 ++++-----
 ginac/mul.h                    |    2 +-
 ginac/ncmul.cpp                |   59 +-
 ginac/normal.cpp               |   67 +-
 ginac/numeric.cpp              |   54 +-
 ginac/numeric.h                |    1 +
 ginac/operators.cpp            |    3 +-
 ginac/order.cpp                |   12 +-
 ginac/order.h                  |    3 +-
 ginac/power.cpp                |  145 ++--
 ginac/pseries.cpp              |  188 ++---
 ginac/registrar.h              |    6 +-
 ginac/relational.cpp           |    2 +-
 ginac/structure.h              |  266 ------
 ginac/symbol.cpp               |   60 +-
 ginac/symbol.h                 |    3 +-
 ginac/symmetry.cpp             |    1 -
 ginac/tensor.cpp               |    3 +-
 ginac/utils.cpp                |    4 +-
 m4/ax_cxx_compile_stdcxx_11.m4 |  165 ++++
 46 files changed, 1102 insertions(+), 5077 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5500e01..5e47c4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@ dnl http://www.freesoftwaremagazine.com/articles/building_shared_libraries_once_
 
 m4_define([ginac_major_version], [0])
 m4_define([ginac_minor_version], [4])
-m4_define([ginac_micro_version], [0])
+m4_define([ginac_micro_version], [1])
 
 m4_define([lt_current], [0])
 m4_define([lt_revision], [0])
diff --git a/ginac/Makefile.am b/ginac/Makefile.am
index 67d308b..a1cc845 100644
--- a/ginac/Makefile.am
+++ b/ginac/Makefile.am
@@ -1,15 +1,15 @@
 ## Process this file with automake to produce Makefile.in
 
 lib_LTLIBRARIES = libpynac.la
-libpynac_la_SOURCES = py_funcs.cpp add.cpp archive.cpp basic.cpp clifford.cpp color.cpp \
+libpynac_la_SOURCES = py_funcs.cpp add.cpp archive.cpp basic.cpp clifford.cpp \
   constant.cpp ex.cpp expair.cpp expairseq.cpp exprseq.cpp \
   fail.cpp fderivative.cpp function.cpp idx.cpp indexed.cpp infinity.cpp inifcns.cpp \
   inifcns_trans.cpp inifcns_gamma.cpp inifcns_nstdsums.cpp \
   integral.cpp lst.cpp matrix.cpp mul.cpp ncmul.cpp normal.cpp numeric.cpp \
   operators.cpp power.cpp registrar.cpp relational.cpp remember.cpp \
   pseries.cpp print.cpp symbol.cpp symmetry.cpp tensor.cpp \
-  utils.cpp wildcard.cpp \
-  remember.h tostring.h utils.h compiler.h order.cpp templates.cpp
+  utils.cpp wildcard.cpp templates.cpp \
+  remember.h tostring.h utils.h compiler.h order.cpp
 
 #The -no-undefined breaks Pynac on OS X 10.4.  See #9135
 if CYGWIN
@@ -17,15 +17,14 @@ libpynac_la_LDFLAGS = -version-info $(LT_VERSION_INFO) -no-undefined
 else
 libpynac_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
 endif
-libpynac_la_CPPFLAGS = $(PYTHON_CPPFLAGS)
+libpynac_la_CPPFLAGS = $(PYTHON_CPPFLAGS) -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wno-unused-parameter
 
 libpynac_la_LIBADD = $(PYTHON_LDFLAGS)
 ginacincludedir = $(includedir)/pynac
 ginacinclude_HEADERS = ginac.h py_funcs.h add.h archive.h assertion.h basic.h class_info.h \
-  clifford.h color.h constant.h infinity.h container.h ex.h expair.h expairseq.h \
-  exprseq.h fail.h fderivative.h flags.h function.h hash_map.h idx.h indexed.h \
+  clifford.h constant.h infinity.h container.h ex.h expair.h expairseq.h \
+  exprseq.h fail.h fderivative.h flags.h function.h idx.h indexed.h \
   inifcns.h integral.h lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h \
-  power.h print.h pseries.h ptr.h registrar.h relational.h structure.h \
-  symbol.h symmetry.h tensor.h version.h wildcard.h order.h \
-  templates.h extern_templates.h
+  power.h print.h pseries.h ptr.h registrar.h relational.h extern_templates.h \
+  symbol.h symmetry.h tensor.h version.h wildcard.h order.h templates.h
 EXTRA_DIST = version.h.in
diff --git a/ginac/add.cpp b/ginac/add.cpp
index db5d951..1c6b6e2 100644
--- a/ginac/add.cpp
+++ b/ginac/add.cpp
@@ -71,11 +71,11 @@ add::add(const ex & lh, const ex & rh)
 	GINAC_ASSERT(is_canonical());
 }
 
-add::add(const exvector & v, bool hold)
+add::add(const exvector & v, bool do_hold)
 {
 	tinfo_key = &add::tinfo_static;
 	overall_coeff = _ex0;
-	construct_from_exvector(v, hold);
+	construct_from_exvector(v, do_hold);
 	GINAC_ASSERT(is_canonical());
 }
 
@@ -95,14 +95,14 @@ add::add(const epvector & v, const ex & oc)
 	GINAC_ASSERT(is_canonical());
 }
 
-add::add(std::unique_ptr<epvector> vp, const ex & oc)
-{
-	tinfo_key = &add::tinfo_static;
-	GINAC_ASSERT(vp.get()!=0);
-	overall_coeff = oc;
-	construct_from_epvector(*vp);
-	GINAC_ASSERT(is_canonical());
-}
+//add::add(std::unique_ptr<epvector> vp, const ex & oc)
+//{
+//	tinfo_key = &add::tinfo_static;
+//	GINAC_ASSERT(vp.get()!=0);
+//	overall_coeff = oc;
+//	construct_from_epvector(*vp);
+//	GINAC_ASSERT(is_canonical());
+//}
 
 //////////
 // archiving
@@ -125,21 +125,19 @@ void add::print_add(const print_context & c, unsigned level, bool latex) const
 			c.s << '(';
 	}
 
-	numeric coeff;
 	bool first = true;
 
 	const epvector & sorted_seq = get_sorted_seq();
 	// Then proceed with the remaining factors
-	auto it = sorted_seq.begin(), itend = sorted_seq.end();
-	while (it != itend) {
+	for (const auto & elem : sorted_seq) {
 		std::stringstream tstream;
-		print_context *tcontext_p;
+		std::unique_ptr<print_context> tcontext_p;
 		if (latex) {
-			tcontext_p = new print_latex(tstream, c.options);
+			tcontext_p.reset(new print_latex(tstream, c.options));
 		} else {
-			tcontext_p = new print_dflt(tstream, c.options);
+			tcontext_p.reset(new print_dflt(tstream, c.options));
 		}
-		mul(it->rest,it->coeff).print(*tcontext_p, precedence());
+		mul(elem.rest, elem.coeff).print(*tcontext_p, precedence());
 
 		if (!first) {
 			if (tstream.peek() == '-') {
@@ -151,19 +149,17 @@ void add::print_add(const print_context & c, unsigned level, bool latex) const
 			first = false;
 		}
 		tstream.get(*(c.s.rdbuf()));
-		delete tcontext_p;
-		++it;
 	}
 
 	// Finally print the "overall" numeric coefficient, if present.
 	// This is just the constant coefficient. 
 	if (!(ex_to<numeric>(overall_coeff)).is_zero()) {
 		std::stringstream tstream;
-		print_context *tcontext_p;
+		std::unique_ptr<print_context> tcontext_p;
 		if (latex) {
-			tcontext_p = new print_latex(tstream, c.options);
+			tcontext_p.reset(new print_latex(tstream, c.options));
 		} else {
-			tcontext_p = new print_dflt(tstream, c.options);
+			tcontext_p.reset(new print_dflt(tstream, c.options));
 		}
 		overall_coeff.print(*tcontext_p, 0);
 		if (!first) {
@@ -175,7 +171,6 @@ void add::print_add(const print_context & c, unsigned level, bool latex) const
 		}
 
 		tstream.get(*(c.s.rdbuf()));
-		delete tcontext_p;
 	}
 
 	if (precedence() <= level) {
@@ -202,30 +197,28 @@ void add::do_print_csrc(const print_csrc & c, unsigned level) const
 		c.s << "(";
 	
 	// Print arguments, separated by "+" or "-"
-	auto it = seq.begin(), itend = seq.end();
 	char separator = ' ';
-	while (it != itend) {
+        for (const auto & elem : seq) {
 		
 		// If the coefficient is negative, separator is "-"
-		if (it->coeff.is_equal(_ex_1) || 
-			ex_to<numeric>(it->coeff).numer().is_equal(*_num_1_p))
+		if (elem.coeff.is_equal(_ex_1) || 
+			ex_to<numeric>(elem.coeff).numer().is_equal(*_num_1_p))
 			separator = '-';
 		c.s << separator;
-		if (it->coeff.is_equal(_ex1) || it->coeff.is_equal(_ex_1)) {
-			it->rest.print(c, precedence());
-		} else if (ex_to<numeric>(it->coeff).numer().is_equal(*_num1_p) ||
-				 ex_to<numeric>(it->coeff).numer().is_equal(*_num_1_p))
+		if (elem.coeff.is_equal(_ex1) || elem.coeff.is_equal(_ex_1)) {
+			elem.rest.print(c, precedence());
+		} else if (ex_to<numeric>(elem.coeff).numer().is_equal(*_num1_p) ||
+				 ex_to<numeric>(elem.coeff).numer().is_equal(*_num_1_p))
 		{
-			it->rest.print(c, precedence());
+			elem.rest.print(c, precedence());
 			c.s << '/';
-			ex_to<numeric>(it->coeff).denom().print(c, precedence());
+			ex_to<numeric>(elem.coeff).denom().print(c, precedence());
 		} else {
-			it->coeff.print(c, precedence());
+			elem.coeff.print(c, precedence());
 			c.s << '*';
-			it->rest.print(c, precedence());
+			elem.rest.print(c, precedence());
 		}
 		
-		++it;
 		separator = '+';
 	}
 	
@@ -240,7 +233,7 @@ void add::do_print_csrc(const print_csrc & c, unsigned level) const
 		c.s << ")";
 }
 
-void add::do_print_python_repr(const print_python_repr & c, unsigned level) const
+void add::do_print_python_repr(const print_python_repr & c, unsigned) const
 {
 	c.s << class_name() << '(';
 	op(0).print(c);
@@ -270,22 +263,18 @@ bool add::info(unsigned inf) const
 		case info_flags::even:
 		case info_flags::crational_polynomial:
 		case info_flags::rational_function: {
-			auto i = seq.begin(), end = seq.end();
-			while (i != end) {
-				if (!(recombine_pair_to_ex(*i).info(inf)))
+			for (const auto & elem : seq) {
+				if (!(recombine_pair_to_ex(elem).info(inf)))
 					return false;
-				++i;
 			}
 			if (overall_coeff.is_zero() && (inf == info_flags::positive || inf == info_flags::posint))
-				return true;
-			return overall_coeff.info(inf);
+                                return true;
+                        return overall_coeff.info(inf);
 		}
 		case info_flags::algebraic: {
-			auto i = seq.begin(), end = seq.end();
-			while (i != end) {
-				if ((recombine_pair_to_ex(*i).info(inf)))
+                        for (const auto & elem : seq) {
+				if ((recombine_pair_to_ex(elem).info(inf)))
 					return true;
-				++i;
 			}
 			return false;
 		}
@@ -310,12 +299,10 @@ int add::degree(const ex & s) const
 		deg = 0;
 	
 	// Find maximum of degrees of individual terms
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		int cur_deg = i->rest.degree(s);
+        for (const auto & elem : seq) {
+		int cur_deg = elem.rest.degree(s);
 		if (cur_deg > deg)
 			deg = cur_deg;
-		++i;
 	}
 	return deg;
 }
@@ -327,43 +314,39 @@ int add::ldegree(const ex & s) const
 		deg = 0;
 	
 	// Find minimum of degrees of individual terms
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		int cur_deg = i->rest.ldegree(s);
+        for (const auto & elem : seq) {
+		int cur_deg = elem.rest.ldegree(s);
 		if (cur_deg < deg)
 			deg = cur_deg;
-		++i;
 	}
 	return deg;
 }
 
 ex add::coeff(const ex & s, int n) const
 {
-	std::unique_ptr<epvector> coeffseq(new epvector);
-	std::unique_ptr<epvector> coeffseq_cliff(new epvector);
+	epvector coeffseq;
+	epvector coeffseq_cliff;
 	int rl = clifford_max_label(s);
 	bool do_clifford = (rl != -1);
 	bool nonscalar = false;
 
 	// Calculate sum of coefficients in each term
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		ex restcoeff = i->rest.coeff(s, n);
+        for (const auto & elem : seq) {
+		ex restcoeff = elem.rest.coeff(s, n);
  		if (!restcoeff.is_zero()) {
  			if (do_clifford) {
  				if (clifford_max_label(restcoeff) == -1) {
- 					coeffseq_cliff->push_back(combine_ex_with_coeff_to_pair(ncmul(restcoeff, dirac_ONE(rl)), i->coeff));
+ 					coeffseq_cliff.push_back(combine_ex_with_coeff_to_pair(ncmul(restcoeff, dirac_ONE(rl)), elem.coeff));
 				} else {
- 					coeffseq_cliff->push_back(combine_ex_with_coeff_to_pair(restcoeff, i->coeff));
+ 					coeffseq_cliff.push_back(combine_ex_with_coeff_to_pair(restcoeff, elem.coeff));
 					nonscalar = true;
  				}
 			}
-			coeffseq->push_back(combine_ex_with_coeff_to_pair(restcoeff, i->coeff));
+			coeffseq.push_back(combine_ex_with_coeff_to_pair(restcoeff, elem.coeff));
 		}
-		++i;
 	}
 
-	return (new add(std::move(nonscalar ? coeffseq_cliff : coeffseq),
+	return (new add(nonscalar ? coeffseq_cliff : coeffseq,
 	                n==0 ? overall_coeff : _ex0))->setflag(status_flags::dynallocated);
 }
 
@@ -379,18 +362,16 @@ ex add::eval(int level) const
 	std::unique_ptr<epvector> evaled_seqp = evalchildren(level);
 	if (evaled_seqp.get()) {
 		// do more evaluation later
-		return (new add(std::move(evaled_seqp), overall_coeff))->
+		return (new add(*evaled_seqp, overall_coeff))->
 		       setflag(status_flags::dynallocated);
 	}
 	
 #ifdef DO_GINAC_ASSERT
-	epvector::const_iterator i = seq.begin(), end = seq.end();
-	while (i != end) {
-		GINAC_ASSERT(!is_exactly_a<add>(i->rest));
-		if (is_exactly_a<numeric>(i->rest))
+        for (const auto & elem : seq) {
+		GINAC_ASSERT(!is_exactly_a<add>(elem.rest));
+		if (is_exactly_a<numeric>(elem.rest))
 			dbgprint();
-		GINAC_ASSERT(!is_exactly_a<numeric>(i->rest));
-		++i;
+		GINAC_ASSERT(!is_exactly_a<numeric>(elem.rest));
 	}
 #endif // def DO_GINAC_ASSERT
 	
@@ -401,9 +382,9 @@ ex add::eval(int level) const
 	}
 		
 	// handle infinity
-	for (auto i = seq.begin(); i != seq.end(); i++)
-		if (unlikely(is_exactly_a<infinity>(i->rest)))
-			return eval_infinity(i);
+        for (auto i = seq.begin(); i != seq.end(); i++)
+                if (unlikely(is_exactly_a<infinity>(i->rest)))
+                        return eval_infinity(i);
 
 	/** Perform automatic term rewriting rules */
 	int seq_size = seq.size();
@@ -420,19 +401,19 @@ ex add::eval(int level) const
 	// if any terms in the sum still are purely numeric, then they are more
 	// appropriately collected into the overall coefficient
 	int terms_to_collect = 0;
-	for (auto j = seq.begin(); j != seq.end(); j++)
-		if (unlikely(is_a<numeric>(j->rest)))
+	for (const auto & elem : seq)
+		if (unlikely(is_a<numeric>(elem.rest)))
 			++terms_to_collect;
 	if (terms_to_collect) {
-		std::unique_ptr<epvector> s(new epvector);
-		s->reserve(seq_size - terms_to_collect);
+                epvector s;
+		s.reserve(seq_size - terms_to_collect);
 		numeric oc = *_num0_p;
-		for (auto j = seq.begin(); j != seq.end(); j++)
-			if (unlikely(is_a<numeric>(j->rest)))
-				oc = oc.add((ex_to<numeric>(j->rest)).mul(ex_to<numeric>(j->coeff)));
+                for (const auto & elem : seq)
+			if (unlikely(is_a<numeric>(elem.rest)))
+				oc = oc.add((ex_to<numeric>(elem.rest)).mul(ex_to<numeric>(elem.coeff)));
 			else
-				s->push_back(*j);
-		return (new add(std::move(s), ex_to<numeric>(overall_coeff).add_dyn(oc)))
+				s.push_back(elem);
+		return (new add(s, ex_to<numeric>(overall_coeff).add_dyn(oc)))
 		        ->setflag(status_flags::dynallocated);
 	}
 
@@ -472,17 +453,16 @@ ex add::evalm() const
 {
 	// Evaluate children first and add up all matrices. Stop if there's one
 	// term that is not a matrix.
-	std::unique_ptr<epvector> s(new epvector);
-	s->reserve(seq.size());
+	epvector s;
+	s.reserve(seq.size());
 
 	bool all_matrices = true;
 	bool first_term = true;
 	matrix sum;
 
-	auto it = seq.begin(), itend = seq.end();
-	while (it != itend) {
-		const ex &m = recombine_pair_to_ex(*it).evalm();
-		s->push_back(split_ex_to_pair(m));
+	for (const auto & elem : seq) {
+		const ex &m = recombine_pair_to_ex(elem).evalm();
+		s.push_back(split_ex_to_pair(m));
 		if (is_a<matrix>(m)) {
 			if (first_term) {
 				sum = ex_to<matrix>(m);
@@ -491,18 +471,17 @@ ex add::evalm() const
 				sum = sum.add(ex_to<matrix>(m));
 		} else
 			all_matrices = false;
-		++it;
 	}
 
 	if (all_matrices)
 		return sum + overall_coeff;
 	else
-		return (new add(std::move(s), overall_coeff))->setflag(status_flags::dynallocated);
+		return (new add(s, overall_coeff))->setflag(status_flags::dynallocated);
 }
 
 ex add::conjugate() const
 {
-	exvector *v = nullptr;
+	std::unique_ptr<exvector> v(nullptr);
 	for (size_t i=0; i<nops(); ++i) {
 		if (v) {
 			v->push_back(op(i).conjugate());
@@ -512,7 +491,7 @@ ex add::conjugate() const
 		ex ccterm = term.conjugate();
 		if (are_ex_trivially_equal(term, ccterm))
 			continue;
-		v = new exvector;
+		v.reset(new exvector);
 		v->reserve(nops());
 		for (size_t j=0; j<i; ++j)
 			v->push_back(op(j));
@@ -520,7 +499,6 @@ ex add::conjugate() const
 	}
 	if (v) {
 		ex result = add(*v);
-		delete v;
 		return result;
 	}
 	return *this;
@@ -576,18 +554,15 @@ ex add::eval_ncmul(const exvector & v) const
  *  @see ex::diff */
 ex add::derivative(const symbol & y) const
 {
-	std::unique_ptr<epvector> s(new epvector);
-	s->reserve(seq.size());
+	epvector s;
+	s.reserve(seq.size());
 	
 	// Only differentiate the "rest" parts of the expairs. This is faster
 	// than the default implementation in basic::derivative() although
 	// if performs the same function (differentiate each term).
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		s->push_back(combine_ex_with_coeff_to_pair(i->rest.diff(y), i->coeff));
-		++i;
-	}
-	return (new add(std::move(s), _ex0))->setflag(status_flags::dynallocated);
+	for (const auto & elem : seq)
+		s.push_back(combine_ex_with_coeff_to_pair(elem.rest.diff(y), elem.coeff));
+	return (new add(s, _ex0))->setflag(status_flags::dynallocated);
 }
 
 int add::compare_same_type(const basic & other) const
@@ -612,15 +587,15 @@ tinfo_t add::return_type_tinfo() const
 }
 
 // Note: do_index_renaming is ignored because it makes no sense for an add.
-ex add::thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming) const
+ex add::thisexpairseq(const epvector & v, const ex & oc, bool) const
 {
 	return (new add(v,oc))->setflag(status_flags::dynallocated);
 }
 
-// Note: do_index_renaming is ignored because it makes no sense for an add.
-ex add::thisexpairseq(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming) const
+//// Note: do_index_renaming is ignored because it makes no sense for an add.
+ex add::thisexpairseq(std::unique_ptr<epvector> vp, const ex & oc, bool) const
 {
-	return (new add(std::move(vp),oc))->setflag(status_flags::dynallocated);
+	return (new add(*vp,oc))->setflag(status_flags::dynallocated);
 }
 
 expair add::split_ex_to_pair(const ex & e) const
@@ -694,7 +669,7 @@ ex add::expand(unsigned options) const
 		return (options == 0) ? setflag(status_flags::expanded) : *this;
 	}
 
-	return (new add(std::move(vp), overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
+	return (new add(*vp, overall_coeff))->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
 }
 
 const epvector & add::get_sorted_seq() const
diff --git a/ginac/add.h b/ginac/add.h
index dc40dcc..095e34a 100644
--- a/ginac/add.h
+++ b/ginac/add.h
@@ -41,7 +41,7 @@ public:
 	add(const exvector & v, bool hold=false);
 	add(const epvector & v);
 	add(const epvector & v, const ex & oc);
-	add(std::unique_ptr<epvector> vp, const ex & oc);
+//	add(std::unique_ptr<epvector> vp, const ex & oc);
 	
 	// functions overriding virtual functions from base classes
 public:
diff --git a/ginac/archive.cpp b/ginac/archive.cpp
index d044556..5a21e85 100644
--- a/ginac/archive.cpp
+++ b/ginac/archive.cpp
@@ -83,18 +83,14 @@ ex archive::unarchive_ex(const lst &sym_lst, const char *name) const
 	// Find root node
 	std::string name_string = name;
 	archive_atom id = atomize(name_string);
-	auto i = exprs.begin(), iend = exprs.end();
-	while (i != iend) {
-		if (i->name == id)
-			goto found;
-		i++;
+        for (const auto & elem : exprs) {
+		if (elem.name == id) {
+                        // Recursively unarchive all nodes, starting at the root node
+                        lst sym_lst_copy = sym_lst;
+                        return nodes[elem.root].unarchive(sym_lst_copy);
+                }
 	}
 	throw (std::runtime_error("expression with name '" + name_string + "' not found in archive"));
-
-found:
-	// Recursively unarchive all nodes, starting at the root node
-	lst sym_lst_copy = sym_lst;
-	return nodes[i->root].unarchive(sym_lst_copy);
 }
 
 ex archive::unarchive_ex(const lst &sym_lst, unsigned index) const
@@ -402,17 +398,15 @@ void archive_node::add_ex(const std::string &name, const ex &value)
 bool archive_node::find_bool(const std::string &name, bool &ret, unsigned index) const
 {
 	archive_atom name_atom = a.atomize(name);
-	auto i = props.begin(), iend = props.end();
 	unsigned found_index = 0;
-	while (i != iend) {
-		if (i->type == PTYPE_BOOL && i->name == name_atom) {
+	for (const auto & elem : props) {
+		if (elem.type == PTYPE_BOOL && elem.name == name_atom) {
 			if (found_index == index) {
-				ret = i->value;
+				ret = elem.value;
 				return true;
 			}
 			found_index++;
 		}
-		i++;
 	}
 	return false;
 }
@@ -420,17 +414,15 @@ bool archive_node::find_bool(const std::string &name, bool &ret, unsigned index)
 bool archive_node::find_unsigned(const std::string &name, unsigned &ret, unsigned index) const
 {
 	archive_atom name_atom = a.atomize(name);
-	auto i = props.begin(), iend = props.end();
 	unsigned found_index = 0;
-	while (i != iend) {
-		if (i->type == PTYPE_UNSIGNED && i->name == name_atom) {
+	for (const auto & elem : props) {
+		if (elem.type == PTYPE_UNSIGNED && elem.name == name_atom) {
 			if (found_index == index) {
-				ret = i->value;
+				ret = elem.value;
 				return true;
 			}
 			found_index++;
 		}
-		i++;
 	}
 	return false;
 }
@@ -438,17 +430,15 @@ bool archive_node::find_unsigned(const std::string &name, unsigned &ret, unsigne
 bool archive_node::find_string(const std::string &name, std::string &ret, unsigned index) const
 {
 	archive_atom name_atom = a.atomize(name);
-	auto i = props.begin(), iend = props.end();
 	unsigned found_index = 0;
-	while (i != iend) {
-		if (i->type == PTYPE_STRING && i->name == name_atom) {
+        for (const auto & elem : props) {
+		if (elem.type == PTYPE_STRING && elem.name == name_atom) {
 			if (found_index == index) {
-				ret = a.unatomize(i->value);
+				ret = a.unatomize(elem.value);
 				return true;
 			}
 			found_index++;
 		}
-		i++;
 	}
 	return false;
 }
@@ -462,17 +452,15 @@ void archive_node::find_ex_by_loc(archive_node_cit loc, ex &ret, lst &sym_lst)
 bool archive_node::find_ex(const std::string &name, ex &ret, lst &sym_lst, unsigned index) const
 {
 	archive_atom name_atom = a.atomize(name);
-	auto i = props.begin(), iend = props.end();
 	unsigned found_index = 0;
-	while (i != iend) {
-		if (i->type == PTYPE_NODE && i->name == name_atom) {
+        for (const auto & elem : props) {
+		if (elem.type == PTYPE_NODE && elem.name == name_atom) {
 			if (found_index == index) {
-				ret = a.get_node(i->value).unarchive(sym_lst);
+				ret = a.get_node(elem.value).unarchive(sym_lst);
 				return true;
 			}
 			found_index++;
 		}
-		i++;
 	}
 	return false;
 }
@@ -480,15 +468,13 @@ bool archive_node::find_ex(const std::string &name, ex &ret, lst &sym_lst, unsig
 const archive_node &archive_node::find_ex_node(const std::string &name, unsigned index) const
 {
 	archive_atom name_atom = a.atomize(name);
-	auto i = props.begin(), iend = props.end();
 	unsigned found_index = 0;
-	while (i != iend) {
-		if (i->type == PTYPE_NODE && i->name == name_atom) {
+        for (const auto & elem : props) {
+		if (elem.type == PTYPE_NODE && elem.name == name_atom) {
 			if (found_index == index)
-				return a.get_node(i->value);
+				return a.get_node(elem.value);
 			found_index++;
 		}
-		i++;
 	}
 	throw (std::runtime_error("property with name '" + name + "' not found in archive node"));
 }
@@ -497,24 +483,20 @@ const archive_node &archive_node::find_ex_node(const std::string &name, unsigned
 void archive_node::get_properties(propinfovector &v) const
 {
 	v.clear();
-	auto i = props.begin(), iend = props.end();
-	while (i != iend) {
-		property_type type = i->type;
-		std::string name = a.unatomize(i->name);
+        for (const auto & elem : props) {
+		property_type type = elem.type;
+		std::string name = a.unatomize(elem.name);
 
-		auto a = v.begin(), aend = v.end();
 		bool found = false;
-		while (a != aend) {
-			if (a->type == type && a->name == name) {
-				a->count++;
+                for (auto & velem : v) {
+			if (velem.type == type && velem.name == name) {
+				velem.count++;
 				found = true;
 				break;
 			}
-			++a;
 		}
 		if (!found)
 			v.push_back(property_info(type, name));
-		i++;
 	}	
 }
 
@@ -569,11 +551,10 @@ void archive::printraw(std::ostream &os) const
 	// Dump atoms
 	os << "Atoms:\n";
 	{
-		std::vector<std::string>::const_iterator i = atoms.begin(), iend = atoms.end();
 		archive_atom id = 0;
-		while (i != iend) {
-			os << " " << id << " " << *i << std::endl;
-			i++; id++;
+                for (const auto & elem : atoms) {
+			os << " " << id << " " << elem << std::endl;
+			id++;
 		}
 	}
 	os << std::endl;
@@ -581,11 +562,10 @@ void archive::printraw(std::ostream &os) const
 	// Dump expressions
 	os << "Expressions:\n";
 	{
-		auto i = exprs.begin(), iend = exprs.end();
 		unsigned index = 0;
-		while (i != iend) {
-			os << " " << index << " \"" << unatomize(i->name) << "\" root node " << i->root << std::endl;
-			i++; index++;
+                for (const auto & elem : exprs) {
+			os << " " << index << " \"" << unatomize(elem.name) << "\" root node " << elem.root << std::endl;
+			index++;
 		}
 	}
 	os << std::endl;
@@ -593,12 +573,11 @@ void archive::printraw(std::ostream &os) const
 	// Dump nodes
 	os << "Nodes:\n";
 	{
-		auto i = nodes.begin(), iend = nodes.end();
 		archive_node_id id = 0;
-		while (i != iend) {
+                for (const auto & elem : nodes) {
 			os << " " << id << " ";
-			i->printraw(os);
-			i++; id++;
+			elem.printraw(os);
+			id++;
 		}
 	}
 }
@@ -613,18 +592,16 @@ void archive_node::printraw(std::ostream &os) const
 		os << "\n";
 
 	// Dump properties
-	auto i = props.begin(), iend = props.end();
-	while (i != iend) {
+        for (const auto & elem : props) {
 		os << "  ";
-		switch (i->type) {
+		switch (elem.type) {
 			case PTYPE_BOOL: os << "bool"; break;
 			case PTYPE_UNSIGNED: os << "unsigned"; break;
 			case PTYPE_STRING: os << "string"; break;
 			case PTYPE_NODE: os << "node"; break;
 			default: os << "<unknown>"; break;
 		}
-		os << " \"" << a.unatomize(i->name) << "\" " << i->value << std::endl;
-		i++;
+		os << " \"" << a.unatomize(elem.name) << "\" " << elem.value << std::endl;
 	}
 }
 
diff --git a/ginac/basic.cpp b/ginac/basic.cpp
index 74765fb..40425e7 100644
--- a/ginac/basic.cpp
+++ b/ginac/basic.cpp
@@ -94,12 +94,12 @@ const basic & basic::operator=(const basic & other)
 //////////
 
 /** Construct object from archive_node. */
-basic::basic(const archive_node &n, lst &sym_lst) : flags(0)
+basic::basic(const archive_node &n, lst&) : flags(0)
 {
 	// Reconstruct tinfo_key from class name
-	std::string class_name;
-	if (n.find_string("class", class_name))
-		tinfo_key = find_tinfo_key(class_name);
+	std::string found_class_name;
+	if (n.find_string("class", found_class_name))
+		tinfo_key = find_tinfo_key(found_class_name);
 	else
 		throw (std::runtime_error("archive node contains no class name"));
 }
@@ -177,7 +177,7 @@ next_context:
 }
 
 /** Default output to stream. */
-void basic::do_print(const print_context & c, unsigned level) const
+void basic::do_print(const print_context & c, unsigned) const
 {
 	c.s << "[" << class_name() << " object]";
 }
@@ -195,7 +195,7 @@ void basic::do_print_tree(const print_tree & c, unsigned level) const
 }
 
 /** Python parsable output to stream. */
-void basic::do_print_python_repr(const print_python_repr & c, unsigned level) const
+void basic::do_print_python_repr(const print_python_repr & c, unsigned) const
 {
 	c.s << class_name() << "()";
 }
@@ -230,7 +230,7 @@ unsigned basic::precedence() const
 /** Information about the object.
  *
  *  @see class info_flags */
-bool basic::info(unsigned inf) const
+bool basic::info(unsigned) const
 {
 	// all possible properties are false for basic objects
 	return false;
@@ -246,13 +246,13 @@ size_t basic::nops() const
 }
 
 /** Return operand/member at position i. */
-ex basic::op(size_t i) const
+ex basic::op(size_t) const
 {
 	throw(std::range_error(std::string("basic::op(): ") + class_name() + std::string(" has no operands")));
 }
 
 /** Return modifyable operand/member at position i. */
-ex & basic::let_op(size_t i)
+ex & basic::let_op(size_t)
 {
 	ensure_if_modifiable();
 	throw(std::range_error(std::string("basic::let_op(): ") + class_name() + std::string(" has no operands")));
@@ -377,13 +377,13 @@ ex basic::collect(const ex & s, bool distributed) const
 
 			exmap cmap;
 			cmap[_ex1] = _ex0;
-			for (const_iterator xi=x.begin(); xi!=x.end(); ++xi) {
+                        for (const auto & xelem : x) {
 				ex key = _ex1;
-				ex pre_coeff = *xi;
-				for (const auto & elem : l) {
-					int cexp = pre_coeff.degree(elem);
-					pre_coeff = pre_coeff.coeff(elem, cexp);
-					key *= pow(elem, cexp);
+                                ex pre_coeff = xelem;
+				for (const auto & lelem : l) {
+					int cexp = pre_coeff.degree(lelem);
+					pre_coeff = pre_coeff.coeff(lelem, cexp);
+					key *= pow(lelem, cexp);
 				}
 				auto ci = cmap.find(key);
 				if (ci != cmap.end())
@@ -393,8 +393,8 @@ ex basic::collect(const ex & s, bool distributed) const
 			}
 
 			exvector resv;
-			for (exmap::const_iterator mi=cmap.begin(); mi != cmap.end(); ++mi)
-				resv.push_back((mi->first)*(mi->second));
+                        for (const auto & elem : cmap)
+				resv.push_back((elem.first) * (elem.second));
 			return (new add(resv))->setflag(status_flags::dynallocated);
 
 		} else {
@@ -422,7 +422,7 @@ ex basic::collect(const ex & s, bool distributed) const
 }
 
 /** Perform automatic non-interruptive term rewriting rules. */
-ex basic::eval(int level) const
+ex basic::eval(int) const
 {
 	// There is nothing to do for basic objects:
 	return hold();
@@ -528,7 +528,7 @@ ex basic::scalar_mul_indexed(const ex & self, const numeric & other) const
  *  @param v The complete vector of factors
  *  @return true if the contraction was successful, false otherwise
  *  @see ex::simplify_indexed() */
-bool basic::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
+bool basic::contract_with(exvector::iterator, exvector::iterator, exvector&) const
 {
 	// Do nothing
 	return false;
@@ -599,19 +599,14 @@ bool basic::match(const ex & pattern, lst & repl_lst) const
 /** Helper function for subs(). Does not recurse into subexpressions. */
 ex basic::subs_one_level(const exmap & m, unsigned options) const
 {
-	exmap::const_iterator it;
-
 	if (options & subs_options::no_pattern) {
-		ex thisex = *this;
-		it = m.find(thisex);
-		if (it != m.end())
-			return it->second;
-		return thisex;
+		const auto& it = m.find(*this);
+		return (it != m.end())? it->second : *this;
 	} else {
-		for (it = m.begin(); it != m.end(); ++it) {
+                for (const auto & elem : m) {
 			lst repl_lst;
-			if (match(ex_to<basic>(it->first), repl_lst))
-				return it->second.subs(repl_lst, options | subs_options::no_pattern); // avoid infinite recursion when re-substituting the wildcards
+			if (match(ex_to<basic>(elem.first), repl_lst))
+				return elem.second.subs(repl_lst, options | subs_options::no_pattern); // avoid infinite recursion when re-substituting the wildcards
 		}
 	}
 
@@ -758,7 +753,7 @@ bool basic::is_equal_same_type(const basic & other) const
  *  automatically used instead of match_same_type() if nops() == 0.
  *
  *  @see basic::match */
-bool basic::match_same_type(const basic & other) const
+bool basic::match_same_type(const basic &) const
 {
 	// The default is to only consider subexpressions, but not any other
 	// attributes
diff --git a/ginac/class_info.h b/ginac/class_info.h
index e5b7d14..1b6d0a5 100644
--- a/ginac/class_info.h
+++ b/ginac/class_info.h
@@ -156,17 +156,17 @@ void class_info<OPT>::dump_hierarchy(bool verbose)
 
 	// Identify children for all nodes and find the root
 	tree_node *root = NULL;
-	for (typename std::vector<tree_node>::iterator i = tree.begin(); i != tree.end(); ++i) {
-		class_info *p = i->info->get_parent();
+	for (const auto & elem : tree) {
+		class_info *p = elem.info->get_parent();
 		if (p) {
-			for (typename std::vector<tree_node>::iterator j = tree.begin(); j != tree.end(); ++j) {
-				if (j->info == p) {
-					j->add_child(&*i);
+			for (const auto & elem1 : tree) {
+				if (elem1.info == p) {
+					elem1.add_child(&elem);
 					break;
 				}
 			}
 		} else
-			root = &*i;
+			root = &elem;
 	}
 
 	// Print hierarchy tree starting at the root
diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp
index 05b08d5..8e29ef3 100644
--- a/ginac/clifford.cpp
+++ b/ginac/clifford.cpp
@@ -338,7 +338,7 @@ struct is_not_a_clifford : public std::unary_function<ex, bool> {
 };
 
 /** Contraction of a gamma matrix with something else. */
-bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
+bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other, exvector &) const
 {
 	GINAC_ASSERT(is_a<clifford>(*self));
 	GINAC_ASSERT(is_a<indexed>(*other));
@@ -449,7 +449,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
 }
 
 /** Contraction of a Clifford unit with something else. */
-bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
+bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator other, exvector &) const
 {
 	GINAC_ASSERT(is_a<clifford>(*self));
 	GINAC_ASSERT(is_a<indexed>(*other));
@@ -1219,20 +1219,22 @@ static ex get_clifford_comp(const ex & e, const ex & c)
 	else if (is_a<ncmul>(e) || is_a<mul>(e)) {
 		// find a Clifford unit with the same metric, delete it and substitute its index
 		size_t ind = e.nops() + 1;
-		for (size_t j = 0; j < e.nops(); j++) 
-			if (is_a<clifford>(e.op(j)) && ex_to<clifford>(c).same_metric(e.op(j)))
+		for (size_t j = 0; j < e.nops(); j++) {
+			if (is_a<clifford>(e.op(j)) && ex_to<clifford>(c).same_metric(e.op(j))) {
 				if (ind > e.nops()) 
 					ind = j;
 				else 
 					throw(std::invalid_argument("get_clifford_comp(): expression is a Clifford multi-vector"));
+                        }
+                }
 		if (ind < e.nops()) {
 			ex S = 1;
 			bool same_value_index, found_dummy;
 			same_value_index = ( ex_to<idx>(e.op(ind).op(1)).is_numeric()
 								 &&  (ival == ex_to<numeric>(ex_to<idx>(e.op(ind).op(1)).get_value()).to_int()) );
 			found_dummy = same_value_index;
-			for(size_t j=0; j < e.nops(); j++)
-				if (j != ind) 
+			for(size_t j=0; j < e.nops(); j++) {
+				if (j != ind) {
 					if (same_value_index) 
 						S = S * e.op(j);
 					else {
@@ -1252,19 +1254,22 @@ static ex get_clifford_comp(const ex & e, const ex & c)
 						} else
 							S = S * e.op(j);
 					}
+                                }
 			return (found_dummy ? S : 0);
+                        }
 		} else
 			throw(std::invalid_argument("get_clifford_comp(): expression is not a Clifford vector to the given units"));
 	} else if (e.is_zero()) 
 		return e;
-	else if (is_a<clifford>(e) && ex_to<clifford>(e).same_metric(c))
-		if ( ex_to<idx>(e.op(1)).is_numeric() &&
-			 (ival != ex_to<numeric>(ex_to<idx>(e.op(1)).get_value()).to_int()) )
+	else {
+                if (is_a<clifford>(e) and ex_to<clifford>(e).same_metric(c)
+                and ex_to<idx>(e.op(1)).is_numeric()
+                and (ival != ex_to<numeric>(ex_to<idx>(e.op(1)).get_value()).to_int()) )
 			return 0;
 		else 
 			return 1;
-	else
-		throw(std::invalid_argument("get_clifford_comp(): expression is not usable as a Clifford vector"));
+        }
+        throw(std::invalid_argument("get_clifford_comp(): expression is not usable as a Clifford vector"));
 }
 
 
diff --git a/ginac/color.cpp b/ginac/color.cpp
deleted file mode 100644
index 92c0275..0000000
--- a/ginac/color.cpp
+++ /dev/null
@@ -1,647 +0,0 @@
-/** @file color.cpp
- *
- *  Implementation of GiNaC's color (SU(3) Lie algebra) objects. */
-
-/*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "color.h"
-#include "idx.h"
-#include "ncmul.h"
-#include "symmetry.h"
-#include "operators.h"
-#include "numeric.h"
-#include "mul.h"
-#include "power.h" // for sqrt()
-#include "symbol.h"
-#include "archive.h"
-#include "utils.h"
-
-#include <iostream>
-#include <stdexcept>
-
-namespace GiNaC {
-
-GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed)
-
-const tinfo_static_t color::return_type_tinfo_static[256] = {{}};
-
-GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3one, tensor,
-  print_func<print_dflt>(&su3one::do_print).
-  print_func<print_latex>(&su3one::do_print_latex))
-
-GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3t, tensor,
-  print_func<print_dflt>(&su3t::do_print).
-  print_func<print_latex>(&su3t::do_print))
-
-GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3f, tensor,
-  print_func<print_dflt>(&su3f::do_print).
-  print_func<print_latex>(&su3f::do_print))
-
-GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3d, tensor,
-  print_func<print_dflt>(&su3d::do_print).
-  print_func<print_latex>(&su3d::do_print))
-
-//////////
-// default constructors
-//////////
-
-color::color() : representation_label(0)
-{
-	tinfo_key = &color::tinfo_static;
-}
-
-DEFAULT_CTOR(su3one)
-DEFAULT_CTOR(su3t)
-DEFAULT_CTOR(su3f)
-DEFAULT_CTOR(su3d)
-
-//////////
-// other constructors
-//////////
-
-/** Construct object without any color index. This constructor is for
- *  internal use only. Use the color_ONE() function instead.
- *  @see color_ONE */
-color::color(const ex & b, unsigned char rl) : inherited(b), representation_label(rl)
-{
-	tinfo_key = &color::tinfo_static;
-}
-
-/** Construct object with one color index. This constructor is for internal
- *  use only. Use the color_T() function instead.
- *  @see color_T */
-color::color(const ex & b, const ex & i1, unsigned char rl) : inherited(b, i1), representation_label(rl)
-{
-	tinfo_key = &color::tinfo_static;
-}
-
-color::color(unsigned char rl, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl)
-{
-	tinfo_key = &color::tinfo_static;
-}
-
-color::color(unsigned char rl, std::unique_ptr<exvector> vp) : inherited(not_symmetric(), std::move(vp)), representation_label(rl)
-{
-	tinfo_key = &color::tinfo_static;
-}
-
-//////////
-// archiving
-//////////
-
-color::color(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
-{
-	unsigned rl;
-	n.find_unsigned("label", rl);
-	representation_label = rl;
-}
-
-void color::archive(archive_node &n) const
-{
-	inherited::archive(n);
-	n.add_unsigned("label", representation_label);
-}
-
-DEFAULT_UNARCHIVE(color)
-DEFAULT_ARCHIVING(su3one)
-DEFAULT_ARCHIVING(su3t)
-DEFAULT_ARCHIVING(su3f)
-DEFAULT_ARCHIVING(su3d)
-
-//////////
-// functions overriding virtual functions from base classes
-//////////
-
-int color::compare_same_type(const basic & other) const
-{
-	GINAC_ASSERT(is_a<color>(other));
-	const color &o = static_cast<const color &>(other);
-
-	if (representation_label != o.representation_label) {
-		// different representation label
-		return representation_label < o.representation_label ? -1 : 1;
-	}
-
-	return inherited::compare_same_type(other);
-}
-
-bool color::match_same_type(const basic & other) const
-{
-	GINAC_ASSERT(is_a<color>(other));
-	const color &o = static_cast<const color &>(other);
-
-	return representation_label == o.representation_label;
-}
-
-DEFAULT_COMPARE(su3one)
-DEFAULT_COMPARE(su3t)
-DEFAULT_COMPARE(su3f)
-DEFAULT_COMPARE(su3d)
-
-DEFAULT_PRINT_LATEX(su3one, "ONE", "\\mathbb{1}")
-DEFAULT_PRINT(su3t, "T")
-DEFAULT_PRINT(su3f, "f")
-DEFAULT_PRINT(su3d, "d")
-
-/** Perform automatic simplification on noncommutative product of color
- *  objects. This removes superfluous ONEs. */
-ex color::eval_ncmul(const exvector & v) const
-{
-	exvector s;
-	s.reserve(v.size());
-
-	// Remove superfluous ONEs
-	auto it = v.begin(), itend = v.end();
-	while (it != itend) {
-		if (!is_a<su3one>(it->op(0)))
-			s.push_back(*it);
-		it++;
-	}
-
-	if (s.empty())
-		return color(su3one(), representation_label);
-	else
-		return hold_ncmul(s);
-}
-
-ex color::thiscontainer(const exvector & v) const
-{
-	return color(representation_label, v);
-}
-
-ex color::thiscontainer(std::unique_ptr<exvector> vp) const
-{
-	return color(representation_label, std::move(vp));
-}
-
-/** Given a vector iv3 of three indices and a vector iv2 of two indices that
- *  is a subset of iv3, return the (free) index that is in iv3 but not in
- *  iv2 and the sign introduced by permuting that index to the front.
- *
- *  @param iv3 Vector of 3 indices
- *  @param iv2 Vector of 2 indices, must be a subset of iv3
- *  @param sig Returs sign introduced by index permutation
- *  @return the free index (the one that is in iv3 but not in iv2) */
-static ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2, int & sig)
-{
-	GINAC_ASSERT(iv3.size() == 3);
-	GINAC_ASSERT(iv2.size() == 2);
-
-	sig = 1;
-
-#define TEST_PERMUTATION(A,B,C,P) \
-	if (iv3[B].is_equal(iv2[0]) && iv3[C].is_equal(iv2[1])) { \
-		sig = P; \
-		return iv3[A]; \
-	}
-	
-	TEST_PERMUTATION(0,1,2,  1);
-	TEST_PERMUTATION(0,2,1, -1);
-	TEST_PERMUTATION(1,0,2, -1);
-	TEST_PERMUTATION(1,2,0,  1);
-	TEST_PERMUTATION(2,0,1,  1);
-	TEST_PERMUTATION(2,1,0, -1);
-
-	throw(std::logic_error("permute_free_index_to_front(): no valid permutation found"));
-}
-
-/** Automatic symbolic evaluation of indexed symmetric structure constant. */
-ex su3d::eval_indexed(const basic & i) const
-{
-	GINAC_ASSERT(is_a<indexed>(i));
-	GINAC_ASSERT(i.nops() == 4);
-	GINAC_ASSERT(is_a<su3d>(i.op(0)));
-
-	// Convolutions are zero
-	if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
-		return _ex0;
-
-	// Numeric evaluation
-	if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
-
-		// Sort indices
-		int v[3];
-		for (unsigned j=0; j<3; j++)
-			v[j] = ex_to<numeric>(ex_to<idx>(i.op(j + 1)).get_value()).to_int();
-		if (v[0] > v[1]) std::swap(v[0], v[1]);
-		if (v[0] > v[2]) std::swap(v[0], v[2]);
-		if (v[1] > v[2]) std::swap(v[1], v[2]);
-
-#define CMPINDICES(A,B,C) ((v[0] == (A)) && (v[1] == (B)) && (v[2] == (C)))
-
-		// Check for non-zero elements
-		if (CMPINDICES(1,4,6) || CMPINDICES(1,5,7) || CMPINDICES(2,5,6)
-		 || CMPINDICES(3,4,4) || CMPINDICES(3,5,5))
-			return _ex1_2;
-		else if (CMPINDICES(2,4,7) || CMPINDICES(3,6,6) || CMPINDICES(3,7,7))
-			return _ex_1_2;
-		else if (CMPINDICES(1,1,8) || CMPINDICES(2,2,8) || CMPINDICES(3,3,8))
-			return sqrt(_ex3)*_ex1_3;
-		else if (CMPINDICES(8,8,8))
-			return sqrt(_ex3)*_ex_1_3;
-		else if (CMPINDICES(4,4,8) || CMPINDICES(5,5,8)
-		      || CMPINDICES(6,6,8) || CMPINDICES(7,7,8))
-			return sqrt(_ex3)/_ex_6;
-		else
-			return _ex0;
-	}
-
-	// No further simplifications
-	return i.hold();
-}
-
-/** Automatic symbolic evaluation of indexed antisymmetric structure constant. */
-ex su3f::eval_indexed(const basic & i) const
-{
-	GINAC_ASSERT(is_a<indexed>(i));
-	GINAC_ASSERT(i.nops() == 4);
-	GINAC_ASSERT(is_a<su3f>(i.op(0)));
-
-	// Numeric evaluation
-	if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
-
-		// Sort indices, remember permutation sign
-		int v[3];
-		for (unsigned j=0; j<3; j++)
-			v[j] = ex_to<numeric>(ex_to<idx>(i.op(j + 1)).get_value()).to_int();
-		int sign = 1;
-		if (v[0] > v[1]) { std::swap(v[0], v[1]); sign = -sign; }
-		if (v[0] > v[2]) { std::swap(v[0], v[2]); sign = -sign; }
-		if (v[1] > v[2]) { std::swap(v[1], v[2]); sign = -sign; }
-
-		// Check for non-zero elements
-		if (CMPINDICES(1,2,3))
-			return sign;
-		else if (CMPINDICES(1,4,7) || CMPINDICES(2,4,6)
-		      || CMPINDICES(2,5,7) || CMPINDICES(3,4,5))
-			return _ex1_2 * sign;
-		else if (CMPINDICES(1,5,6) || CMPINDICES(3,6,7))
-			return _ex_1_2 * sign;
-		else if (CMPINDICES(4,5,8) || CMPINDICES(6,7,8))
-			return sqrt(_ex3)/2 * sign;
-		else
-			return _ex0;
-	}
-
-	// No further simplifications
-	return i.hold();
-}
-
-
-/** Contraction of generator with something else. */
-bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
-{
-	GINAC_ASSERT(is_a<indexed>(*self));
-	GINAC_ASSERT(is_a<indexed>(*other));
-	GINAC_ASSERT(self->nops() == 2);
-	GINAC_ASSERT(is_a<su3t>(self->op(0)));
-	unsigned char rl = ex_to<color>(*self).get_representation_label();
-
-	if (is_exactly_a<su3t>(other->op(0))) {
-
-		// Contraction only makes sense if the represenation labels are equal
-		GINAC_ASSERT(is_a<color>(*other));
-		if (ex_to<color>(*other).get_representation_label() != rl)
-			return false;
-
-		// T.a T.a = 4/3 ONE
-		if (other - self == 1) {
-			*self = numeric(4, 3);
-			*other = color_ONE(rl);
-			return true;
-
-		// T.a T.b T.a = -1/6 T.b
-		} else if (other - self == 2
-		        && is_a<color>(self[1])) {
-			*self = numeric(-1, 6);
-			*other = _ex1;
-			return true;
-
-		// T.a S T.a = 1/2 Tr(S) - 1/6 S
-		} else {
-			auto it = self + 1;
-			while (it != other) {
-				if (!is_a<color>(*it)) {
-					return false;
-				}
-				it++;
-			}
-
-			it = self + 1;
-			ex S = _ex1;
-			while (it != other) {
-				S *= *it;
-				*it++ = _ex1;
-			}
-
-			*self = color_trace(S, rl) * color_ONE(rl) / 2 - S / 6;
-			*other = _ex1;
-			return true;
-		}
-	}
-
-	return false;
-}
-
-/** Contraction of an indexed symmetric structure constant with something else. */
-bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
-{
-	GINAC_ASSERT(is_a<indexed>(*self));
-	GINAC_ASSERT(is_a<indexed>(*other));
-	GINAC_ASSERT(self->nops() == 4);
-	GINAC_ASSERT(is_a<su3d>(self->op(0)));
-
-	if (is_exactly_a<su3d>(other->op(0))) {
-
-		// Find the dummy indices of the contraction
-		exvector self_indices = ex_to<indexed>(*self).get_indices();
-		exvector other_indices = ex_to<indexed>(*other).get_indices();
-		exvector all_indices = self_indices;
-		all_indices.insert(all_indices.end(), other_indices.begin(), other_indices.end());
-		exvector free_indices, dummy_indices;
-		find_free_and_dummy(all_indices, free_indices, dummy_indices);
-
-		// d.abc d.abc = 40/3
-		if (dummy_indices.size() == 3) {
-			*self = numeric(40, 3);
-			*other = _ex1;
-			return true;
-
-		// d.akl d.bkl = 5/3 delta.ab
-		} else if (dummy_indices.size() == 2) {
-			exvector a;
-			std::back_insert_iterator<exvector> ita(a);
-			ita = set_difference(self_indices.begin(), self_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita, ex_is_less());
-			ita = set_difference(other_indices.begin(), other_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita, ex_is_less());
-			GINAC_ASSERT(a.size() == 2);
-			*self = numeric(5, 3) * delta_tensor(a[0], a[1]);
-			*other = _ex1;
-			return true;
-		}
-
-	} else if (is_exactly_a<su3t>(other->op(0))) {
-
-		// d.abc T.b T.c = 5/6 T.a
-		if (other+1 != v.end()
-		 && is_exactly_a<su3t>(other[1].op(0))
-		 && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
-
-			exvector self_indices = ex_to<indexed>(*self).get_indices();
-			exvector dummy_indices;
-			dummy_indices.push_back(other[0].op(1));
-			dummy_indices.push_back(other[1].op(1));
-			int sig;
-			ex a = permute_free_index_to_front(self_indices, dummy_indices, sig);
-			*self = numeric(5, 6);
-			other[0] = color_T(a, ex_to<color>(other[0]).get_representation_label());
-			other[1] = _ex1;
-			return true;
-		}
-	}
-
-	return false;
-}
-
-/** Contraction of an indexed antisymmetric structure constant with something else. */
-bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
-{
-	GINAC_ASSERT(is_a<indexed>(*self));
-	GINAC_ASSERT(is_a<indexed>(*other));
-	GINAC_ASSERT(self->nops() == 4);
-	GINAC_ASSERT(is_a<su3f>(self->op(0)));
-
-	if (is_exactly_a<su3f>(other->op(0))) { // f*d is handled by su3d class
-
-		// Find the dummy indices of the contraction
-		exvector dummy_indices;
-		dummy_indices = ex_to<indexed>(*self).get_dummy_indices(ex_to<indexed>(*other));
-
-		// f.abc f.abc = 24
-		if (dummy_indices.size() == 3) {
-			*self = 24;
-			*other = _ex1;
-			return true;
-
-		// f.akl f.bkl = 3 delta.ab
-		} else if (dummy_indices.size() == 2) {
-			int sign1, sign2;
-			ex a = permute_free_index_to_front(ex_to<indexed>(*self).get_indices(), dummy_indices, sign1);
-			ex b = permute_free_index_to_front(ex_to<indexed>(*other).get_indices(), dummy_indices, sign2);
-			*self = sign1 * sign2 * 3 * delta_tensor(a, b);
-			*other = _ex1;
-			return true;
-		}
-
-	} else if (is_exactly_a<su3t>(other->op(0))) {
-
-		// f.abc T.b T.c = 3/2 I T.a
-		if (other+1 != v.end()
-		 && is_exactly_a<su3t>(other[1].op(0))
-		 && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
-
-			exvector self_indices = ex_to<indexed>(*self).get_indices();
-			exvector dummy_indices;
-			dummy_indices.push_back(other[0].op(1));
-			dummy_indices.push_back(other[1].op(1));
-			int sig;
-			ex a = permute_free_index_to_front(self_indices, dummy_indices, sig);
-			*self = numeric(3, 2) * sig * I;
-			other[0] = color_T(a, ex_to<color>(other[0]).get_representation_label());
-			other[1] = _ex1;
-			return true;
-		}
-	}
-
-	return false;
-}
-
-//////////
-// global functions
-//////////
-
-ex color_ONE(unsigned char rl)
-{
-	static ex ONE = (new su3one)->setflag(status_flags::dynallocated);
-	return color(ONE, rl);
-}
-
-ex color_T(const ex & a, unsigned char rl)
-{
-	static ex t = (new su3t)->setflag(status_flags::dynallocated);
-
-	if (!is_a<idx>(a))
-		throw(std::invalid_argument("indices of color_T must be of type idx"));
-	if (!ex_to<idx>(a).get_dim().is_equal(8))
-		throw(std::invalid_argument("index dimension for color_T must be 8"));
-
-	return color(t, a, rl);
-}
-
-ex color_f(const ex & a, const ex & b, const ex & c)
-{
-	static ex f = (new su3f)->setflag(status_flags::dynallocated);
-
-	if (!is_a<idx>(a) || !is_a<idx>(b) || !is_a<idx>(c))
-		throw(std::invalid_argument("indices of color_f must be of type idx"));
-	if (!ex_to<idx>(a).get_dim().is_equal(8) || !ex_to<idx>(b).get_dim().is_equal(8) || !ex_to<idx>(c).get_dim().is_equal(8))
-		throw(std::invalid_argument("index dimension for color_f must be 8"));
-
-	return indexed(f, antisymmetric3(), a, b, c);
-}
-
-ex color_d(const ex & a, const ex & b, const ex & c)
-{
-	static ex d = (new su3d)->setflag(status_flags::dynallocated);
-
-	if (!is_a<idx>(a) || !is_a<idx>(b) || !is_a<idx>(c))
-		throw(std::invalid_argument("indices of color_d must be of type idx"));
-	if (!ex_to<idx>(a).get_dim().is_equal(8) || !ex_to<idx>(b).get_dim().is_equal(8) || !ex_to<idx>(c).get_dim().is_equal(8))
-		throw(std::invalid_argument("index dimension for color_d must be 8"));
-
-	return indexed(d, symmetric3(), a, b, c);
-}
-
-ex color_h(const ex & a, const ex & b, const ex & c)
-{
-	return color_d(a, b, c) + I * color_f(a, b, c);
-}
-
-/** Check whether a given tinfo key (as returned by return_type_tinfo()
- *  is that of a color object (with an arbitrary representation label). */
-static bool is_color_tinfo(tinfo_t ti)
-{
-	p_int start_loc=(p_int)&color::return_type_tinfo_static;
-	return (p_int)ti>=start_loc && (p_int)ti<start_loc+256;
-}
-
-/** Extract representation label from tinfo key (as returned by
- *  return_type_tinfo()). */
-static unsigned char get_representation_label(tinfo_t ti)
-{
-	return (unsigned char)((p_int)ti-(p_int)&color::return_type_tinfo_static);
-}
-
-ex color_trace(const ex & e, const std::set<unsigned char> & rls)
-{
-	if (is_a<color>(e)) {
-
-		unsigned char rl = ex_to<color>(e).get_representation_label();
-
-		// Are we taking the trace over this object's representation label?
-		if (rls.find(rl) == rls.end())
-			return e;
-
-		// Yes, all generators are traceless, except for color_ONE
-		if (is_a<su3one>(e.op(0)))
-			return _ex3;
-		else
-			return _ex0;
-
-	} else if (is_exactly_a<mul>(e)) {
-
-		// Trace of product: pull out non-color factors
-		ex prod = _ex1;
-		for (size_t i=0; i<e.nops(); i++) {
-			const ex &o = e.op(i);
-			if (is_color_tinfo(o.return_type_tinfo()))
-				prod *= color_trace(o, rls);
-			else
-				prod *= o;
-		}
-		return prod;
-
-	} else if (is_exactly_a<ncmul>(e)) {
-
-		unsigned char rl = get_representation_label(e.return_type_tinfo());
-
-		// Are we taking the trace over this string's representation label?
-		if (rls.find(rl) == rls.end())
-			return e;
-
-		// Yes, expand product if necessary
-		ex e_expanded = e.expand();
-		if (!is_a<ncmul>(e_expanded))
-			return color_trace(e_expanded, rls);
-
-		size_t num = e.nops();
-
-		if (num == 2) {
-
-			// Tr T_a T_b = 1/2 delta_a_b
-			return delta_tensor(e.op(0).op(1), e.op(1).op(1)) / 2;
-
-		} else if (num == 3) {
-
-			// Tr T_a T_b T_c = 1/4 h_a_b_c
-			return color_h(e.op(0).op(1), e.op(1).op(1), e.op(2).op(1)) / 4;
-
-		} else {
-
-			// Traces of 4 or more generators are computed recursively:
-			// Tr T_a1 .. T_an =
-			//     1/6 delta_a(n-1)_an Tr T_a1 .. T_a(n-2)
-			//   + 1/2 h_a(n-1)_an_k Tr T_a1 .. T_a(n-2) T_k
-			const ex &last_index = e.op(num - 1).op(1);
-			const ex &next_to_last_index = e.op(num - 2).op(1);
-			idx summation_index((new symbol)->setflag(status_flags::dynallocated), 8);
-
-			exvector v1;
-			v1.reserve(num - 2);
-			for (size_t i=0; i<num-2; i++)
-				v1.push_back(e.op(i));
-
-			exvector v2 = v1;
-			v2.push_back(color_T(summation_index, rl));
-
-			return delta_tensor(next_to_last_index, last_index) * color_trace(ncmul(v1), rl) / 6
-			       + color_h(next_to_last_index, last_index, summation_index) * color_trace(ncmul(v2), rl) / 2;
-		}
-
-	} else if (e.nops() > 0) {
-
-		// Trace maps to all other container classes (this includes sums)
-		pointer_to_map_function_1arg<const std::set<unsigned char> &> fcn(color_trace, rls);
-		return e.map(fcn);
-
-	} else
-		return _ex0;
-}
-
-ex color_trace(const ex & e, const lst & rll)
-{
-	// Convert list to set
-	std::set<unsigned char> rls;
-	for (const auto & elem : rll) {
-		if (elem.info(info_flags::nonnegint))
-			rls.insert(ex_to<numeric>(elem).to_int());
-	}
-
-	return color_trace(e, rls);
-}
-
-ex color_trace(const ex & e, unsigned char rl)
-{
-	// Convert label to set
-	std::set<unsigned char> rls;
-	rls.insert(rl);
-
-	return color_trace(e, rls);
-}
-
-} // namespace GiNaC
diff --git a/ginac/color.h b/ginac/color.h
deleted file mode 100644
index 8784206..0000000
--- a/ginac/color.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/** @file color.h
- *
- *  Interface to GiNaC's color (SU(3) Lie algebra) objects. */
-
-/*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __GINAC_COLOR_H__
-#define __GINAC_COLOR_H__
-
-#include "indexed.h"
-#include "tensor.h"
-
-#include <set>
-
-namespace GiNaC {
-
-
-/** This class holds a generator T_a or the unity element of the Lie algebra
- *  of SU(3), as used for calculations in quantum chromodynamics. A
- *  representation label (an unsigned 8-bit integer) is used to distinguish
- *  elements from different Lie algebras (objects with different labels
- *  commutate). These objects implement an abstract representation of the
- *  group, not a specific matrix representation. The indices used for color
- *  objects should not have a variance. */
-class color : public indexed
-{
-	GINAC_DECLARE_REGISTERED_CLASS(color, indexed)
-public:
-	static const tinfo_static_t return_type_tinfo_static[256];
-
-	// other constructors
-public:
-	color(const ex & b, unsigned char rl = 0);
-	color(const ex & b, const ex & i1, unsigned char rl = 0);
-
-	// internal constructors
-	color(unsigned char rl, const exvector & v, bool discardable = false);
-	color(unsigned char rl, std::unique_ptr<exvector> vp);
-
-	// functions overriding virtual functions from base classes
-protected:
-	ex eval_ncmul(const exvector & v) const;
-	bool match_same_type(const basic & other) const;
-	ex thiscontainer(const exvector & v) const;
-	ex thiscontainer(std::unique_ptr<exvector> vp) const;
-	unsigned return_type() const { return return_types::noncommutative; }
-	tinfo_t return_type_tinfo() const { return color::return_type_tinfo_static+representation_label; }
-
-	// non-virtual functions in this class
-public:
-	unsigned char get_representation_label() const {return representation_label;}
-
-	// member variables
-private:
-	unsigned char representation_label; /**< Representation label to distinguish independent color matrices coming from separated fermion lines */
-};
-
-
-/** This class represents the su(3) unity element. */
-class su3one : public tensor
-{
-	GINAC_DECLARE_REGISTERED_CLASS(su3one, tensor)
-
-	// non-virtual functions in this class
-protected:
-	void do_print(const print_context & c, unsigned level) const;
-	void do_print_latex(const print_latex & c, unsigned level) const;
-};
-
-/** This class represents an su(3) generator. */
-class su3t : public tensor
-{
-	GINAC_DECLARE_REGISTERED_CLASS(su3t, tensor)
-
-	// functions overriding virtual functions from base classes
-public:
-	bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
-
-	// non-virtual functions in this class
-protected:
-	void do_print(const print_context & c, unsigned level) const;
-	void do_print_latex(const print_latex & c, unsigned level) const;
-};
-
-/** This class represents the tensor of antisymmetric su(3) structure
- *  constants. */
-class su3f : public tensor
-{
-	GINAC_DECLARE_REGISTERED_CLASS(su3f, tensor)
-
-	// functions overriding virtual functions from base classes
-public:
-	ex eval_indexed(const basic & i) const;
-	bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
-
-	// non-virtual functions in this class
-protected:
-	unsigned return_type() const { return return_types::commutative; }
-	void do_print(const print_context & c, unsigned level) const;
-	void do_print_latex(const print_latex & c, unsigned level) const;
-};
-
-/** This class represents the tensor of symmetric su(3) structure constants. */
-class su3d : public tensor
-{
-	GINAC_DECLARE_REGISTERED_CLASS(su3d, tensor)
-
-	// functions overriding virtual functions from base classes
-public:
-	ex eval_indexed(const basic & i) const;
-	bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
-
-	// non-virtual functions in this class
-protected:
-	unsigned return_type() const { return return_types::commutative; }
-	void do_print(const print_context & c, unsigned level) const;
-	void do_print_latex(const print_latex & c, unsigned level) const;
-};
-
-
-// global functions
-
-/** Create the su(3) unity element. This is an indexed object, although it
- *  has no indices.
- *
- *  @param rl Representation label
- *  @return newly constructed unity element */
-ex color_ONE(unsigned char rl = 0);
-
-/** Create an su(3) generator.
- *
- *  @param a Index
- *  @param rl Representation label
- *  @return newly constructed unity generator */
-ex color_T(const ex & a, unsigned char rl = 0);
-
-/** Create an su(3) antisymmetric structure constant.
- *
- *  @param a First index
- *  @param b Second index
- *  @param c Third index
- *  @return newly constructed structure constant */
-ex color_f(const ex & a, const ex & b, const ex & c);
-
-/** Create an su(3) symmetric structure constant.
- *
- *  @param a First index
- *  @param b Second index
- *  @param c Third index
- *  @return newly constructed structure constant */
-ex color_d(const ex & a, const ex & b, const ex & c);
-
-/** This returns the linear combination d.a.b.c+I*f.a.b.c. */
-ex color_h(const ex & a, const ex & b, const ex & c);
-
-/** Calculate color traces over the specified set of representation labels.
- *
- *  @param e Expression to take the trace of
- *  @param rls Set of representation labels */
-ex color_trace(const ex & e, const std::set<unsigned char> & rls);
-
-/** Calculate color traces over the specified list of representation labels.
- *
- *  @param e Expression to take the trace of
- *  @param rll List of representation labels */
-ex color_trace(const ex & e, const lst & rll);
-
-/** Calculate the trace of an expression containing color objects with a
- *  specified representation label.
- *
- *  @param e Expression to take the trace of
- *  @param rl Representation label */
-ex color_trace(const ex & e, unsigned char rl = 0);
-
-
-} // namespace GiNaC
-
-#endif // ndef __GINAC_COLOR_H__
diff --git a/ginac/container.h b/ginac/container.h
index 87c08fb..24f2a06 100644
--- a/ginac/container.h
+++ b/ginac/container.h
@@ -34,6 +34,7 @@
 #include <vector>
 #include <list>
 #include <memory>
+#include <bits/algorithmfwd.h>
 
 namespace GiNaC {
 
@@ -373,21 +374,22 @@ protected:
 	ex conjugate() const
 	{
 		STLT *newcont = nullptr;
-		for (auto i=this->seq.begin(); i!=this->seq.end(); ++i) {
+		for (const auto & elem : this->seq) {
+			const ex conj = elem.conjugate();
 			if (newcont) {
-				newcont->push_back(i->conjugate());
+				newcont->push_back(conj);
 				continue;
 			}
-			ex x = i->conjugate();
-			if (are_ex_trivially_equal(x, *i)) {
+			if (are_ex_trivially_equal(conj, elem)) {
 				continue;
 			}
 			newcont = new STLT;
 			this->reserve(*newcont, this->seq.size());
-			for (auto j=this->seq.begin(); j!=i; ++j) {
-				newcont->push_back(*j);
+			for (const auto & elem2 : this->seq) {
+				if (&elem2 != &elem)
+					newcont->push_back(elem2);
 			}
-			newcont->push_back(x);
+			newcont->push_back(conj);
 		}
 		if (newcont) {
 			ex result = thiscontainer(*newcont);
@@ -401,10 +403,8 @@ protected:
 	{
 		STLT cont;
 		this->reserve(cont, nops());
-		auto b = begin();
-		auto e = end();
-		for(auto i=b; i!=e; ++i)
-			cont.push_back(i->real_part());
+		for (const auto & elem : this->seq)
+			cont.push_back(elem.real_part());
 		return thiscontainer(cont);
 	}
 
@@ -412,10 +412,8 @@ protected:
 	{
 		STLT cont;
 		this->reserve(cont, nops());
-		auto b = begin();
-		auto e = end();
-		for(auto i=b; i!=e; ++i)
-			cont.push_back(i->imag_part());
+		for (const auto & elem : this->seq)
+			cont.push_back(elem.imag_part());
 		return thiscontainer(cont);
 	}
 
@@ -508,15 +506,12 @@ template <template <class T, class = std::allocator<T> > class C>
 void container<C>::archive(archive_node &n) const
 {
 	inherited::archive(n);
-	auto i = this->seq.begin(), end = this->seq.end();
-	while (i != end) {
-		n.add_ex("seq", *i);
-		++i;
-	}
+	for (const auto & elem : this->seq)
+		n.add_ex("seq", elem);
 }
 
 template <template <class T, class = std::allocator<T> > class C>
-void container<C>::do_print(const print_context & c, unsigned level) const
+void container<C>::do_print(const print_context & c, unsigned) const
 {
 	// always print brackets around seq, ignore upper_precedence
 	printseq(c, get_open_delim(), ',', get_close_delim(), precedence(), precedence()+1);
@@ -529,10 +524,8 @@ void container<C>::do_print_tree(const print_tree & c, unsigned level) const
 	    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
 	    << ", nops=" << nops()
 	    << std::endl;
-	auto i = this->seq.begin(), end = this->seq.end();
-	while (i != end) {
-		i->print(c, level + c.delta_indent);
-		++i;
+	for (const auto & elem : this->seq) {
+		elem.print(c, level + c.delta_indent);
 	}
 	c.s << std::string(level + c.delta_indent,' ') << "=====" << std::endl;
 }
@@ -544,7 +537,7 @@ void container<C>::do_print_python(const print_python & c, unsigned level) const
 }
 
 template <template <class T, class = std::allocator<T> > class C>
-void container<C>::do_print_python_repr(const print_python_repr & c, unsigned level) const
+void container<C>::do_print_python_repr(const print_python_repr & c, unsigned) const
 {
 	c.s << class_name();
 	printseq(c, "(", ',', ")", precedence(), precedence()+1);
@@ -635,14 +628,14 @@ bool container<C>::is_equal_same_type(const basic & other) const
 	if (this->seq.size() != o.seq.size())
 		return false;
 
-	auto it1 = this->seq.begin(), it1end = this->seq.end(), it2 = o.seq.begin();
-	while (it1 != it1end) {
-		if (!it1->is_equal(*it2))
-			return false;
-		++it1; ++it2;
-	}
+        auto it1 = this->seq.begin(), it1end = this->seq.end(), it2 = o.seq.begin();
+        while (it1 != it1end) {
+                if (!it1->is_equal(*it2))
+                        return false;
+                ++it1; ++it2;
+       }
 
-	return true;
+       return true;
 }
 
 /** Add element at front. */
@@ -772,10 +765,8 @@ typename container<C>::STLT container<C>::evalchildren(int level) const
 	this->reserve(s, this->seq.size());
 
 	--level;
-	auto it = this->seq.begin(), itend = this->seq.end();
-	while (it != itend) {
-		s.push_back(it->eval(level));
-		++it;
+	for (const auto & elem : this->seq) {
+		s.push_back(elem.eval(level));
 	}
 
 	return s;
@@ -788,8 +779,8 @@ std::unique_ptr<typename container<C>::STLT> container<C>::subschildren(const ex
 	// returns a pointer to a newly created STLT otherwise
 	// (and relinquishes responsibility for the STLT)
 
-	auto cit = this->seq.begin(), end = this->seq.end();
-	while (cit != end) {
+	auto cit = this->seq.begin(), cend = this->seq.end();
+	while (cit != cend) {
 		const ex & subsed_ex = cit->subs(m, options);
 		if (!are_ex_trivially_equal(*cit, subsed_ex)) {
 
@@ -802,7 +793,7 @@ std::unique_ptr<typename container<C>::STLT> container<C>::subschildren(const ex
 			++cit;
 
 			// copy rest
-			while (cit != end) {
+			while (cit != cend) {
 				s->push_back(cit->subs(m, options));
 				++cit;
 			}
diff --git a/ginac/excompiler.h b/ginac/excompiler.h
deleted file mode 100644
index 7122fef..0000000
--- a/ginac/excompiler.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/** @file excompiler.h
- *
- *  Functions to facilitate the conversion of a ex to a function pointer suited for
- *  fast numerical integration.
- *
- */
-
-/*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __GINAC_EXCOMPILER_H__
-#define __GINAC_EXCOMPILER_H__
-
-#include <string>
-
-#include "lst.h"
-
-namespace GiNaC {
-
-class ex;
-class symbol;
-
-/**
- * Function pointer with one function parameter.
- */
-typedef double (*FUNCP_1P) (double);
-
-/**
- * Function pointer with two function parameters.
- */
-typedef double (*FUNCP_2P) (double, double);
-
-/**
- * Function pointer for use with the CUBA library (http://www.feynarts.de/cuba).
- */
-typedef void (*FUNCP_CUBA) (const int*, const double[], const int*, double[]);
-
-/**
- * Takes an expression and produces a function pointer to the compiled and linked
- * C code equivalent in double precision. The function pointer has type FUNCP_1P.
- *
- * @param expr Expression to be compiled
- * @param sym Symbol from the expression to become the function parameter
- * @param fp Returned function pointer
- * @param filename Name of the intermediate source code and so-file. If
- * supplied, these intermediate files will not be deleted
- */
-void compile_ex(const ex& expr, const symbol& sym, FUNCP_1P& fp, const std::string filename = "");
-
-/**
- * Takes an expression and produces a function pointer to the compiled and linked
- * C code equivalent in double precision. The function pointer has type FUNCP_2P.
- *
- * @param expr Expression to be compiled
- * @param sym Symbol from the expression to become the function parameter
- * @param fp Returned function pointer
- * @param filename Name of the intermediate source code and so-file. If
- * supplied, these intermediate files will not be deleted
- */
-void compile_ex(const ex& expr, const symbol& sym1, const symbol& sym2, FUNCP_2P& fp, const std::string filename = "");
-
-/**
- * Takes an expression and produces a function pointer to the compiled and linked
- * C code equivalent in double precision. The function pointer has type FUNCP_CUBA.
- *
- * @param expr Expression to be compiled
- * @param sym Symbol from the expression to become the function parameter
- * @param fp Returned function pointer
- * @param filename Name of the intermediate source code and so-file. If
- * supplied, these intermediate files will not be deleted
- */
-void compile_ex(const lst& exprs, const lst& syms, FUNCP_CUBA& fp, const std::string filename = "");
-
-/** 
- * Opens an existing so-file and returns a function pointer of type FUNCP_1P to
- * the contained function. The so-file has to be generated by compile_ex in
- * advance.
- *
- * @param filename Name of the so-file to open and link
- * @param fp Returned function pointer
- */
-void link_ex(const std::string filename, FUNCP_1P& fp);
-
-/** 
- * Opens an existing so-file and returns a function pointer of type FUNCP_2P to
- * the contained function. The so-file has to be generated by compile_ex in
- * advance.
- *
- * @param filename Name of the so-file to open and link
- * @param fp Returned function pointer
- */
-void link_ex(const std::string filename, FUNCP_2P& fp);
-
-/** 
- * Opens an existing so-file and returns a function pointer of type FUNCP_CUBA to
- * the contained function. The so-file has to be generated by compile_ex in
- * advance.
- *
- * @param filename Name of the so-file to open and link
- * @param fp Returned function pointer
- */
-void link_ex(const std::string filename, FUNCP_CUBA& fp);
-
-/**
- * Closes all linked .so files that have the supplied filename.
- *
- * @param filename Name of the so-file to close
- */
-void unlink_ex(const std::string filename);
-
-} // namespace GiNaC
-
-#endif // ndef __GINAC_EXCOMPILER_H__
diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp
index 5005386..2abb7b7 100644
--- a/ginac/expairseq.cpp
+++ b/ginac/expairseq.cpp
@@ -154,11 +154,11 @@ expairseq::expairseq(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst
 	seq.reserve((last-first)/2);
 
 	for (auto loc = first; loc < last;) {
-		ex rest;
-		ex coeff;
-		n.find_ex_by_loc(loc++, rest, sym_lst);
-		n.find_ex_by_loc(loc++, coeff, sym_lst);
-		seq.push_back(expair(rest, coeff));
+		ex lrest;
+		ex lcoeff;
+		n.find_ex_by_loc(loc++, lrest, sym_lst);
+		n.find_ex_by_loc(loc++, lcoeff, sym_lst);
+		seq.push_back(expair(lrest, lcoeff));
 	}
 
 	n.find_ex("overall_coeff", overall_coeff, sym_lst);
@@ -170,11 +170,9 @@ expairseq::expairseq(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst
 void expairseq::archive(archive_node &n) const
 {
 	inherited::archive(n);
-	auto i = seq.begin(), iend = seq.end();
-	while (i != iend) {
-		n.add_ex("rest", i->rest);
-		n.add_ex("coeff", i->coeff);
-		++i;
+	for (const auto & elem : seq) {
+		n.add_ex("rest", elem.rest);
+		n.add_ex("coeff", elem.coeff);
 	}
 	n.add_ex("overall_coeff", overall_coeff);
 }
@@ -323,11 +321,8 @@ ex expairseq::map(map_function &f) const
 	std::unique_ptr<epvector> v(new epvector);
 	v->reserve(seq.size()+1);
 
-	auto cit = seq.begin(), last = seq.end();
-	while (cit != last) {
-		v->push_back(split_ex_to_pair(f(recombine_pair_to_ex(*cit))));
-		++cit;
-	}
+	for (const auto & elem : seq)
+		v->push_back(split_ex_to_pair(f(recombine_pair_to_ex(elem))));
 
 	if (overall_coeff_equals_default())
 		return thisexpairseq(std::move(v), default_overall_coeff(), true);
@@ -355,23 +350,23 @@ ex expairseq::eval(int level) const
 	return (new expairseq(std::move(vp), overall_coeff))->setflag(status_flags::dynallocated | status_flags::evaluated);
 }
 
-epvector* conjugateepvector(const epvector&epv)
+epvector* conjugateepvector(const epvector& epv)
 {
 	epvector *newepv = nullptr;
-	for (auto i=epv.begin(); i!=epv.end(); ++i) {
-		if(newepv) {
-			newepv->push_back(i->conjugate());
+	for (const auto & elem : epv) {
+		if (newepv) {
+			newepv->push_back(elem.conjugate());
 			continue;
 		}
-		expair x = i->conjugate();
-		if (x.is_equal(*i)) {
+		expair x = elem.conjugate();
+		if (x.is_equal(elem)) {
 			continue;
 		}
 		newepv = new epvector;
 		newepv->reserve(epv.size());
-		for (auto j=epv.begin(); j!=i; ++j) {
-			newepv->push_back(*j);
-		}
+                for (const auto & elem2 : epv)
+                        if (&elem2 != &elem)
+                                newepv->push_back(elem2);
 		newepv->push_back(x);
 	}
 	return newepv;
@@ -379,13 +374,12 @@ epvector* conjugateepvector(const epvector&epv)
 
 ex expairseq::conjugate() const
 {
-	epvector* newepv = conjugateepvector(seq);
+	std::unique_ptr<epvector> newepv(conjugateepvector(seq));
 	ex x = overall_coeff.conjugate();
 	if (!newepv && are_ex_trivially_equal(x, overall_coeff)) {
 		return *this;
 	}
 	ex result = thisexpairseq(newepv ? *newepv : seq, x);
-	delete newepv;
 	return result;
 }
 
@@ -461,17 +455,18 @@ found:		;
 			vp->reserve(num);
 			for (size_t i=0; i<num; i++)
 				vp->push_back(split_ex_to_pair(ops[i]));
-			ex rest = thisexpairseq(std::move(vp), default_overall_coeff());
-            for (auto it = tmp_repl.begin(); it != tmp_repl.end(); ++it) {
-                if (it->op(0).is_equal(global_wildcard)) {
-                    if (rest.is_equal(it->op(1))) {
+
+                        ex rest = thisexpairseq(std::move(vp), default_overall_coeff());
+                        for (const auto & elem : tmp_repl) {
+                                if (elem.op(0).is_equal(global_wildcard)) {
+                                    if (rest.is_equal(elem.op(1))) {
+                                        repl_lst = tmp_repl;
+                                        return true;
+                                        }
+                                return false;
+                                }
+                        }
                         repl_lst = tmp_repl;
-                        return true;
-                    }
-                return false;
-                }
-            }
-            repl_lst = tmp_repl;
 			repl_lst.append(global_wildcard == rest);
 			return true;
 
@@ -504,11 +499,8 @@ ex expairseq::subs(const exmap & m, unsigned options) const
 numeric expairseq::calc_total_degree() const
 {
 	numeric deg = 0;
-	auto cit = seq.begin();
-	auto last = seq.end();
-	for (; (cit!=last); ++cit) {
-		deg = deg.add(ex_to<numeric>(cit->coeff));
-	}
+	for (const auto & elem : seq)
+		deg = deg.add(ex_to<numeric>(elem.coeff));
 	return deg;
 }
 
@@ -612,8 +604,9 @@ bool expairseq::is_equal_same_type(const basic &other) const
 			++cit1;
 			++cit2;
 		}
-		
-		return true;
+                
+                return true;
+
 #if EXPAIRSEQ_USE_HASHTAB
 	}
 	
@@ -650,16 +643,13 @@ unsigned expairseq::return_type() const
 unsigned expairseq::calchash() const
 {
 	unsigned v = golden_ratio_hash((p_int)this->tinfo());
-	auto i = seq.begin();
-	const epvector::const_iterator end = seq.end();
-	while (i != end) {
-		v ^= i->rest.gethash();
+        for (const auto & elem : seq) {
+		v ^= elem.rest.gethash();
 #if !EXPAIRSEQ_USE_HASHTAB
 		// rotation spoils commutativity!
 		v = rotate_left(v);
-		v ^= i->coeff.gethash();
+		v ^= elem.coeff.gethash();
 #endif // !EXPAIRSEQ_USE_HASHTAB
-		++i;
 	}
 
 	v ^= overall_coeff.gethash();
@@ -708,7 +698,7 @@ ex expairseq::thisexpairseq(std::unique_ptr<epvector> vp, const ex &oc, bool do_
 	return expairseq(std::move(vp), oc, do_index_renaming);
 }
 
-void expairseq::printpair(const print_context & c, const expair & p, unsigned upper_precedence) const
+void expairseq::printpair(const print_context & c, const expair & p, unsigned) const
 {
 	c.s << "[[";
 	p.rest.print(c, precedence());
@@ -723,8 +713,9 @@ void expairseq::printseq(const print_context & c, char delim,
 {
 	if (this_precedence <= upper_precedence)
 		c.s << "(";
-	epvector::const_iterator it, it_last = seq.end() - 1;
-	for (it=seq.begin(); it!=it_last; ++it) {
+        auto it = seq.begin();
+        auto it_last = seq.end() - 1;
+        for (; it != it_last; ++it) {
 		printpair(c, *it, this_precedence);
 		c.s << delim;
 	}
@@ -773,7 +764,7 @@ ex expairseq::recombine_pair_to_ex(const expair &p) const
 	return lst(p.rest,p.coeff);
 }
 
-bool expairseq::expair_needs_further_processing(epp it)
+bool expairseq::expair_needs_further_processing(epp)
 {
 #if EXPAIRSEQ_USE_HASHTAB
 	//#  error "FIXME: expair_needs_further_processing not yet implemented for hashtabs, sorry. A.F."
@@ -808,7 +799,7 @@ void expairseq::combine_overall_coeff(const ex &c1, const ex &c2)
 	                add_dyn(ex_to<numeric>(c1).mul(ex_to<numeric>(c2)));
 }
 
-bool expairseq::can_make_flat(const expair &p) const
+bool expairseq::can_make_flat(const expair &) const
 {
 	return true;
 }
@@ -1060,18 +1051,18 @@ void expairseq::construct_from_expairseq_ex(const expairseq &s,
 	}
 }
 
-void expairseq::construct_from_exvector(const exvector &v, bool hold)
+void expairseq::construct_from_exvector(const exvector &v, bool do_hold)
 {
 	// simplifications: +(a,+(b,c),d) -> +(a,b,c,d) (associativity)
 	//                  +(d,b,c,a) -> +(a,b,c,d) (canonicalization)
 	//                  +(...,x,*(x,c1),*(x,c2)) -> +(...,*(x,1+c1+c2)) (c1, c2 numeric)
 	//                  (same for (+,*) -> (*,^)
 
-	make_flat(v, hold);
+	make_flat(v, do_hold);
 #if EXPAIRSEQ_USE_HASHTAB
 	combine_same_terms();
 #else
-	if (!hold) {
+	if (!do_hold) {
 		canonicalize();
 		combine_same_terms_sorted_seq();
 	}
@@ -1096,27 +1087,23 @@ void expairseq::construct_from_epvector(const epvector &v, bool do_index_renamin
 
 /** Combine this expairseq with argument exvector.
  *  It cares for associativity as well as for special handling of numerics. */
-void expairseq::make_flat(const exvector &v, bool hold)
+void expairseq::make_flat(const exvector &v, bool do_hold)
 {
-	exvector::const_iterator cit;
-	
 	// count number of operands which are of same expairseq derived type
 	// and their cumulative number of operands
 	int nexpairseqs = 0;
 	int noperands = 0;
 	bool do_idx_rename = false;
 	
-	if (!hold) {
-		cit = v.begin();
-		while (cit!=v.end()) {
-			if (ex_to<basic>(*cit).tinfo()==this->tinfo()) {
+	if (!do_hold) {
+                for (const auto & elem : v) {
+			if (ex_to<basic>(elem).tinfo()==this->tinfo()) {
 				++nexpairseqs;
-				noperands += ex_to<expairseq>(*cit).seq.size();
+				noperands += ex_to<expairseq>(elem).seq.size();
 			}
 			if (is_a<mul>(*this) && (!do_idx_rename) &&
-					cit->info(info_flags::has_indices))
+					elem.info(info_flags::has_indices))
 				do_idx_rename = true;
-			++cit;
 		}
 	} else
 		this->hold();
@@ -1126,26 +1113,21 @@ void expairseq::make_flat(const exvector &v, bool hold)
 	
 	// copy elements and split off numerical part
 	make_flat_inserter mf(v, do_idx_rename);
-	cit = v.begin();
-	while (cit!=v.end()) {
-		if (ex_to<basic>(*cit).tinfo()==this->tinfo() && !hold) {
-			ex newfactor = mf.handle_factor(*cit, _ex1);
+        for (const auto & elem : v) {
+		if (ex_to<basic>(elem).tinfo()==this->tinfo() && !do_hold) {
+			ex newfactor = mf.handle_factor(elem, _ex1);
 			const expairseq &subseqref = ex_to<expairseq>(newfactor);
 			combine_overall_coeff(subseqref.overall_coeff);
-			auto cit_s = subseqref.seq.begin();
-			while (cit_s!=subseqref.seq.end()) {
-				seq.push_back(*cit_s);
-				++cit_s;
-			}
+                        for (const auto & elem2 : subseqref.seq)
+				seq.push_back(elem2);
 		} else {
-			if (is_exactly_a<numeric>(*cit))
-				combine_overall_coeff(*cit);
+			if (is_exactly_a<numeric>(elem))
+				combine_overall_coeff(elem);
 			else {
-				ex newfactor = mf.handle_factor(*cit, _ex1);
+				ex newfactor = mf.handle_factor(elem, _ex1);
 				seq.push_back(split_ex_to_pair(newfactor));
 			}
 		}
-		++cit;
 	}
 }
 
@@ -1153,24 +1135,20 @@ void expairseq::make_flat(const exvector &v, bool hold)
  *  It cares for associativity as well as for special handling of numerics. */
 void expairseq::make_flat(const epvector &v, bool do_index_renaming)
 {
-	epvector::const_iterator cit;
-	
 	// count number of operands which are of same expairseq derived type
 	// and their cumulative number of operands
 	int nexpairseqs = 0;
 	int noperands = 0;
 	bool really_need_rename_inds = false;
 	
-	cit = v.begin();
-	while (cit!=v.end()) {
-		if (ex_to<basic>(cit->rest).tinfo()==this->tinfo()) {
+        for (const auto & elem : v) {
+		if (ex_to<basic>(elem.rest).tinfo()==this->tinfo()) {
 			++nexpairseqs;
-			noperands += ex_to<expairseq>(cit->rest).seq.size();
+			noperands += ex_to<expairseq>(elem.rest).seq.size();
 		}
 		if ((!really_need_rename_inds) && is_a<mul>(*this) &&
-				cit->rest.info(info_flags::has_indices))
+				elem.rest.info(info_flags::has_indices))
 			really_need_rename_inds = true;
-		++cit;
 	}
 	do_index_renaming = do_index_renaming && really_need_rename_inds;
 	
@@ -1179,35 +1157,29 @@ void expairseq::make_flat(const epvector &v, bool do_index_renaming)
 	make_flat_inserter mf(v, do_index_renaming);
 	
 	// copy elements and split off numerical part
-	cit = v.begin();
-	while (cit!=v.end()) {
-		if (ex_to<basic>(cit->rest).tinfo()==this->tinfo() &&
-		    this->can_make_flat(*cit)) {
-			ex newrest = mf.handle_factor(cit->rest, cit->coeff);
+        for (const auto & elem : v) {
+
+		if (ex_to<basic>(elem.rest).tinfo()==this->tinfo() &&
+		    this->can_make_flat(elem)) {
+			ex newrest = mf.handle_factor(elem.rest, elem.coeff);
 			const expairseq &subseqref = ex_to<expairseq>(newrest);
 			combine_overall_coeff(ex_to<numeric>(subseqref.overall_coeff),
-			                                    ex_to<numeric>(cit->coeff));
-			auto cit_s = subseqref.seq.begin();
-			while (cit_s!=subseqref.seq.end()) {
-				seq.push_back(expair(cit_s->rest,
-				                     ex_to<numeric>(cit_s->coeff).mul_dyn(ex_to<numeric>(cit->coeff))));
-				//seq.push_back(combine_pair_with_coeff_to_pair(*cit_s,
-				//                                              (*cit).coeff));
-				++cit_s;
-			}
+			                                    ex_to<numeric>(elem.coeff));
+                        for (const auto & elem2 : subseqref.seq)
+				seq.push_back(expair(elem2.rest,
+                                        ex_to<numeric>(elem2.coeff).mul_dyn(ex_to<numeric>(elem.coeff))));
 		} else {
-			if (cit->is_canonical_numeric())
-				combine_overall_coeff(mf.handle_factor(cit->rest, _ex1));
+			if (elem.is_canonical_numeric())
+				combine_overall_coeff(mf.handle_factor(elem.rest, _ex1));
 			else {
-				ex rest = cit->rest;
-				ex newrest = mf.handle_factor(rest, cit->coeff);
+				const ex& rest = elem.rest;
+				const ex& newrest = mf.handle_factor(rest, elem.coeff);
 				if (are_ex_trivially_equal(newrest, rest))
-					seq.push_back(*cit);
+					seq.push_back(elem);
 				else
-					seq.push_back(expair(newrest, cit->coeff));
+					seq.push_back(expair(newrest, elem.coeff));
 			}
 		}
-		++cit;
 	}
 }
 
@@ -1620,8 +1592,8 @@ bool expairseq::is_canonical() const
  *  if no members were changed. */
 std::unique_ptr<epvector> expairseq::expandchildren(unsigned options) const
 {
-	const epvector::const_iterator last = seq.end();
 	auto cit = seq.begin();
+	auto last = seq.end();
 	while (cit!=last) {
 		const ex &expanded_ex = cit->rest.expand(options);
 		if (!are_ex_trivially_equal(cit->rest,expanded_ex)) {
diff --git a/ginac/fderivative.cpp b/ginac/fderivative.cpp
index abf2cdc..52e94f1 100644
--- a/ginac/fderivative.cpp
+++ b/ginac/fderivative.cpp
@@ -84,11 +84,8 @@ fderivative::fderivative(const archive_node &n, lst &sym_lst) : inherited(n, sym
 void fderivative::archive(archive_node &n) const
 {
 	inherited::archive(n);
-	auto i = parameter_set.begin(), end = parameter_set.end();
-	while (i != end) {
-		n.add_unsigned("param", *i);
-		++i;
-	}
+        for (const auto & elem : parameter_set)
+		n.add_unsigned("param", elem);
 }
 
 DEFAULT_UNARCHIVE(fderivative)
@@ -103,7 +100,7 @@ void fderivative::print(const print_context & c, unsigned level) const
 	basic::print(c, level);
 }
 
-void fderivative::do_print(const print_context & c, unsigned level) const
+void fderivative::do_print(const print_context & c, unsigned) const
 {
 	//convert paramset to a python list
 	PyObject* params = py_funcs.paramset_to_PyTuple(parameter_set);
@@ -137,12 +134,12 @@ void fderivative::do_print(const print_context & c, unsigned level) const
 	*/
 }
 
-void fderivative::do_print_csrc(const print_csrc & c, unsigned level) const
+void fderivative::do_print_csrc(const print_csrc & c, unsigned) const
 {
 	c.s << "D_";
-	auto i = parameter_set.begin(), end = parameter_set.end();
-	--end;
-	while (i != end)
+	auto i = parameter_set.begin(), iend = parameter_set.end();
+	--iend;
+	while (i != iend)
 		c.s << *i++ << "_";
 	c.s << *i << "_" << registered_functions()[serial].name;
 	printseq(c, "(", ',', ")", exprseq::precedence(), function::precedence());
@@ -155,9 +152,9 @@ void fderivative::do_print_tree(const print_tree & c, unsigned level) const
 	    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
 	    << ", nops=" << nops()
 	    << ", params=";
-	auto i = parameter_set.begin(), end = parameter_set.end();
-	--end;
-	while (i != end)
+	auto i = parameter_set.begin(), iend = parameter_set.end();
+	--iend;
+	while (i != iend)
 		c.s << *i++ << ",";
 	c.s << *i << std::endl;
 	for (auto & elem : seq)
diff --git a/ginac/function.cpp b/ginac/function.cpp
index 0e08feb..63554d5 100644
--- a/ginac/function.cpp
+++ b/ginac/function.cpp
@@ -577,13 +577,12 @@ function::function(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 	if (n.find_string("name", s)) {
 		unsigned int ser = 0;
 		unsigned int nargs = seq.size();
-		std::vector<function_options>::const_iterator i = registered_functions().begin(), iend = registered_functions().end();
-		while (i != iend) {
-			if (s == i->name && nargs == i->nparams) {
+                for (const auto & elem : registered_functions()) {
+			if (s == elem.name && nargs == elem.nparams) {
 				serial = ser;
 				return;
 			}
-			++i; ++ser;
+			++ser;
 		}
 		// if the name is not already in the registry, we are
 		// unarchiving a SymbolicFunction without any custom methods
@@ -650,7 +649,7 @@ void function::print(const print_context & c, unsigned level) const
 	GINAC_ASSERT(serial<registered_functions().size());
 	// Dynamically dispatch on print_context type
 	const print_context_class_info *pc_info = &c.get_class_info();
-	if (serial >= py_funcs.py_get_ginac_serial()) {
+	if (serial >= static_cast<unsigned>(py_funcs.py_get_ginac_serial())) {
 		//convert arguments to a PyTuple of Expressions
 		PyObject* args = py_funcs.exvector_to_PyTuple(seq);
 
@@ -842,11 +841,8 @@ ex function::evalf(int level, PyObject* kwds) const
 	else {
 		eseq.reserve(seq.size());
 		--level;
-		auto it = seq.begin(), itend = seq.end();
-		while (it != itend) {
-			eseq.push_back(it->evalf(level, kwds));
-			++it;
-		}
+                for (const auto & elem : seq)
+			eseq.push_back(elem.evalf(level, kwds));
 	}
 
 	if (opt.evalf_f==nullptr) {
@@ -1159,8 +1155,8 @@ ex function::imag_part() const
  *  @see ex::diff */
 ex function::derivative(const symbol & s) const
 {
-	ex result;
-
+        ex result;
+        
 	/*
 	if (serial == Order_SERIAL::serial) {
 		// Order Term function only differentiates the argument
@@ -1193,7 +1189,7 @@ ex function::derivative(const symbol & s) const
 				throw(std::runtime_error("function::derivative(): python function raised exception"));
 			}
 			// convert output Expression to an ex
-			ex result = py_funcs.pyExpression_to_ex(pyresult);
+			result = py_funcs.pyExpression_to_ex(pyresult);
 			Py_DECREF(pyresult);
 			if (PyErr_Occurred()) { 
 				throw(std::runtime_error("function::derivative(): python function (pyExpression_to_ex) raised exception"));
@@ -1480,12 +1476,10 @@ unsigned function::register_new(function_options const & opt)
  *  Throws exception if function was not found. */
 unsigned function::find_function(const std::string &name, unsigned nparams)
 {
-	std::vector<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
 	unsigned serial = 0;
-	while (i != end) {
-		if (i->get_name() == name && i->get_nparams() == nparams)
+        for (const auto & elem : registered_functions()) {
+		if (elem.get_name() == name && elem.get_nparams() == nparams)
 			return serial;
-		++i;
 		++serial;
 	}
 	throw (std::runtime_error("no function '" + name + "' with " + ToString(nparams) + " parameters defined"));
@@ -1498,5 +1492,37 @@ std::string function::get_name() const
 	return registered_functions()[serial].name;
 }
 
+bool function::info(unsigned inf) const
+{
+	if (get_serial() == exp_SERIAL::serial)
+        {
+                const ex& arg = op(0);
+                switch (inf) {
+                case info_flags::real:
+                        return arg.info(info_flags::real);
+                case info_flags::positive:
+                        return arg.info(info_flags::real);
+                }
+        }
+	else if (get_serial() == log_SERIAL::serial)
+        {
+                const ex& arg = op(0);
+                switch (inf) {
+                case info_flags::real:
+                        return arg.info(info_flags::positive);
+                case info_flags::positive:
+                        return arg.info(info_flags::real) and
+                                is_exactly_a<numeric>(arg) and
+                                ex_to<numeric>(arg) >= *_num1_p;
+                case info_flags::negative:
+                        return arg.info(info_flags::real) and
+                                is_exactly_a<numeric>(arg) and
+                                arg.info(info_flags::positive) and
+                                ex_to<numeric>(arg) < *_num1_p;
+                }
+        }
+        return false;
+}
+
 } // namespace GiNaC
 
diff --git a/ginac/function.h b/ginac/function.h
index 0635e53..052639d 100644
--- a/ginac/function.h
+++ b/ginac/function.h
@@ -349,6 +349,7 @@ public:
 	ex conjugate() const;
 	ex real_part() const;
 	ex imag_part() const;
+	bool info(unsigned inf) const;
 	//int compare(const basic &other) const;
 protected:
 	ex derivative(const symbol & s) const;
diff --git a/ginac/ginac.h b/ginac/ginac.h
index d8373ba..26bece3 100644
--- a/ginac/ginac.h
+++ b/ginac/ginac.h
@@ -41,7 +41,6 @@
 #include "numeric.h"
 #include "power.h"
 #include "relational.h"
-#include "structure.h"
 #include "symbol.h"
 #include "pseries.h"
 #include "wildcard.h"
@@ -59,12 +58,10 @@
 #include "inifcns.h"
 #include "fderivative.h"
 #include "operators.h"
-#include "hash_map.h"
 
 #include "idx.h"
 #include "indexed.h"
 #include "tensor.h"
-#include "color.h"
 #include "clifford.h"
 
 #ifdef __MAKECINT__
diff --git a/ginac/hash_map.h b/ginac/hash_map.h
deleted file mode 100644
index e7aa924..0000000
--- a/ginac/hash_map.h
+++ /dev/null
@@ -1,597 +0,0 @@
-/** @file hash_map.h
- *
- *  Replacement for map<> using hash tables. */
-
-/*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __GINAC_HASH_MAP_H__
-#define __GINAC_HASH_MAP_H__
-
-#include <list>
-#include <iterator>
-#include <algorithm>
-#include <functional>
-#include <utility>
-
-
-namespace GiNaC {
-
-/*
- *  "Hashmap Light" - buckets only contain one value, quadratic probing,
- *  grows automatically
- */
-
-namespace internal {
-
-// List of prime numbers shamelessly stolen from GCC STL
-enum { num_primes = 29 };
-
-static const unsigned long prime_list[num_primes] =
-{
-	31ul,        53ul,         97ul,         193ul,       389ul,
-	769ul,       1543ul,       3079ul,       6151ul,      12289ul,
-	24593ul,     49157ul,      98317ul,      196613ul,    393241ul,
-	786433ul,    1572869ul,    3145739ul,    6291469ul,   12582917ul,
-	25165843ul,  50331653ul,   100663319ul,  201326611ul, 402653189ul,
-	805306457ul, 1610612741ul, 3221225473ul, 4294967291ul
-};
-
-inline unsigned long next_prime(unsigned long n)
-{
-	const unsigned long *first = prime_list;
-	const unsigned long *last = prime_list + num_primes;
-	const unsigned long *pos = std::lower_bound(first, last, n);
-	return pos == last ? *(last - 1) : *pos;
-}
-
-} // namespace internal
-
-
-// Define default arguments
-template <typename T, template <class> class A = std::allocator>
-class exhashmap;
-
-
-/** Pair Associative Container with 'ex' objects as keys, that is implemented
- *  with a hash table and can be used as a replacement for map<> in many cases.
- *
- *  Differences to map<>:
- *   - no lower_bound()/upper_bound()
- *   - no reverse iterators, no rbegin()/rend()
- *   - no operator<()
- *   - comparison functor is hardcoded to ex_is_less
- *   - bucket_count() returns the number of buckets allocated in the hash table
- *   - insert() and erase() invalidate all iterators
- *   - average complexity of find() is constant time, worst case is O(n) */
-template <typename T, template <class> class A>
-class exhashmap {
-public:
-	static const unsigned min_num_buckets = 31; // must be prime
-
-	// Standard types
-	typedef ex key_type;
-	typedef T mapped_type;
-	typedef std::pair<key_type, T> value_type;
-	typedef ex_is_less key_compare;
-	typedef ex_is_equal key_equal;
-	typedef value_type & reference;
-	typedef const value_type & const_reference;
-	typedef value_type * pointer;
-	typedef const value_type * const_pointer;
-
-protected:
-	// Private types
-	enum bucket_state {
-		EMPTY,  ///< bucket empty (never used)
-		USED,   ///< bucket in use
-		ERASED  ///< bucket empty (element deleted), but may be part of a search chain
-	};
-	typedef std::pair<bucket_state, value_type> Bucket;
-
-public:
-	// More standard types
-	typedef A<Bucket> allocator_type;
-
-protected:
-	// More private types
-	typedef std::vector<Bucket, allocator_type> Table;
-
-	typedef typename Table::iterator table_iterator;
-	typedef typename Table::const_iterator table_const_iterator;
-
-public:
-	// Iterators
-	template <typename Pointer, typename Reference, class TableIterator>
-	class exhashmap_iterator : public std::iterator<std::forward_iterator_tag, value_type, typename Table::difference_type, Pointer, Reference> {
-	protected:
-		friend class exhashmap;
-
-	public:
-		exhashmap_iterator() {}
-		exhashmap_iterator(TableIterator t, TableIterator te)
-		 : it(t), table_end(te) {}
-
-		// Allow iterator to const_iterator conversion
-		template <typename P, typename R, class TI>
-		exhashmap_iterator(const exhashmap_iterator<P, R, TI> &other)
-		 : it(other.get_it_()), table_end(other.get_table_end_()) {}
-
-		typename exhashmap_iterator::reference operator*() const
-		{
-			return it->second;
-		}
-
-		typename exhashmap_iterator::pointer operator->() const
-		{
-			return &(it->second);
-		}
-
-		exhashmap_iterator &operator++()
-		{
-			increment();
-			return *this;
-		}
-
-		exhashmap_iterator operator++(int)
-		{
-			exhashmap_iterator tmp = *this;
-			increment();
-			return tmp;
-		}
-
-		template <typename P, typename R, class TI>
-		bool operator==(const exhashmap_iterator<P, R, TI> &other) const
-		{
-			return it == other.get_it_();
-		}
-
-		template <typename P, typename R, class TI>
-		bool operator!=(const exhashmap_iterator<P, R, TI> &other) const
-		{
-			return it != other.get_it_();
-		}
-
-		// Private access function
-		TableIterator get_it_() const { return it; }
-		TableIterator get_table_end_() const { return table_end; }
-
-	protected:
-		TableIterator it;        ///< Pointer to current bucket
-		TableIterator table_end; ///< Pointer to one-past-last bucket
-
-		void increment()
-		{
-			if (it != table_end)
-				++it;
-
-			// Skip empty and erased buckets
-			while (it != table_end && it->first != USED)
-				++it;
-		}
-	};
-
-	typedef exhashmap_iterator<value_type*, value_type&, table_iterator> iterator;
-	typedef exhashmap_iterator<const value_type*, const value_type&, table_const_iterator> const_iterator;
-
-	// More standard types
-	typedef typename Table::size_type size_type;
-	typedef typename Table::difference_type difference_type;
-
-	class value_compare : public std::binary_function<value_type, value_type, bool>, private key_compare {
-		friend class exhashmap;
-	public:
-		bool operator()(const value_type &lhs, const value_type &rhs) const
-		{
-			return key_compare::operator()(lhs.first, rhs.first);
-		}
-
-		bool operator()(const key_type &lhs, const value_type &rhs) const
-		{
-			return key_compare::operator()(lhs, rhs.first);
-		}
-
-		bool operator()(const value_type &lhs, const key_type &rhs) const
-		{
-			return key_compare::operator()(lhs.first, rhs);
-		}
-	};
-
-protected:
-	// Private data
-	size_type num_entries; ///< Number of values stored in container (cached for faster operation of size())
-	size_type num_buckets; ///< Number of buckets (= hashtab.size())
-	Table hashtab;         ///< Vector of buckets, each bucket is kept sorted
-
-	/** Return index of key in hash table. */
-	static size_type hash_index(const key_type &x, size_type nbuckets)
-	{
-		return x.gethash() % nbuckets;
-	}
-
-	static table_iterator find_bucket(const key_type &x, table_iterator tab, size_type nbuckets);
-	static table_const_iterator find_bucket(const key_type &x, table_const_iterator tab, size_type nbuckets);
-	static table_iterator find_bucket_for_insertion(const key_type &x, table_iterator tab, size_type nbuckets);
-
-	/** Return pointer to bucket corresponding to key (or first empty bucket). */
-	table_iterator find_bucket(const key_type &x)
-	{
-		return find_bucket(x, hashtab.begin(), num_buckets);
-	}
-
-	/** Return pointer to bucket corresponding to key (or first empty bucket). */
-	table_const_iterator find_bucket(const key_type &x) const
-	{
-		return find_bucket(x, hashtab.begin(), num_buckets);
-	}
-
-	/** Return pointer to bucket corresponding to key (or first empty or erased bucket). */
-	table_iterator find_bucket_for_insertion(const key_type &x)
-	{
-		return find_bucket_for_insertion(x, hashtab.begin(), num_buckets);
-	}
-
-	/** Return number of entries above which the table will grow. */
-	size_type hwm() const
-	{
-		// Try to keep at least 25% of the buckets free
-		return num_buckets - (num_buckets >> 2);
-	}
-
-	void grow();
-
-public:
-	// 23.3.1.1 Construct/copy/destroy
-	exhashmap()
-	 : num_entries(0), num_buckets(min_num_buckets), hashtab(num_buckets, std::make_pair(EMPTY, std::make_pair(0, mapped_type()))) {}
-
-	explicit exhashmap(size_type nbuckets)
-	 : num_entries(0), num_buckets(internal::next_prime(nbuckets)), hashtab(num_buckets, std::make_pair(EMPTY, std::make_pair(0, mapped_type()))) {}
-
-	template <class InputIterator>
-	exhashmap(InputIterator first, InputIterator last)
-	 : num_entries(0), num_buckets(min_num_buckets), hashtab(num_buckets, std::make_pair(EMPTY, std::make_pair(0, mapped_type())))
-	{
-		insert(first, last);
-	}
-
-	exhashmap &operator=(const exhashmap &other)
-	{
-		exhashmap(other).swap(*this);
-		return *this;
-	}
-
-	// Iterators
-	iterator begin()
-	{
-		// Find first used bucket
-		table_iterator bucket = hashtab.begin();
-		while (bucket != hashtab.end() && bucket->first != USED)
-			++bucket;
-		return iterator(bucket, hashtab.end());
-	}
-
-	const_iterator begin() const
-	{
-		// Find first used bucket
-		table_const_iterator bucket = hashtab.begin();
-		while (bucket != hashtab.end() && bucket->first != USED)
-			++bucket;
-		return const_iterator(bucket, hashtab.end());
-	}
-
-	iterator end()
-	{
-		return iterator(hashtab.end(), hashtab.end());
-	}
-
-	const_iterator end() const
-	{
-		return const_iterator(hashtab.end(), hashtab.end());
-	}
-
-	// Capacity
-	bool empty() const
-	{
-		return num_entries == 0;
-	}
-
-	size_type size() const
-	{
-		return num_entries;
-	}
-
-	size_type max_size() const
-	{
-		return hashtab.max_size();
-	}
-
-	size_type bucket_count() const
-	{
-		return num_buckets;
-	}
-
-	// 23.3.1.2 Element access
-	T &operator[](const key_type &x)
-	{
-		return insert(value_type(x, mapped_type())).first->second;
-	}
-
-	// Modifiers
-	std::pair<iterator, bool> insert(const value_type &x);
-
-	iterator insert(iterator pos, const value_type &x)
-	{
-		return insert(x).first;
-	}
-
-	template <class InputIterator>
-	void insert(InputIterator first, InputIterator last)
-	{
-		for (; first != last; ++first)
-			insert(*first);
-	}
-
-	void erase(iterator position)
-	{
-		table_iterator bucket = position.get_it_();
-		bucket->first = ERASED;
-		bucket->second.first = 0;
-		--num_entries;
-	}
-
-	size_type erase(const key_type &x);
-
-	void swap(exhashmap &other)
-	{
-		hashtab.swap(other.hashtab);
-		std::swap(num_buckets, other.num_buckets);
-		std::swap(num_entries, other.num_entries);
-	}
-
-	void clear();
-
-	// Observers
-	key_compare key_comp() const
-	{
-		return key_compare();
-	}
-
-	value_compare value_comp() const
-	{
-		return value_compare();
-	}
-
-	// 23.3.1.3 Map operations
-	iterator find(const key_type &x);
-	const_iterator find(const key_type &x) const;
-
-	size_type count(const key_type &x) const
-	{
-		return find(x) == end() ? 0 : 1;
-	}
-
-	std::pair<iterator, iterator> equal_range(const key_type &x)
-	{
-		iterator i = find(x);
-		if (i == end())
-			return std::make_pair(i, i);
-		else {
-			iterator j = ++i;
-			return std::make_pair(i, j);
-		}
-	}
-
-	std::pair<const_iterator, const_iterator> equal_range(const key_type &x) const
-	{
-		const_iterator i = find(x);
-		if (i == end())
-			return std::make_pair(i, i);
-		else {
-			const_iterator j = ++i;
-			return std::make_pair(i, j);
-		}
-	}
-
-	friend bool operator==(const exhashmap &lhs, const exhashmap &rhs)
-	{
-		if (lhs.num_entries != rhs.num_entries || lhs.num_buckets != rhs.num_buckets)
-			return false;
-
-		// We can't compare the tables directly as the elements may be
-		// in different order due to the collision handling. We therefore
-		// look up each value from the lhs map in the rhs map separately.
-		for (const_iterator itl = lhs.begin(); itl != lhs.end(); ++itl) {
-			const_iterator itr = rhs.find(itl->first);
-			if (itr == rhs.end())
-				return false;
-			if (itl->second != itr->second)
-				return false;
-		}
-		return true;
-	}
-
-	friend bool operator!=(const exhashmap &lhs, const exhashmap &rhs)
-	{
-		return !(lhs == rhs);
-	}
-
-#if 0
-	void dump() const
-	{
-		std::clog << "num_entries = " << num_entries << std::endl;
-		std::clog << "num_buckets = " << num_buckets << std::endl;
-		size_type t = 0;
-		for (table_const_iterator it = hashtab.begin(); it != hashtab.end(); ++it, ++t) {
-			std::clog << " bucket " << t << ": ";
-			std::clog << (it->first == EMPTY ? "free" : (it->first == USED ? "used" : "erased")) << ", " << it->second.first << " -> " << it->second.second << std::endl;
-		}
-	}
-#endif
-};
-
-/** Return pointer to bucket corresponding to key (or first empty bucket). */
-template <typename T, template <class> class A>
-inline typename exhashmap<T, A>::table_iterator exhashmap<T, A>::find_bucket(const key_type &x, table_iterator tab, size_type nbuckets)
-{
-	// Quadratic probing
-	size_type h = hash_index(x, nbuckets);
-	size_type d = 1;
-	table_iterator it = tab + h;
-	while (it->first != EMPTY && !(it->first == USED && key_equal()(it->second.first, x))) {
-		h = (h + d) % nbuckets;
-		d += 2;
-		it = tab + h;
-	}
-	return it;
-}
-
-/** Return pointer to bucket corresponding to key (or first empty bucket). */
-template <typename T, template <class> class A>
-inline typename exhashmap<T, A>::table_const_iterator exhashmap<T, A>::find_bucket(const key_type &x, table_const_iterator tab, size_type nbuckets)
-{
-	// Quadratic probing
-	size_type h = hash_index(x, nbuckets);
-	size_type d = 1;
-	table_const_iterator it = tab + h;
-	while (it->first != EMPTY && !(it->first == USED && key_equal()(it->second.first, x))) {
-		h = (h + d) % nbuckets;
-		d += 2;
-		it = tab + h;
-	}
-	return it;
-}
-
-/** Return pointer to bucket corresponding to key (or first empty or erased bucket). */
-template <typename T, template <class> class A>
-inline typename exhashmap<T, A>::table_iterator exhashmap<T, A>::find_bucket_for_insertion(const key_type &x, table_iterator tab, size_type nbuckets)
-{
-	// Quadratic probing
-	size_type h = hash_index(x, nbuckets);
-	size_type d = 1;
-	table_iterator it = tab + h;
-	while (it->first != EMPTY && !key_equal()(it->second.first, x)) {
-		h = (h + d) % nbuckets;
-		d += 2;
-		it = tab + h;
-	}
-	return it;
-}
-
-/** Grow hash table */
-template <typename T, template <class> class A>
-void exhashmap<T, A>::grow()
-{
-	// Allocate new empty hash table
-	size_type new_num_buckets = internal::next_prime(num_buckets + 1);
-	Table new_hashtab;
-	new_hashtab.resize(new_num_buckets);
-	for (table_iterator it = new_hashtab.begin(); it != new_hashtab.end(); ++it)
-		it->first = EMPTY;
-
-	// Re-insert all elements into new table
-	for (table_const_iterator it = hashtab.begin(); it != hashtab.end(); ++it) {
-		if (it->first == USED) {
-			table_iterator bucket = find_bucket(it->second.first, new_hashtab.begin(), new_num_buckets);
-			*bucket = *it;
-		}
-	}
-
-	// Swap with the old table
-	hashtab.swap(new_hashtab);
-	num_buckets = new_num_buckets;
-}
-
-template <typename T, template <class> class A>
-std::pair<typename exhashmap<T, A>::iterator, bool> exhashmap<T, A>::insert(const value_type &x)
-{
-	table_iterator bucket = find_bucket_for_insertion(x.first);
-	if (bucket->first == USED) {
-		// Value already in map
-		return std::make_pair(iterator(bucket, hashtab.end()), false);
-	} else {
-		// Insert new value
-		bucket->first = USED;
-		bucket->second = x;
-		++num_entries;
-		if (num_entries >= hwm()) {
-			grow();
-			bucket = find_bucket(x.first);
-		}
-		return std::make_pair(iterator(bucket, hashtab.end()), true);
-	}
-}
-
-template <typename T, template <class> class A>
-typename exhashmap<T, A>::size_type exhashmap<T, A>::erase(const key_type &x)
-{
-	iterator i = find(x);
-	if (i != end()) {
-		erase(i);
-		return 1;
-	} else
-		return 0;
-}
-
-template <typename T, template <class> class A>
-typename exhashmap<T, A>::iterator exhashmap<T, A>::find(const key_type &x)
-{
-	table_iterator bucket = find_bucket(x);
-	if (bucket->first == USED)
-		return iterator(bucket, hashtab.end());
-	else
-		return end();
-}
-
-template <typename T, template <class> class A>
-typename exhashmap<T, A>::const_iterator exhashmap<T, A>::find(const key_type &x) const
-{
-	table_const_iterator bucket = find_bucket(x);
-	if (bucket->first == USED)
-		return const_iterator(bucket, hashtab.end());
-	else
-		return end();
-}
-
-template <typename T, template <class> class A>
-void exhashmap<T, A>::clear()
-{
-	for (table_iterator i = hashtab.begin(); i != hashtab.end(); ++i) {
-		i->first = EMPTY;
-		i->second.first = 0;
-		i->second.second = mapped_type();
-	}
-	num_entries = 0;
-}
-
-} // namespace GiNaC
-
-
-// Specializations of Standard Library algorithms
-namespace std {
-
-/** Specialization of std::swap() for exhashmap. */
-template <typename T, template <class> class A>
-inline void swap(GiNaC::exhashmap<T, A> &lhs, GiNaC::exhashmap<T, A> &rhs)
-{
-	lhs.swap(rhs);
-}
-
-} // namespace std
-
-#endif // ndef __GINAC_HASH_MAP_H__
diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp
index a2e3839..8ca24cd 100644
--- a/ginac/indexed.cpp
+++ b/ginac/indexed.cpp
@@ -408,7 +408,7 @@ void indexed::validate() const
 /** Implementation of ex::diff() for an indexed object always returns 0.
  *
  *  @see ex::diff */
-ex indexed::derivative(const symbol & s) const
+ex indexed::derivative(const symbol &) const
 {
 	return _ex0;
 }
@@ -1276,7 +1276,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
  *
  *  @param options Simplification options (currently unused)
  *  @return simplified expression */
-ex ex::simplify_indexed(unsigned options) const
+ex ex::simplify_indexed(unsigned) const
 {
 	exvector free_indices, dummy_indices;
 	scalar_products sp;
@@ -1291,7 +1291,7 @@ ex ex::simplify_indexed(unsigned options) const
  *  @param sp Scalar products to be replaced automatically
  *  @param options Simplification options (currently unused)
  *  @return simplified expression */
-ex ex::simplify_indexed(const scalar_products & sp, unsigned options) const
+ex ex::simplify_indexed(const scalar_products & sp, unsigned) const
 {
 	exvector free_indices, dummy_indices;
 	return GiNaC::simplify_indexed(*this, free_indices, dummy_indices, sp);
@@ -1378,12 +1378,12 @@ void scalar_products::add(const ex & v1, const ex & v2, const ex & dim, const ex
 	spm[spmapkey(v1, v2, dim)] = sp;
 }
 
-void scalar_products::add_vectors(const lst & l, const ex & dim)
+void scalar_products::add_vectors(const lst & l, const ex &)
 {
 	// Add all possible pairs of products
-	for (auto it1 = l.begin(); it1 != l.end(); ++it1)
-		for (const auto & elem : l)
-			add(*it1, elem, *it1 * elem);
+        for (const auto & elem1 : l)
+		for (const auto & elem2 : l)
+			add(elem1, elem2, elem1 * elem2);
 }
 
 void scalar_products::clear()
@@ -1426,7 +1426,7 @@ exvector get_all_dummy_indices_safely(const ex & e)
 	else if (is_a<mul>(e) || is_a<ncmul>(e)) {
 		exvector dummies;
 		exvector free_indices;
-		for (int i=0; i<e.nops(); ++i) {
+		for (unsigned i=0; i<e.nops(); ++i) {
 			exvector dummies_of_factor = get_all_dummy_indices_safely(e.op(i));
 			dummies.insert(dummies.end(), dummies_of_factor.begin(),
 				dummies_of_factor.end());
@@ -1442,7 +1442,7 @@ exvector get_all_dummy_indices_safely(const ex & e)
 	}
 	else if(is_a<add>(e)) {
 		exvector result;
-		for(int i=0; i<e.nops(); ++i) {
+		for(unsigned i=0; i<e.nops(); ++i) {
 			exvector dummies_of_term = get_all_dummy_indices_safely(e.op(i));
 			sort(dummies_of_term.begin(), dummies_of_term.end());
 			exvector new_vec;
diff --git a/ginac/infinity.cpp b/ginac/infinity.cpp
index cd5b6b0..570d477 100644
--- a/ginac/infinity.cpp
+++ b/ginac/infinity.cpp
@@ -156,7 +156,7 @@ void infinity::do_print_latex(const print_latex & c, unsigned level) const
 	}
 }
 
-void infinity::do_print_python_repr(const print_python_repr & c, unsigned level) const
+void infinity::do_print_python_repr(const print_python_repr & c, unsigned) const
 {
 	c.s << class_name() << "('" << "Infinity" << "'" << direction;
 	c.s << ')';
@@ -177,7 +177,7 @@ bool infinity::info(unsigned inf) const
 	return inherited::info(inf);
 }
 
-ex infinity::evalf(int level, PyObject* parent) const
+ex infinity::evalf(int, PyObject*) const
 {
 	if (is_unsigned_infinity())
 		return py_funcs.py_eval_unsigned_infinity();
@@ -215,7 +215,7 @@ ex infinity::imag_part() const
 
 // protected
 
-ex infinity::derivative(const symbol & s) const
+ex infinity::derivative(const symbol &) const
 {
 	return _ex0;
 }
@@ -309,13 +309,14 @@ const infinity & infinity::operator += (const ex & rhs)
 	if (not is_exactly_a<infinity>(rhs))
 		return *this;
 	const ex & rhs_direction = ex_to<infinity>(rhs).direction;
-	if (not direction.is_equal(rhs_direction) )
+	if (not direction.is_equal(rhs_direction) ) {
 		if (ex_to<infinity>(rhs).is_unsigned_infinity() or is_unsigned_infinity())
 			throw(std::runtime_error("indeterminate expression: "
 						 "unsigned_infinity +- infinity encountered."));
 		else
 			throw(std::runtime_error("indeterminate expression: "
 						 "infinity - infinity encountered."));
+        }
 	return *this;
 }
 
diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp
index 321370e..9df4f6d 100644
--- a/ginac/inifcns.cpp
+++ b/ginac/inifcns.cpp
@@ -192,36 +192,50 @@ static ex abs_eval(const ex & arg)
 	if (is_exactly_a<numeric>(arg))
 		return abs(ex_to<numeric>(arg));
 
-	if (arg.info(info_flags::nonnegative))
+	if (arg.info(info_flags::nonnegative) or arg.info(info_flags::positive))
 		return arg;
 
-	if (arg.info(info_flags::negative) || (-arg).info(info_flags::nonnegative))
+	if (arg.info(info_flags::negative) or (-arg).info(info_flags::nonnegative))
 		return -arg;
 
-	if (is_ex_the_function(arg, abs))
-		return arg;
-
-	if (is_ex_the_function(arg, exp))
-		return exp(arg.op(0).real_part());
-
-	if (is_exactly_a<mul>(arg)) {
-                const ex& mex = ex_to<mul>(arg);
-                const int n_ops = mex.nops();
-                ex prod_re = _ex1;
-                ex prod_ir = _ex1;
-                for (int i=0; i<n_ops; ++i) {
-                        const ex& factor = mex.op(i);
-                        if (factor.info(info_flags::real) and
-                                (is_exactly_a<numeric>(factor)
-                                or is_exactly_a<constant>(factor)))
-                                prod_re *= factor;
+        if (is_exactly_a<function>(arg)) {                
+                if (is_ex_the_function(arg, abs))
+                        return arg;
+                if (is_ex_the_function(arg, exp))
+                        return exp(arg.op(0).real_part());
+                if (is_ex_the_function(arg, conjugate_function))
+                        return abs(arg.op(0));
+                if (is_ex_the_function(arg, step))
+                        return arg;
+                return abs(arg).hold();
+        }
+
+        if (is_exactly_a<mul>(arg)) {
+                ex prod = _ex1;
+                ex prod_sy = _ex1;
+                bool is_prod_neg = false;
+                for (size_t i=0; i<arg.nops(); ++i) {
+                        const ex& factor = arg.op(i);
+                        if (has_symbol(factor))
+                                prod_sy *= factor;
+                        else if (factor.info(info_flags::real)) {
+                                if (factor.info(info_flags::negative)) {                                        
+                                        is_prod_neg = not is_prod_neg;
+                                        prod *= factor;
+                                }
+                                else if (factor.info(info_flags::positive))                                        
+                                        prod *= factor;
+                                else
+                                        prod *= abs(factor).hold();
+                        }
                         else
-                                prod_ir *= factor;
+                                prod *= abs(factor);
                 }
-                if (is_exactly_a<numeric>(prod_ir))
-                        return abs(prod_re) * abs(prod_ir);
-                else
-                        return abs(prod_re) * abs(prod_ir).hold();
+                if (is_prod_neg)
+                        prod *= _ex_1;
+                if (not prod_sy.is_integer_one())
+                        prod *= abs(prod_sy).hold();
+                return prod;
 	}
 
 	if (is_exactly_a<power>(arg)) {
@@ -231,12 +245,6 @@ static ex abs_eval(const ex & arg)
 			return pow(abs(base), exponent.real_part());
 	}
 
-	if (is_ex_the_function(arg, conjugate_function))
-		return abs(arg.op(0));
-
-	if (is_ex_the_function(arg, step))
-		return arg;
-
 	return abs(arg).hold();
 }
 
diff --git a/ginac/inifcns_nstdsums.cpp b/ginac/inifcns_nstdsums.cpp
index e132d93..fc8c8c8 100644
--- a/ginac/inifcns_nstdsums.cpp
+++ b/ginac/inifcns_nstdsums.cpp
@@ -101,7 +101,8 @@ namespace GiNaC {
 // anonymous namespace for helper functions
 namespace {
 
-
+/*
+ * 
 // lookup table for factors built from Bernoulli numbers
 // see fill_Xn()
 //std::vector<std::vector<numeric> > Xn;
@@ -126,7 +127,6 @@ namespace {
 // The second index in Xn corresponds to the index from the actual sum.
 void fill_Xn(int n)
 {
-  /*
 	if (n>1) {
 		// calculate X_2 and higher (corresponding to Li_4 and higher)
 		std::vector<Number_T> buf(xninitsize);
@@ -188,13 +188,11 @@ void fill_Xn(int n)
 	}
 
 	xnsize++;
-  */
 }
 
 // doubles the number of entries in each Xn[]
 void double_Xn()
 {
-  /*
 	const int pos0 = xninitsize / 2;
 	// X_0
 	for (int i=1; i<=xninitsizestep/2; ++i) {
@@ -236,14 +234,12 @@ void double_Xn()
 		}
 	}
 	xninitsize += xninitsizestep;
-  */
 }
 
 
 // calculates Li(2,x) without Xn
 numeric Li2_do_sum(const numeric& x)
 {
-  /*
 	Number_T res = x;
 	Number_T resbuf;
 	Number_T num = x ;
@@ -257,14 +253,11 @@ numeric Li2_do_sum(const numeric& x)
 		res = res + num / den;
 	} while (res != resbuf);
 	return res;
-  */
 }
 
-
 // calculates Li(2,x) with Xn
 numeric Li2_do_sum_Xn(const numeric& x)
 {
-  /*
 	std::vector<Number_T>::const_iterator it = Xn[0].begin();
 	std::vector<Number_T>::const_iterator xend = Xn[0].end();
 	Number_T u = -log(1-x);
@@ -285,15 +278,13 @@ numeric Li2_do_sum_Xn(const numeric& x)
 		}
 	} while (res != resbuf);
 	return res;
-  */
 }
 
 
 // calculates Li(n,x), n>2 without Xn
 numeric Lin_do_sum(int n, const numeric& x)
 {
-  /*
-	Number_T factor = x;
+  	Number_T factor = x;
 	Number_T res = x;
 	Number_T resbuf;
 	int i=2;
@@ -304,10 +295,8 @@ numeric Lin_do_sum(int n, const numeric& x)
 		i++;
 	} while (res != resbuf);
 	return res;
-  */
 }
 
-
 // calculates Li(n,x), n>2 with Xn
 numeric Lin_do_sum_Xn(int n, const numeric& x)
 {
@@ -332,7 +321,6 @@ numeric Lin_do_sum_Xn(int n, const numeric& x)
 // 	return res;
 }
 
-
 // forward declaration needed by function Li_projection and C below
 numeric S_num(int n, int p, const numeric& x);
 
@@ -392,12 +380,13 @@ numeric S_num(int n, int p, const numeric& x);
 // 		}
 // 	}
 // }
-
+*/
 
 // helper function for classical polylog Li
 numeric Lin_numeric(const numeric& n, const numeric& x, PyObject* parent)
 {
   return Li2(x, n, parent);
+
 // 	if (n == 1) {
 // 		// just a log
 // 		return -cln::log(1-x.to_cl_N());
@@ -478,6 +467,7 @@ numeric Lin_numeric(const numeric& n, const numeric& x, PyObject* parent)
 //
 //////////////////////////////////////////////////////////////////////
 
+/*
 
 // anonymous namespace for helper function
 namespace {
@@ -517,11 +507,9 @@ numeric multipleLi_do_sum(const std::vector<int>& s, const std::vector<numeric>&
 // 	return t[0];
 }
 
-
 // converts parameter types and calls multipleLi_do_sum (convenience function for G_numeric)
 numeric mLi_do_summation(const lst& m, const lst& x)
 {
-  /*
 	std::vector<int> m_int;
 	std::vector<Number_T> x_cln;
 	for (lst::const_iterator itm = m.begin(), itx = x.begin(); itm != m.end(); ++itm, ++itx) {
@@ -529,10 +517,8 @@ numeric mLi_do_summation(const lst& m, const lst& x)
 		x_cln.push_back(ex_to<numeric>(*itx).to_cl_N());
 	}
 	return multipleLi_do_sum(m_int, x_cln);
-  */
 }
 
-
 // forward declaration for Li_eval()
 lst convert_parameter_Li_to_H(const lst& m, const lst& x, ex& pf);
 
@@ -548,7 +534,6 @@ typedef std::vector<int> Gparameter;
 // G_eval1-function for G transformations
 ex G_eval1(int a, int scale)
 {
-  /*
 	if (a != 0) {
 		const ex& scs = gsyms[std::abs(scale)];
 		const ex& as = gsyms[std::abs(a)];
@@ -560,15 +545,12 @@ ex G_eval1(int a, int scale)
 	} else {
 		return log(gsyms[std::abs(scale)]);
 	}
-  */
 }
 
-
 // G_eval-function for G transformations
 ex G_eval(const Gparameter& a, int scale)
 {
-  /*
-	// check for properties of G
+ 	// check for properties of G
 	ex sc = gsyms[std::abs(scale)];
 	lst newa;
 	bool all_zero = true;
@@ -651,14 +633,11 @@ ex G_eval(const Gparameter& a, int scale)
 		}
 	}
 	return pow(-1, x.nops()) * Li(m, x);
-  */
 }
 
-
 // converts data for G: pending_integrals -> a
 Gparameter convert_pending_integrals_G(const Gparameter& pending_integrals)
 {
-  /*
 	GINAC_ASSERT(pending_integrals.size() != 1);
 
 	if (pending_integrals.size() > 0) {
@@ -670,10 +649,8 @@ Gparameter convert_pending_integrals_G(const Gparameter& pending_integrals)
 		Gparameter new_a;
 		return new_a;
 	}
-  */
 }
 
-
 // check the parameters a and scale for G and return information about convergence, depth, etc.
 // convergent     : true if G(a,scale) is convergent
 // depth          : depth of G(a,scale)
@@ -682,7 +659,6 @@ Gparameter convert_pending_integrals_G(const Gparameter& pending_integrals)
 Gparameter::const_iterator check_parameter_G(const Gparameter& a, int scale,
 		bool& convergent, int& depth, int& trailing_zeros, Gparameter::const_iterator& min_it)
 {
-  /*
 	convergent = true;
 	depth = 0;
 	trailing_zeros = 0;
@@ -706,14 +682,11 @@ Gparameter::const_iterator check_parameter_G(const Gparameter& a, int scale,
 	if (lastnonzero == a.end())
 		return a.end();
 	return ++lastnonzero;
-  */
 }
 
-
 // add scale to pending_integrals if pending_integrals is empty
 Gparameter prepare_pending_integrals(const Gparameter& pending_integrals, int scale)
 {
-  /*
 	GINAC_ASSERT(pending_integrals.size() != 1);
 
 	if (pending_integrals.size() > 0) {
@@ -723,14 +696,11 @@ Gparameter prepare_pending_integrals(const Gparameter& pending_integrals, int sc
 		new_pending_integrals.push_back(scale);
 		return new_pending_integrals;
 	}
-  */
 }
 
-
 // handles trailing zeroes for an otherwise convergent integral
 ex trailing_zeros_G(const Gparameter& a, int scale)
 {
-  /*
 	bool convergent;
 	int depth, trailing_zeros;
 	Gparameter::const_iterator last, dummyit;
@@ -753,14 +723,11 @@ ex trailing_zeros_G(const Gparameter& a, int scale)
 	} else {
 		return G_eval(a, scale);
 	}
-  */
 }
 
-
 // G transformation [VSW] (57),(58)
 ex depth_one_trafo_G(const Gparameter& pending_integrals, const Gparameter& a, int scale)
 {
-  /*
 	// pendint = ( y1, b1, ..., br )
 	//       a = ( 0, ..., 0, amin )
 	//   scale = y2
@@ -832,10 +799,8 @@ ex depth_one_trafo_G(const Gparameter& pending_integrals, const Gparameter& a, i
 	}
 
 	return result;
-  */
 }
 
-
 // forward declaration
 ex shuffle_G(const Gparameter & a0, const Gparameter & a1, const Gparameter & a2,
 	     const Gparameter& pendint, const Gparameter& a_old, int scale);
@@ -844,7 +809,6 @@ ex shuffle_G(const Gparameter & a0, const Gparameter & a1, const Gparameter & a2
 // G transformation [VSW]
 ex G_transform(const Gparameter& pendint, const Gparameter& a, int scale)
 {
-  /*
 	// main recursion routine
 	//
 	// pendint = ( y1, b1, ..., br )
@@ -966,16 +930,13 @@ ex G_transform(const Gparameter& pendint, const Gparameter& a, int scale)
 		result += G_transform(new_pendint, new_a, scale);
 	}
 	return result;
-  */
 }
 
-
 // shuffles the two parameter list a1 and a2 and calls G_transform for every term except
 // for the one that is equal to a_old
 ex shuffle_G(const Gparameter & a0, const Gparameter & a1, const Gparameter & a2,
 	     const Gparameter& pendint, const Gparameter& a_old, int scale) 
 {
-  /*
 	if (a1.size()==0 && a2.size()==0) {
 		// veto the one configuration we don't want
 		if ( a0 == a_old ) return 0;
@@ -1008,15 +969,12 @@ ex shuffle_G(const Gparameter & a0, const Gparameter & a1, const Gparameter & a2
 
 	return shuffle_G(a01,a1_removed,a2,pendint,a_old,scale)
 	     + shuffle_G(a02,a1,a2_removed,pendint,a_old,scale);
-  */
 }
 
-
 // handles the transformations and the numerical evaluation of G
 // the parameter x, s and y must only contain numerics
 ex G_numeric(const lst& x, const lst& s, const ex& y)
 {
-  /*
 	// check for convergence and necessary accelerations
 	bool need_trafo = false;
 	bool need_hoelder = false;
@@ -1185,13 +1143,10 @@ ex G_numeric(const lst& x, const lst& s, const ex& y)
 	}
 
 	return sign * numeric(mLi_do_summation(m, newx));
-  */
 }
 
-
 ex mLi_numeric(const lst& m, const lst& x)
 {
-  /*
 	// let G_numeric do the transformation
 	lst newx;
 	lst s;
@@ -1206,11 +1161,10 @@ ex mLi_numeric(const lst& m, const lst& x)
 		s.append(1);
 	}
 	return pow(-1, m.nops()) * G_numeric(newx, s, _ex1);
-  */
 }
-
-
+        
 } // end of anonymous namespace
+*/
 
 
 //////////////////////////////////////////////////////////////////////
@@ -1221,10 +1175,10 @@ ex mLi_numeric(const lst& m, const lst& x)
 //
 //////////////////////////////////////////////////////////////////////
 
+/*
 
 static ex G2_evalf(const ex& x_, const ex& y, PyObject* parent)
 {
-  /*
 	if (!y.info(info_flags::positive)) {
 		return G(x_, y).hold();
 	}
@@ -1250,14 +1204,11 @@ static ex G2_evalf(const ex& x_, const ex& y, PyObject* parent)
 		return pow(log(y), x.nops()) / factorial(x.nops());
 	}
 	return G_numeric(x, s, y);
-  */
 }
 
-
 static ex G2_eval(const ex& x_, const ex& y)
 {
 	//TODO eval to MZV or H or S or Lin
-  /*
 	if (!y.info(info_flags::positive)) {
 		return G(x_, y).hold();
 	}
@@ -1293,7 +1244,6 @@ static ex G2_eval(const ex& x_, const ex& y)
 		return G(x_, y).hold();
 	}
 	return G_numeric(x, s, y);
-  */
 }
 
 
@@ -1309,7 +1259,6 @@ unsigned G2_SERIAL::serial = function::register_new(function_options("G", 2).
 
 static ex G3_evalf(const ex& x_, const ex& s_, const ex& y, PyObject* parent)
 {
-  /*
 	if (!y.info(info_flags::positive)) {
 		return G(x_, s_, y).hold();
 	}
@@ -1346,14 +1295,12 @@ static ex G3_evalf(const ex& x_, const ex& s_, const ex& y, PyObject* parent)
 		return pow(log(y), x.nops()) / factorial(x.nops());
 	}
 	return G_numeric(x, sn, y);
-  */
 }
 
 
 static ex G3_eval(const ex& x_, const ex& s_, const ex& y)
 {
 	//TODO eval to MZV or H or S or Lin
-  /*
 	if (!y.info(info_flags::positive)) {
 		return G(x_, s_, y).hold();
 	}
@@ -1400,7 +1347,6 @@ static ex G3_eval(const ex& x_, const ex& s_, const ex& y)
 		return G(x_, s_, y).hold();
 	}
 	return G_numeric(x, sn, y);
-  */
 }
 
 
@@ -1413,6 +1359,7 @@ unsigned G3_SERIAL::serial = function::register_new(function_options("G", 3).
 //                                derivative_func(G3_deriv).
 //                                print_func<print_latex>(G3_print_latex).
 
+ */
 
 //////////////////////////////////////////////////////////////////////
 //
@@ -1438,6 +1385,7 @@ static ex Li_evalf(const ex& m_, const ex& x_, PyObject* parent)
 		}
 	}
 	// multiple polylogs
+        /*
 	if (is_a<lst>(m_) && is_a<lst>(x_)) {
 
 		const lst& m = ex_to<lst>(m_);
@@ -1465,7 +1413,7 @@ static ex Li_evalf(const ex& m_, const ex& x_, PyObject* parent)
 		}
 
 		return mLi_numeric(m, x);
-	}
+	}*/
 
 	return Li(m_,x_).hold();
 }
@@ -1473,6 +1421,7 @@ static ex Li_evalf(const ex& m_, const ex& x_, PyObject* parent)
 
 static ex Li_eval(const ex& m_, const ex& x_)
 {
+        /*
 	if (is_a<lst>(m_)) {
 		if (is_a<lst>(x_)) {
 			// multiple polylogs
@@ -1523,7 +1472,7 @@ static ex Li_eval(const ex& m_, const ex& x_)
 		return Li(m_, x_).hold();
 	} else if (is_a<lst>(x_)) {
 		return Li(m_, x_).hold();
-	}
+	}*/
 
 	// classical polylogs
 	if (x_ == _ex0) {
@@ -1670,6 +1619,7 @@ unsigned Li_SERIAL::serial = function::register_new(function_options("polylog",
 //
 //////////////////////////////////////////////////////////////////////
 
+/*
 
 // anonymous namespace for helper functions
 namespace {
@@ -2022,6 +1972,7 @@ numeric S_num(int n, int p, const numeric& x)
 
 } // end of anonymous namespace
 
+*/
 
 //////////////////////////////////////////////////////////////////////
 //
@@ -2031,10 +1982,10 @@ numeric S_num(int n, int p, const numeric& x)
 //
 //////////////////////////////////////////////////////////////////////
 
+/*
 
 static ex S_evalf(const ex& n, const ex& p, const ex& x, PyObject* parent)
 {
-  /*
 	if (n.info(info_flags::posint) && p.info(info_flags::posint)) {
 		if (is_a<numeric>(x)) {
 			return S_num(ex_to<numeric>(n).to_int(), ex_to<numeric>(p).to_int(), ex_to<numeric>(x));
@@ -2046,13 +1997,11 @@ static ex S_evalf(const ex& n, const ex& p, const ex& x, PyObject* parent)
 		}
 	}
 	return S(n, p, x).hold();
-  */
 }
 
 
 static ex S_eval(const ex& n, const ex& p, const ex& x)
 {
-  /*
 	if (n.info(info_flags::posint) && p.info(info_flags::posint)) {
 		if (x == 0) {
 			return _ex0;
@@ -2076,13 +2025,11 @@ static ex S_eval(const ex& n, const ex& p, const ex& x)
 		return pow(-log(1-x), p) / factorial(p);
 	}
 	return S(n, p, x).hold();
-  */
 }
 
 
 static ex S_series(const ex& n, const ex& p, const ex& x, const relational& rel, int order, unsigned options)
 {
-  /*
 	if (p == _ex1) {
 		return Li(n+1, x).series(rel, order, options);
 	}
@@ -2125,13 +2072,11 @@ static ex S_series(const ex& n, const ex& p, const ex& x, const relational& rel,
 	}
 	// all other cases should be safe, by now:
 	throw do_taylor();  // caught by function::series()
-  */
 }
 
 
 static ex S_deriv(const ex& n, const ex& p, const ex& x, unsigned deriv_param)
 {
-  /*
 	GINAC_ASSERT(deriv_param < 3);
 	if (deriv_param < 2) {
 		return _ex0;
@@ -2141,13 +2086,11 @@ static ex S_deriv(const ex& n, const ex& p, const ex& x, unsigned deriv_param)
 	} else {
 		return S(n, p-1, x) / (1-x);
 	}
-  */
 }
 
 
 static void S_print_latex(const ex& n, const ex& p, const ex& x, const print_context& c)
 {
-  /*
 	c.s << "{\\rm S}_{";
 	n.print(c);
 	c.s << ",";
@@ -2155,7 +2098,6 @@ static void S_print_latex(const ex& n, const ex& p, const ex& x, const print_con
 	c.s << "}(";
 	x.print(c);
 	c.s << ")";
-  */
 }
 
 
@@ -2167,6 +2109,7 @@ REGISTER_FUNCTION(S,
                   print_func<print_latex>(S_print_latex).
                   do_not_evalf_params());
 
+ */
 
 //////////////////////////////////////////////////////////////////////
 //
@@ -2176,7 +2119,8 @@ REGISTER_FUNCTION(S,
 //
 //////////////////////////////////////////////////////////////////////
 
-
+/*
+ * 
 // anonymous namespace for helper functions
 namespace {
 
@@ -2190,7 +2134,6 @@ symbol H_polesign("IMSIGN");
 // returns true if some parameters are negative
 bool convert_parameter_H_to_Li(const lst& l, lst& m, lst& s, ex& pf)
 {
-  /*
 	// expand parameter list
 	lst mexp;
 	for (lst::const_iterator it = l.begin(); it != l.end(); it++) {
@@ -2242,7 +2185,6 @@ bool convert_parameter_H_to_Li(const lst& l, lst& m, lst& s, ex& pf)
 	}
 	
 	return has_negative_parameters;
-  */
 }
 
 
@@ -2321,7 +2263,6 @@ struct map_trafo_H_convert_to_zeta : public map_function
 // remove trailing zeros from H-parameters
 struct map_trafo_H_reduce_trailing_zeros : public map_function
 {
-  /*
 	ex operator()(const ex& e)
 	{
 		if (is_a<add>(e) || is_a<mul>(e)) {
@@ -2390,27 +2331,23 @@ struct map_trafo_H_reduce_trailing_zeros : public map_function
 		}
 		return e;
 	}
-  */
 };
 
 
 // returns an expression with zeta functions corresponding to the parameter list for H
 ex convert_H_to_zeta(const lst& m)
 {
-  /*
 	symbol xtemp("xtemp");
 	map_trafo_H_reduce_trailing_zeros filter;
 	map_trafo_H_convert_to_zeta filter2;
 	return filter2(filter(H(m, xtemp).hold())).subs(xtemp == 1);
-  */
 }
 
 
 // convert signs form Li to H representation
 lst convert_parameter_Li_to_H(const lst& m, const lst& x, ex& pf)
 {
-  /*
-	lst res;
+ 	lst res;
 	lst::const_iterator itm = m.begin();
 	lst::const_iterator itx = ++x.begin();
 	int signum = 1;
@@ -2425,7 +2362,6 @@ lst convert_parameter_Li_to_H(const lst& m, const lst& x, ex& pf)
 		itx++;
 	}
 	return res;
-  */
 }
 
 
@@ -2433,7 +2369,6 @@ lst convert_parameter_Li_to_H(const lst& m, const lst& x, ex& pf)
 // [ReV] (18)
 ex trafo_H_mult(const ex& h1, const ex& h2)
 {
-  /*
 	ex res;
 	ex hshort;
 	lst hlong;
@@ -2463,7 +2398,6 @@ ex trafo_H_mult(const ex& h1, const ex& h2)
 		res += H(newparameter, h1.op(1)).hold();
 	}
 	return res;
-  */
 }
 
 
@@ -2535,7 +2469,6 @@ struct map_trafo_H_mult : public map_function
 // put parameter 0 in front of existing parameters
 ex trafo_H_1tx_prepend_zero(const ex& e, const ex& arg)
 {
-  /*
 	ex h;
 	std::string name;
 	if (is_a<function>(e)) {
@@ -2561,7 +2494,6 @@ ex trafo_H_1tx_prepend_zero(const ex& e, const ex& arg)
 	} else {
 		return e * (-H(lst(0),1/arg).hold());
 	}
-  */
 }
 
 
@@ -2569,7 +2501,6 @@ ex trafo_H_1tx_prepend_zero(const ex& e, const ex& arg)
 // put parameter 1 in front of existing parameters
 ex trafo_H_prepend_one(const ex& e, const ex& arg)
 {
-  /*
 	ex h;
 	std::string name;
 	if (is_a<function>(e)) {
@@ -2594,7 +2525,6 @@ ex trafo_H_prepend_one(const ex& e, const ex& arg)
 	} else {
 		return e * H(lst(1),1-arg).hold();
 	}
-  */
 }
 
 
@@ -2602,7 +2532,6 @@ ex trafo_H_prepend_one(const ex& e, const ex& arg)
 // put parameter -1 in front of existing parameters
 ex trafo_H_1tx_prepend_minusone(const ex& e, const ex& arg)
 {
-  /*
 	ex h;
 	std::string name;
 	if (is_a<function>(e)) {
@@ -2660,7 +2589,6 @@ ex trafo_H_1mxt1px_prepend_minusone(const ex& e, const ex& arg)
 	} else {
 		return (e * H(lst(-1),(1-arg)/(1+arg)).hold()).expand();
 	}
-  */
 }
 
 
@@ -2668,7 +2596,6 @@ ex trafo_H_1mxt1px_prepend_minusone(const ex& e, const ex& arg)
 // put parameter 1 in front of existing parameters
 ex trafo_H_1mxt1px_prepend_one(const ex& e, const ex& arg)
 {
-  /*
 	ex h;
 	std::string name;
 	if (is_a<function>(e)) {
@@ -2693,7 +2620,6 @@ ex trafo_H_1mxt1px_prepend_one(const ex& e, const ex& arg)
 	} else {
 		return (e * H(lst(1),(1-arg)/(1+arg)).hold()).expand();
 	}
-  */
 }
 
 
@@ -2801,7 +2727,6 @@ struct map_trafo_H_1mx : public map_function
 // do x -> 1/x transformation
 struct map_trafo_H_1overx : public map_function
 {
-  /*
 	ex operator()(const ex& e)
 	{
 		if (is_a<add>(e) || is_a<mul>(e)) {
@@ -2917,14 +2842,12 @@ struct map_trafo_H_1overx : public map_function
 		}
 		return e;
 	}
-  */
 };
 
 
 // do x -> (1-x)/(1+x) transformation
 struct map_trafo_H_1mxt1px : public map_function
 {
-  /*
 	ex operator()(const ex& e)
 	{
 		if (is_a<add>(e) || is_a<mul>(e)) {
@@ -3042,7 +2965,6 @@ struct map_trafo_H_1mxt1px : public map_function
 		}
 		return e;
 	}
-  */
 };
 
 
@@ -3074,6 +2996,7 @@ numeric H_do_sum(const std::vector<int>& m, const numeric& x)
 
 } // end of anonymous namespace
 
+ */
 
 //////////////////////////////////////////////////////////////////////
 //
@@ -3083,6 +3006,7 @@ numeric H_do_sum(const std::vector<int>& m, const numeric& x)
 //
 //////////////////////////////////////////////////////////////////////
 
+/*
 
 static ex H_evalf(const ex& x1, const ex& x2, PyObject* parent)
 {
@@ -3404,7 +3328,6 @@ REGISTER_FUNCTION(H,
 // takes a parameter list for H and returns an expression with corresponding multiple polylogarithms
 ex convert_H_to_Li(const ex& m, const ex& x)
 {
-  /*
 	map_trafo_H_reduce_trailing_zeros filter;
 	map_trafo_H_convert_to_Li filter2;
 	if (is_a<lst>(m)) {
@@ -3412,9 +3335,8 @@ ex convert_H_to_Li(const ex& m, const ex& x)
 	} else {
 		return filter2(filter(H(lst(m), x).hold()));
 	}
-  */
 }
-
+*/
 
 //////////////////////////////////////////////////////////////////////
 //
@@ -3424,6 +3346,7 @@ ex convert_H_to_Li(const ex& m, const ex& x)
 //
 //////////////////////////////////////////////////////////////////////
 
+/*
 
 // anonymous namespace for helper functions
 namespace {
@@ -3488,7 +3411,6 @@ void initcX(const std::vector<int>& s)
 // 	}
 }
 
-
 // [Cra] section 4
 numeric crandall_Y_loop(const numeric& Sqk)
 {
@@ -3682,7 +3604,6 @@ numeric zeta_do_sum_simple(const std::vector<int>& r)
 // does Hoelder convolution. see [BBB] (7.0)
 numeric zeta_do_Hoelder_convolution(const std::vector<int>& m_, const std::vector<int>& s_)
 {
-  /*
 	// prepare parameters
 	// holds Li arguments in [BBB] notation
 	std::vector<int> s = s_;
@@ -3763,12 +3684,12 @@ numeric zeta_do_Hoelder_convolution(const std::vector<int>& m_, const std::vecto
 	res = res + signum * multipleLi_do_sum(m_q, s_q);
 
 	return res;
-  */
 }
 
 
 } // end of anonymous namespace
 
+ */
 
 //////////////////////////////////////////////////////////////////////
 //
@@ -3781,6 +3702,7 @@ numeric zeta_do_Hoelder_convolution(const std::vector<int>& m_, const std::vecto
 
 static ex zeta1_evalf(const ex& x, PyObject* parent)
 {
+        /*
 	if (is_exactly_a<lst>(x) && (x.nops()>1)) {
 
 		// multiple zeta value
@@ -3813,7 +3735,7 @@ static ex zeta1_evalf(const ex& x, PyObject* parent)
 		} else {
 			return numeric(zeta_do_sum_simple(r));
 		}
-	}
+	}*/
 
 	// single zeta value
 	if (x == 1) {
@@ -3932,6 +3854,7 @@ unsigned zeta1_SERIAL::serial = function::register_new(function_options("zeta",
 
 static ex zeta2_evalf(const ex& x, const ex& s, PyObject* parent)
 {
+        /*
 	if (is_exactly_a<lst>(x)) {
 
 		// alternating Euler sum
@@ -3969,7 +3892,7 @@ static ex zeta2_evalf(const ex& x, const ex& s, PyObject* parent)
 
 		// use Hoelder convolution
 		return numeric(zeta_do_Hoelder_convolution(xi, si));
-	}
+	}*/
 
 	return zeta(x, s).hold();
 }
diff --git a/ginac/input_lexer.cc b/ginac/input_lexer.cc
deleted file mode 100644
index e98bd92..0000000
--- a/ginac/input_lexer.cc
+++ /dev/null
@@ -1,1824 +0,0 @@
-#define yy_create_buffer ginac_yy_create_buffer
-#define yy_delete_buffer ginac_yy_delete_buffer
-#define yy_scan_buffer ginac_yy_scan_buffer
-#define yy_scan_string ginac_yy_scan_string
-#define yy_scan_bytes ginac_yy_scan_bytes
-#define yy_flex_debug ginac_yy_flex_debug
-#define yy_init_buffer ginac_yy_init_buffer
-#define yy_flush_buffer ginac_yy_flush_buffer
-#define yy_load_buffer_state ginac_yy_load_buffer_state
-#define yy_switch_to_buffer ginac_yy_switch_to_buffer
-#define yyin ginac_yyin
-#define yyleng ginac_yyleng
-#define yylex ginac_yylex
-#define yyout ginac_yyout
-#define yyrestart ginac_yyrestart
-#define yytext ginac_yytext
-#define yywrap ginac_yywrap
-
-#line 20 "input_lexer.cc"
-/* A lexical scanner generated by flex */
-
-/* Scanner skeleton version:
- * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
- */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-
-#include <stdio.h>
-#include <unistd.h>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
-
-#ifdef __cplusplus
-
-#include <stdlib.h>
-
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else	/* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-
-#endif	/* __STDC__ */
-#endif	/* ! __cplusplus */
-
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index.  If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition.  This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state.  The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START ((yy_start - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#define YY_BUF_SIZE 16384
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator).  This
- * avoids problems with code like:
- *
- * 	if ( condition_holds )
- *		yyless( 5 );
- *	else
- *		do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
-#define yyless(n) \
-	do \
-		{ \
-		/* Undo effects of setting up yytext. */ \
-		*yy_cp = yy_hold_char; \
-		YY_RESTORE_YY_MORE_OFFSET \
-		yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
-		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
-		} \
-	while ( 0 )
-
-#define unput(c) yyunput( c, yytext_ptr )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-typedef unsigned int yy_size_t;
-
-
-struct yy_buffer_state
-	{
-	FILE *yy_input_file;
-
-	char *yy_ch_buf;		/* input buffer */
-	char *yy_buf_pos;		/* current position in input buffer */
-
-	/* Size of input buffer in bytes, not including room for EOB
-	 * characters.
-	 */
-	yy_size_t yy_buf_size;
-
-	/* Number of characters read into yy_ch_buf, not including EOB
-	 * characters.
-	 */
-	int yy_n_chars;
-
-	/* Whether we "own" the buffer - i.e., we know we created it,
-	 * and can realloc() it to grow it, and should free() it to
-	 * delete it.
-	 */
-	int yy_is_our_buffer;
-
-	/* Whether this is an "interactive" input source; if so, and
-	 * if we're using stdio for input, then we want to use getc()
-	 * instead of fread(), to make sure we stop fetching input after
-	 * each newline.
-	 */
-	int yy_is_interactive;
-
-	/* Whether we're considered to be at the beginning of a line.
-	 * If so, '^' rules will be active on the next match, otherwise
-	 * not.
-	 */
-	int yy_at_bol;
-
-	/* Whether to try to fill the input buffer when we reach the
-	 * end of it.
-	 */
-	int yy_fill_buffer;
-
-	int yy_buffer_status;
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
-	/* When an EOF's been seen but there's still some text to process
-	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
-	 * shouldn't try reading from the input source any more.  We might
-	 * still have a bunch of tokens to match, though, because of
-	 * possible backing-up.
-	 *
-	 * When we actually see the EOF, we change the status to "new"
-	 * (via yyrestart()), so that the user can continue scanning by
-	 * just pointing yyin at a new input file.
-	 */
-#define YY_BUFFER_EOF_PENDING 2
-	};
-
-static YY_BUFFER_STATE yy_current_buffer = 0;
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- */
-#define YY_CURRENT_BUFFER yy_current_buffer
-
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-
-static int yy_n_chars;		/* number of characters read into yy_ch_buf */
-
-
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1;		/* whether we need to initialize */
-static int yy_start = 0;	/* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin.  A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart YY_PROTO(( FILE *input_file ));
-
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
-
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
-
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-static void yy_flex_free YY_PROTO(( void * ));
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
-	{ \
-	if ( ! yy_current_buffer ) \
-		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
-	yy_current_buffer->yy_is_interactive = is_interactive; \
-	}
-
-#define yy_set_bol(at_bol) \
-	{ \
-	if ( ! yy_current_buffer ) \
-		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
-	yy_current_buffer->yy_at_bol = at_bol; \
-	}
-
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
-
-typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-typedef int yy_state_type;
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
-	yytext_ptr = yy_bp; \
-	yyleng = (int) (yy_cp - yy_bp); \
-	yy_hold_char = *yy_cp; \
-	*yy_cp = '\0'; \
-	yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 22
-#define YY_END_OF_BUFFER 23
-static yyconst short int yy_accept[72] =
-    {   0,
-        0,    0,   23,   21,    1,    1,   21,   21,   21,   12,
-       21,   21,   21,   20,   20,   20,   20,   20,    6,   20,
-        1,    9,    0,    0,    0,    0,   18,   17,   12,    0,
-       10,    8,   11,   20,   20,   20,   20,   20,    2,    0,
-       14,   15,   16,    0,   17,    0,    0,   19,   20,   20,
-       20,   20,   13,    0,   18,    0,    0,   17,   20,   20,
-       20,    5,    0,   17,   20,   20,    3,   20,    7,    4,
-        0
-    } ;
-
-static yyconst int yy_ec[256] =
-    {   0,
-        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    2,    4,    1,    5,    1,    1,    1,    1,    1,
-        1,    1,    6,    1,    6,    7,    1,    8,    8,    9,
-        9,    9,    9,    9,    9,   10,   10,    1,    1,   11,
-       12,   13,    1,    1,   14,   15,   16,   17,   18,   19,
-       20,   20,   21,   20,   20,   22,   20,   20,   20,   23,
-       20,   24,   20,   20,   20,   20,   20,   20,   20,   20,
-        1,    1,    1,    1,   20,    1,   25,   26,   15,   15,
-
-       27,   15,   28,   20,   29,   20,   20,   30,   20,   31,
-       32,   20,   20,   33,   34,   35,   36,   20,   20,   37,
-       20,   20,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1
-    } ;
-
-static yyconst int yy_meta[38] =
-    {   0,
-        1,    1,    1,    1,    1,    1,    1,    2,    2,    2,
-        1,    1,    1,    2,    2,    2,    2,    2,    2,    3,
-        3,    3,    3,    3,    2,    2,    2,    3,    3,    3,
-        3,    3,    3,    3,    3,    3,    3
-    } ;
-
-static yyconst short int yy_base[75] =
-    {   0,
-        0,    0,  153,  169,   36,   38,  139,   34,   37,   65,
-      138,  137,  136,    0,  122,  117,  109,  126,    0,  110,
-       46,  169,   43,  129,   46,    0,   88,  111,    0,   53,
-      169,  169,  169,    0,  101,  107,  104,  107,    0,    0,
-      109,   48,    0,   70,  134,   76,   60,   80,   91,   85,
-       67,   71,    0,   91,   94,   99,  103,  114,   61,   46,
-       44,    0,  117,  122,   40,   30,    0,   27,    0,    0,
-      169,  163,   48,  165
-    } ;
-
-static yyconst short int yy_def[75] =
-    {   0,
-       71,    1,   71,   71,   71,   71,   71,   71,   71,   71,
-       71,   71,   71,   72,   72,   72,   72,   72,   72,   72,
-       71,   71,   71,   71,   71,   73,   71,   71,   10,   71,
-       71,   71,   71,   72,   72,   72,   72,   72,   72,   74,
-       71,   71,   73,   71,   71,   71,   71,   71,   72,   72,
-       72,   72,   74,   71,   71,   71,   71,   71,   72,   72,
-       72,   72,   71,   71,   72,   72,   72,   72,   72,   72,
-        0,   71,   71,   71
-    } ;
-
-static yyconst short int yy_nxt[207] =
-    {   0,
-        4,    5,    6,    7,    8,    4,    9,   10,   10,   10,
-       11,   12,   13,   14,   14,   15,   16,   17,   18,   14,
-       19,   14,   20,   14,   14,   14,   14,   14,   14,   14,
-       14,   14,   14,   14,   14,   14,   14,   21,   21,   21,
-       21,   23,   23,   23,   27,   27,   27,   21,   21,   43,
-       23,   23,   23,   42,   42,   42,   42,   70,   47,   24,
-       48,   48,   48,   69,   68,   25,   40,   48,   48,   48,
-       26,   28,   29,   29,   29,   54,   67,   55,   55,   55,
-       66,   57,   30,   58,   58,   58,   30,   48,   48,   48,
-       65,   30,   62,   61,   30,   27,   27,   27,   55,   55,
-
-       55,   55,   55,   55,   63,   44,   64,   64,   64,   44,
-       58,   58,   58,   60,   44,   59,   41,   44,   45,   45,
-       45,   58,   58,   58,   64,   64,   64,   52,   46,   64,
-       64,   64,   46,   51,   50,   49,   41,   46,   39,   38,
-       46,   45,   45,   45,   37,   36,   35,   33,   32,   31,
-       22,   56,   71,   71,   71,   56,   71,   71,   71,   71,
-       56,   71,   71,   56,   34,   34,   53,   53,    3,   71,
-       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
-       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
-       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
-
-       71,   71,   71,   71,   71,   71
-    } ;
-
-static yyconst short int yy_chk[207] =
-    {   0,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    5,    5,    6,
-        6,    8,    8,    8,    9,    9,    9,   21,   21,   73,
-       23,   23,   23,   25,   25,   42,   42,   68,   30,    8,
-       30,   30,   30,   66,   65,    8,   23,   47,   47,   47,
-        8,   10,   10,   10,   10,   44,   61,   44,   44,   44,
-       60,   46,   10,   46,   46,   46,   10,   48,   48,   48,
-       59,   10,   52,   51,   10,   27,   27,   27,   54,   54,
-
-       54,   55,   55,   55,   56,   27,   56,   56,   56,   27,
-       57,   57,   57,   50,   27,   49,   41,   27,   28,   28,
-       28,   58,   58,   58,   63,   63,   63,   38,   28,   64,
-       64,   64,   28,   37,   36,   35,   24,   28,   20,   18,
-       28,   45,   45,   45,   17,   16,   15,   13,   12,   11,
-        7,   45,    3,    0,    0,   45,    0,    0,    0,    0,
-       45,    0,    0,   45,   72,   72,   74,   74,   71,   71,
-       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
-       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
-       71,   71,   71,   71,   71,   71,   71,   71,   71,   71,
-
-       71,   71,   71,   71,   71,   71
-    } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-#define INITIAL 0
-/** @file input_lexer.ll
- *
- *  Lexical analyzer definition for reading expressions.
- *  This file must be processed with flex. */
-/*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-/*
- *  Definitions
- */
-#line 32 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-#include <iostream>
-#include <string>
-#include <map>
-#include <stdexcept>
-
-#include "input_lexer.h"
-#include "ex.h"
-#include "constant.h"
-#include "fail.h"
-#include "numeric.h"
-#include "symbol.h"
-#include "lst.h"
-#include "idx.h"
-
-using namespace GiNaC;
-namespace GiNaC {
-
-#include "input_parser.h"
-
-} // namespace GiNaC
-
-// Table of all used symbols/indices
-struct sym_def {
-	sym_def() : predefined(false) {}
-	sym_def(const ex &s, bool predef) : sym(s), predefined(predef) {}
-	~sym_def() {}
-
-	sym_def(const sym_def &other) {sym = other.sym; predefined = other.predefined;}
-	const sym_def &operator=(const sym_def &other)
-	{
-		if (this != &other) {
-			sym = other.sym;
-			predefined = other.predefined;
-		}
-		return *this;
-	}
-
-	ex sym;
-	bool predefined;	// true = user supplied symbol, false = lexer generated symbol
-};
-typedef std::map<std::string, sym_def> sym_tab;
-static sym_tab syms;
-
-// lex input function
-static int lexer_input(char *buf, int max_size);
-#define YY_INPUT(buf, result, max_size) (result = lexer_input(buf, max_size))
-/* Abbreviations */
-/*
- *  Lexical rules
- */
-#line 525 "input_lexer.cc"
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
-#else
-extern int yywrap YY_PROTO(( void ));
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-#endif
-
-#if YY_STACK_USED
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
-#endif
-
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
-
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines.  This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
-	if ( yy_current_buffer->yy_is_interactive ) \
-		{ \
-		int c = '*', n; \
-		for ( n = 0; n < max_size && \
-			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
-			buf[n] = (char) c; \
-		if ( c == '\n' ) \
-			buf[n++] = (char) c; \
-		if ( c == EOF && ferror( yyin ) ) \
-			YY_FATAL_ERROR( "input in flex scanner failed" ); \
-		result = n; \
-		} \
-	else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
-		  && ferror( yyin ) ) \
-		YY_FATAL_ERROR( "input in flex scanner failed" );
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
-	YY_USER_ACTION
-
-YY_DECL
-	{
-	register yy_state_type yy_current_state;
-	register char *yy_cp = NULL, *yy_bp = NULL;
-	register int yy_act;
-
-#line 91 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-
-#line 678 "input_lexer.cc"
-
-	if ( yy_init )
-		{
-		yy_init = 0;
-
-#ifdef YY_USER_INIT
-		YY_USER_INIT;
-#endif
-
-		if ( ! yy_start )
-			yy_start = 1;	/* first start state */
-
-		if ( ! yyin )
-			yyin = stdin;
-
-		if ( ! yyout )
-			yyout = stdout;
-
-		if ( ! yy_current_buffer )
-			yy_current_buffer =
-				yy_create_buffer( yyin, YY_BUF_SIZE );
-
-		yy_load_buffer_state();
-		}
-
-	while ( 1 )		/* loops until end-of-file is reached */
-		{
-		yy_cp = yy_c_buf_p;
-
-		/* Support of yytext. */
-		*yy_cp = yy_hold_char;
-
-		/* yy_bp points to the position in yy_ch_buf of the start of
-		 * the current run.
-		 */
-		yy_bp = yy_cp;
-
-		yy_current_state = yy_start;
-yy_match:
-		do
-			{
-			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
-			if ( yy_accept[yy_current_state] )
-				{
-				yy_last_accepting_state = yy_current_state;
-				yy_last_accepting_cpos = yy_cp;
-				}
-			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-				{
-				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 72 )
-					yy_c = yy_meta[(unsigned int) yy_c];
-				}
-			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-			++yy_cp;
-			}
-		while ( yy_base[yy_current_state] != 169 );
-
-yy_find_action:
-		yy_act = yy_accept[yy_current_state];
-		if ( yy_act == 0 )
-			{ /* have to back up */
-			yy_cp = yy_last_accepting_cpos;
-			yy_current_state = yy_last_accepting_state;
-			yy_act = yy_accept[yy_current_state];
-			}
-
-		YY_DO_BEFORE_ACTION;
-
-
-do_action:	/* This label is used only to access EOF actions. */
-
-
-		switch ( yy_act )
-	{ /* beginning of action switch */
-			case 0: /* must back up */
-			/* undo the effects of YY_DO_BEFORE_ACTION */
-			*yy_cp = yy_hold_char;
-			yy_cp = yy_last_accepting_cpos;
-			yy_current_state = yy_last_accepting_state;
-			goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 92 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-/* skip whitespace */
-	YY_BREAK
-/* special values */
-case 2:
-YY_RULE_SETUP
-#line 95 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-ginac_yylval = Pi; return T_LITERAL;
-	YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 96 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-ginac_yylval = Euler; return T_LITERAL;
-	YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 97 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-ginac_yylval = Catalan; return T_LITERAL;
-	YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 98 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-ginac_yylval = *new fail(); return T_LITERAL;
-	YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 99 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-ginac_yylval = I; return T_NUMBER;
-	YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 100 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-ginac_yylval = (long)Digits; return T_DIGITS;
-	YY_BREAK
-/* comparison */
-case 8:
-YY_RULE_SETUP
-#line 103 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-return T_EQUAL;
-	YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 104 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-return T_NOTEQ;
-	YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 105 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-return T_LESSEQ;
-	YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 106 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-return T_GREATEREQ;
-	YY_BREAK
-/* numbers */
-case 12:
-#line 110 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-case 13:
-#line 111 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-case 14:
-#line 112 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-case 15:
-#line 113 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-case 16:
-#line 114 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-case 17:
-#line 115 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-case 18:
-#line 116 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-case 19:
-YY_RULE_SETUP
-#line 116 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-ginac_yylval = numeric(yytext); return T_NUMBER;
-	YY_BREAK
-/* symbols */
-case 20:
-YY_RULE_SETUP
-#line 119 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-{
-				sym_tab::const_iterator i = syms.find(yytext);
-				if (i == syms.end()) {
-					symbol tmp(yytext);
-					ginac_yylval = tmp;
-					syms[yytext] = sym_def(tmp, false);
-				} else
-					ginac_yylval = (*i).second.sym;
-				return T_SYMBOL;
-			}
-	YY_BREAK
-/* end of input */
-case YY_STATE_EOF(INITIAL):
-#line 131 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-return T_EOF;
-	YY_BREAK
-/* everything else */
-case 21:
-YY_RULE_SETUP
-#line 134 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-return *yytext;
-	YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 136 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-ECHO;
-	YY_BREAK
-#line 869 "input_lexer.cc"
-
-	case YY_END_OF_BUFFER:
-		{
-		/* Amount of text matched not including the EOB char. */
-		int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
-
-		/* Undo the effects of YY_DO_BEFORE_ACTION. */
-		*yy_cp = yy_hold_char;
-		YY_RESTORE_YY_MORE_OFFSET
-
-		if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
-			{
-			/* We're scanning a new file or input source.  It's
-			 * possible that this happened because the user
-			 * just pointed yyin at a new source and called
-			 * yylex().  If so, then we have to assure
-			 * consistency between yy_current_buffer and our
-			 * globals.  Here is the right place to do so, because
-			 * this is the first action (other than possibly a
-			 * back-up) that will match for the new input source.
-			 */
-			yy_n_chars = yy_current_buffer->yy_n_chars;
-			yy_current_buffer->yy_input_file = yyin;
-			yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
-			}
-
-		/* Note that here we test for yy_c_buf_p "<=" to the position
-		 * of the first EOB in the buffer, since yy_c_buf_p will
-		 * already have been incremented past the NUL character
-		 * (since all states make transitions on EOB to the
-		 * end-of-buffer state).  Contrast this with the test
-		 * in input().
-		 */
-		if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
-			{ /* This was really a NUL. */
-			yy_state_type yy_next_state;
-
-			yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
-
-			yy_current_state = yy_get_previous_state();
-
-			/* Okay, we're now positioned to make the NUL
-			 * transition.  We couldn't have
-			 * yy_get_previous_state() go ahead and do it
-			 * for us because it doesn't know how to deal
-			 * with the possibility of jamming (and we don't
-			 * want to build jamming into it because then it
-			 * will run more slowly).
-			 */
-
-			yy_next_state = yy_try_NUL_trans( yy_current_state );
-
-			yy_bp = yytext_ptr + YY_MORE_ADJ;
-
-			if ( yy_next_state )
-				{
-				/* Consume the NUL. */
-				yy_cp = ++yy_c_buf_p;
-				yy_current_state = yy_next_state;
-				goto yy_match;
-				}
-
-			else
-				{
-				yy_cp = yy_c_buf_p;
-				goto yy_find_action;
-				}
-			}
-
-		else switch ( yy_get_next_buffer() )
-			{
-			case EOB_ACT_END_OF_FILE:
-				{
-				yy_did_buffer_switch_on_eof = 0;
-
-				if ( yywrap() )
-					{
-					/* Note: because we've taken care in
-					 * yy_get_next_buffer() to have set up
-					 * yytext, we can now set up
-					 * yy_c_buf_p so that if some total
-					 * hoser (like flex itself) wants to
-					 * call the scanner after we return the
-					 * YY_NULL, it'll still work - another
-					 * YY_NULL will get returned.
-					 */
-					yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
-
-					yy_act = YY_STATE_EOF(YY_START);
-					goto do_action;
-					}
-
-				else
-					{
-					if ( ! yy_did_buffer_switch_on_eof )
-						YY_NEW_FILE;
-					}
-				break;
-				}
-
-			case EOB_ACT_CONTINUE_SCAN:
-				yy_c_buf_p =
-					yytext_ptr + yy_amount_of_matched_text;
-
-				yy_current_state = yy_get_previous_state();
-
-				yy_cp = yy_c_buf_p;
-				yy_bp = yytext_ptr + YY_MORE_ADJ;
-				goto yy_match;
-
-			case EOB_ACT_LAST_MATCH:
-				yy_c_buf_p =
-				&yy_current_buffer->yy_ch_buf[yy_n_chars];
-
-				yy_current_state = yy_get_previous_state();
-
-				yy_cp = yy_c_buf_p;
-				yy_bp = yytext_ptr + YY_MORE_ADJ;
-				goto yy_find_action;
-			}
-		break;
-		}
-
-	default:
-		YY_FATAL_ERROR(
-			"fatal flex scanner internal error--no action found" );
-	} /* end of action switch */
-		} /* end of scanning one token */
-	} /* end of yylex */
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- *	EOB_ACT_LAST_MATCH -
- *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- *	EOB_ACT_END_OF_FILE - end of file
- */
-
-static int yy_get_next_buffer()
-	{
-	register char *dest = yy_current_buffer->yy_ch_buf;
-	register char *source = yytext_ptr;
-	register int number_to_move, i;
-	int ret_val;
-
-	if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
-		YY_FATAL_ERROR(
-		"fatal flex scanner internal error--end of buffer missed" );
-
-	if ( yy_current_buffer->yy_fill_buffer == 0 )
-		{ /* Don't try to fill the buffer, so this is an EOF. */
-		if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
-			{
-			/* We matched a single character, the EOB, so
-			 * treat this as a final EOF.
-			 */
-			return EOB_ACT_END_OF_FILE;
-			}
-
-		else
-			{
-			/* We matched some text prior to the EOB, first
-			 * process it.
-			 */
-			return EOB_ACT_LAST_MATCH;
-			}
-		}
-
-	/* Try to read more data. */
-
-	/* First move last chars to start of buffer. */
-	number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
-
-	for ( i = 0; i < number_to_move; ++i )
-		*(dest++) = *(source++);
-
-	if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
-		/* don't do the read, it's not guaranteed to return an EOF,
-		 * just force an EOF
-		 */
-		yy_current_buffer->yy_n_chars = yy_n_chars = 0;
-
-	else
-		{
-		int num_to_read =
-			yy_current_buffer->yy_buf_size - number_to_move - 1;
-
-		while ( num_to_read <= 0 )
-			{ /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
-			YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
-
-			/* just a shorter name for the current buffer */
-			YY_BUFFER_STATE b = yy_current_buffer;
-
-			int yy_c_buf_p_offset =
-				(int) (yy_c_buf_p - b->yy_ch_buf);
-
-			if ( b->yy_is_our_buffer )
-				{
-				int new_size = b->yy_buf_size * 2;
-
-				if ( new_size <= 0 )
-					b->yy_buf_size += b->yy_buf_size / 8;
-				else
-					b->yy_buf_size *= 2;
-
-				b->yy_ch_buf = (char *)
-					/* Include room in for 2 EOB chars. */
-					yy_flex_realloc( (void *) b->yy_ch_buf,
-							 b->yy_buf_size + 2 );
-				}
-			else
-				/* Can't grow it, we don't own it. */
-				b->yy_ch_buf = 0;
-
-			if ( ! b->yy_ch_buf )
-				YY_FATAL_ERROR(
-				"fatal error - scanner input buffer overflow" );
-
-			yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
-			num_to_read = yy_current_buffer->yy_buf_size -
-						number_to_move - 1;
-#endif
-			}
-
-		if ( num_to_read > YY_READ_BUF_SIZE )
-			num_to_read = YY_READ_BUF_SIZE;
-
-		/* Read in more data. */
-		YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
-			yy_n_chars, num_to_read );
-
-		yy_current_buffer->yy_n_chars = yy_n_chars;
-		}
-
-	if ( yy_n_chars == 0 )
-		{
-		if ( number_to_move == YY_MORE_ADJ )
-			{
-			ret_val = EOB_ACT_END_OF_FILE;
-			yyrestart( yyin );
-			}
-
-		else
-			{
-			ret_val = EOB_ACT_LAST_MATCH;
-			yy_current_buffer->yy_buffer_status =
-				YY_BUFFER_EOF_PENDING;
-			}
-		}
-
-	else
-		ret_val = EOB_ACT_CONTINUE_SCAN;
-
-	yy_n_chars += number_to_move;
-	yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
-	yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
-	yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
-
-	return ret_val;
-	}
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
-static yy_state_type yy_get_previous_state()
-	{
-	register yy_state_type yy_current_state;
-	register char *yy_cp;
-
-	yy_current_state = yy_start;
-
-	for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
-		{
-		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
-		if ( yy_accept[yy_current_state] )
-			{
-			yy_last_accepting_state = yy_current_state;
-			yy_last_accepting_cpos = yy_cp;
-			}
-		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-			{
-			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 72 )
-				yy_c = yy_meta[(unsigned int) yy_c];
-			}
-		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-		}
-
-	return yy_current_state;
-	}
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- *	next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
-	{
-	register int yy_is_jam;
-	register char *yy_cp = yy_c_buf_p;
-
-	register YY_CHAR yy_c = 1;
-	if ( yy_accept[yy_current_state] )
-		{
-		yy_last_accepting_state = yy_current_state;
-		yy_last_accepting_cpos = yy_cp;
-		}
-	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
-		{
-		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 72 )
-			yy_c = yy_meta[(unsigned int) yy_c];
-		}
-	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-	yy_is_jam = (yy_current_state == 71);
-
-	return yy_is_jam ? 0 : yy_current_state;
-	}
-
-
-#ifndef YY_NO_UNPUT
-#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-int c;
-register char *yy_bp;
-#endif
-	{
-	register char *yy_cp = yy_c_buf_p;
-
-	/* undo effects of setting up yytext */
-	*yy_cp = yy_hold_char;
-
-	if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
-		{ /* need to shift things up to make room */
-		/* +2 for EOB chars. */
-		register int number_to_move = yy_n_chars + 2;
-		register char *dest = &yy_current_buffer->yy_ch_buf[
-					yy_current_buffer->yy_buf_size + 2];
-		register char *source =
-				&yy_current_buffer->yy_ch_buf[number_to_move];
-
-		while ( source > yy_current_buffer->yy_ch_buf )
-			*--dest = *--source;
-
-		yy_cp += (int) (dest - source);
-		yy_bp += (int) (dest - source);
-		yy_current_buffer->yy_n_chars =
-			yy_n_chars = yy_current_buffer->yy_buf_size;
-
-		if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
-			YY_FATAL_ERROR( "flex scanner push-back overflow" );
-		}
-
-	*--yy_cp = (char) c;
-
-
-	yytext_ptr = yy_bp;
-	yy_hold_char = *yy_cp;
-	yy_c_buf_p = yy_cp;
-	}
-#endif	/* ifndef YY_NO_UNPUT */
-
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
-	{
-	int c;
-
-	*yy_c_buf_p = yy_hold_char;
-
-	if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
-		{
-		/* yy_c_buf_p now points to the character we want to return.
-		 * If this occurs *before* the EOB characters, then it's a
-		 * valid NUL; if not, then we've hit the end of the buffer.
-		 */
-		if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
-			/* This was really a NUL. */
-			*yy_c_buf_p = '\0';
-
-		else
-			{ /* need more input */
-			int offset = yy_c_buf_p - yytext_ptr;
-			++yy_c_buf_p;
-
-			switch ( yy_get_next_buffer() )
-				{
-				case EOB_ACT_LAST_MATCH:
-					/* This happens because yy_g_n_b()
-					 * sees that we've accumulated a
-					 * token and flags that we need to
-					 * try matching the token before
-					 * proceeding.  But for input(),
-					 * there's no matching to consider.
-					 * So convert the EOB_ACT_LAST_MATCH
-					 * to EOB_ACT_END_OF_FILE.
-					 */
-
-					/* Reset buffer status. */
-					yyrestart( yyin );
-
-					/* fall through */
-
-				case EOB_ACT_END_OF_FILE:
-					{
-					if ( yywrap() )
-						return EOF;
-
-					if ( ! yy_did_buffer_switch_on_eof )
-						YY_NEW_FILE;
-#ifdef __cplusplus
-					return yyinput();
-#else
-					return input();
-#endif
-					}
-
-				case EOB_ACT_CONTINUE_SCAN:
-					yy_c_buf_p = yytext_ptr + offset;
-					break;
-				}
-			}
-		}
-
-	c = *(unsigned char *) yy_c_buf_p;	/* cast for 8-bit char's */
-	*yy_c_buf_p = '\0';	/* preserve yytext */
-	yy_hold_char = *++yy_c_buf_p;
-
-
-	return c;
-	}
-#endif /* YY_NO_INPUT */
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
-	{
-	if ( ! yy_current_buffer )
-		yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
-	yy_init_buffer( yy_current_buffer, input_file );
-	yy_load_buffer_state();
-	}
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
-	{
-	if ( yy_current_buffer == new_buffer )
-		return;
-
-	if ( yy_current_buffer )
-		{
-		/* Flush out information for old buffer. */
-		*yy_c_buf_p = yy_hold_char;
-		yy_current_buffer->yy_buf_pos = yy_c_buf_p;
-		yy_current_buffer->yy_n_chars = yy_n_chars;
-		}
-
-	yy_current_buffer = new_buffer;
-	yy_load_buffer_state();
-
-	/* We don't actually know whether we did this switch during
-	 * EOF (yywrap()) processing, but the only time this flag
-	 * is looked at is after yywrap() is called, so it's safe
-	 * to go ahead and always set it.
-	 */
-	yy_did_buffer_switch_on_eof = 1;
-	}
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
-	{
-	yy_n_chars = yy_current_buffer->yy_n_chars;
-	yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
-	yyin = yy_current_buffer->yy_input_file;
-	yy_hold_char = *yy_c_buf_p;
-	}
-
-
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
-	{
-	YY_BUFFER_STATE b;
-
-	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
-	if ( ! b )
-		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
-	b->yy_buf_size = size;
-
-	/* yy_ch_buf has to be 2 characters longer than the size given because
-	 * we need to put in 2 end-of-buffer characters.
-	 */
-	b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
-	if ( ! b->yy_ch_buf )
-		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
-	b->yy_is_our_buffer = 1;
-
-	yy_init_buffer( b, file );
-
-	return b;
-	}
-
-
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-	{
-	if ( ! b )
-		return;
-
-	if ( b == yy_current_buffer )
-		yy_current_buffer = (YY_BUFFER_STATE) 0;
-
-	if ( b->yy_is_our_buffer )
-		yy_flex_free( (void *) b->yy_ch_buf );
-
-	yy_flex_free( (void *) b );
-	}
-
-
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
-
-
-	{
-	yy_flush_buffer( b );
-
-	b->yy_input_file = file;
-	b->yy_fill_buffer = 1;
-
-#if YY_ALWAYS_INTERACTIVE
-	b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
-	b->yy_is_interactive = 0;
-#else
-	b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
-	}
-
-
-#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
-#else
-void yy_flush_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-
-	{
-	if ( ! b )
-		return;
-
-	b->yy_n_chars = 0;
-
-	/* We always need two end-of-buffer characters.  The first causes
-	 * a transition to the end-of-buffer state.  The second causes
-	 * a jam in that state.
-	 */
-	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
-	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
-	b->yy_buf_pos = &b->yy_ch_buf[0];
-
-	b->yy_at_bol = 1;
-	b->yy_buffer_status = YY_BUFFER_NEW;
-
-	if ( b == yy_current_buffer )
-		yy_load_buffer_state();
-	}
-
-
-#ifndef YY_NO_SCAN_BUFFER
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
-#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
-char *base;
-yy_size_t size;
-#endif
-	{
-	YY_BUFFER_STATE b;
-
-	if ( size < 2 ||
-	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
-	     base[size-1] != YY_END_OF_BUFFER_CHAR )
-		/* They forgot to leave room for the EOB's. */
-		return 0;
-
-	b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
-	if ( ! b )
-		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
-	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
-	b->yy_buf_pos = b->yy_ch_buf = base;
-	b->yy_is_our_buffer = 0;
-	b->yy_input_file = 0;
-	b->yy_n_chars = b->yy_buf_size;
-	b->yy_is_interactive = 0;
-	b->yy_at_bol = 1;
-	b->yy_fill_buffer = 0;
-	b->yy_buffer_status = YY_BUFFER_NEW;
-
-	yy_switch_to_buffer( b );
-
-	return b;
-	}
-#endif
-
-
-#ifndef YY_NO_SCAN_STRING
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
-#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
-yyconst char *yy_str;
-#endif
-	{
-	int len;
-	for ( len = 0; yy_str[len]; ++len )
-		;
-
-	return yy_scan_bytes( yy_str, len );
-	}
-#endif
-
-
-#ifndef YY_NO_SCAN_BYTES
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
-#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
-yyconst char *bytes;
-int len;
-#endif
-	{
-	YY_BUFFER_STATE b;
-	char *buf;
-	yy_size_t n;
-	int i;
-
-	/* Get memory for full buffer, including space for trailing EOB's. */
-	n = len + 2;
-	buf = (char *) yy_flex_alloc( n );
-	if ( ! buf )
-		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
-	for ( i = 0; i < len; ++i )
-		buf[i] = bytes[i];
-
-	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
-
-	b = yy_scan_buffer( buf, n );
-	if ( ! b )
-		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
-	/* It's okay to grow etc. this buffer, and we should throw it
-	 * away when we're done.
-	 */
-	b->yy_is_our_buffer = 1;
-
-	return b;
-	}
-#endif
-
-
-#ifndef YY_NO_PUSH_STATE
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
-	{
-	if ( yy_start_stack_ptr >= yy_start_stack_depth )
-		{
-		yy_size_t new_size;
-
-		yy_start_stack_depth += YY_START_STACK_INCR;
-		new_size = yy_start_stack_depth * sizeof( int );
-
-		if ( ! yy_start_stack )
-			yy_start_stack = (int *) yy_flex_alloc( new_size );
-
-		else
-			yy_start_stack = (int *) yy_flex_realloc(
-					(void *) yy_start_stack, new_size );
-
-		if ( ! yy_start_stack )
-			YY_FATAL_ERROR(
-			"out of memory expanding start-condition stack" );
-		}
-
-	yy_start_stack[yy_start_stack_ptr++] = YY_START;
-
-	BEGIN(new_state);
-	}
-#endif
-
-
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
-	{
-	if ( --yy_start_stack_ptr < 0 )
-		YY_FATAL_ERROR( "start-condition stack underflow" );
-
-	BEGIN(yy_start_stack[yy_start_stack_ptr]);
-	}
-#endif
-
-
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
-	{
-	return yy_start_stack[yy_start_stack_ptr - 1];
-	}
-#endif
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( yyconst char msg[] )
-#else
-static void yy_fatal_error( msg )
-char msg[];
-#endif
-	{
-	(void) fprintf( stderr, "%s\n", msg );
-	exit( YY_EXIT_FAILURE );
-	}
-
-
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
-	do \
-		{ \
-		/* Undo effects of setting up yytext. */ \
-		yytext[yyleng] = yy_hold_char; \
-		yy_c_buf_p = yytext + n; \
-		yy_hold_char = *yy_c_buf_p; \
-		*yy_c_buf_p = '\0'; \
-		yyleng = n; \
-		} \
-	while ( 0 )
-
-
-/* Internal utility routines. */
-
-#ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-yyconst char *s2;
-int n;
-#endif
-	{
-	register int i;
-	for ( i = 0; i < n; ++i )
-		s1[i] = s2[i];
-	}
-#endif
-
-#ifdef YY_NEED_STRLEN
-#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
-#else
-static int yy_flex_strlen( s )
-yyconst char *s;
-#endif
-	{
-	register int n;
-	for ( n = 0; s[n]; ++n )
-		;
-
-	return n;
-	}
-#endif
-
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
-#else
-static void *yy_flex_alloc( size )
-yy_size_t size;
-#endif
-	{
-	return (void *) malloc( size );
-	}
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-yy_size_t size;
-#endif
-	{
-	/* The cast to (char *) in the following accommodates both
-	 * implementations that use char* generic pointers, and those
-	 * that use void* generic pointers.  It works with the latter
-	 * because both ANSI C and C++ allow castless assignment from
-	 * any pointer type to void*, and deal with argument conversions
-	 * as though doing an assignment.
-	 */
-	return (void *) realloc( (char *) ptr, size );
-	}
-
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
-	{
-	free( ptr );
-	}
-
-#if YY_MAIN
-int main()
-	{
-	yylex();
-	return 0;
-	}
-#endif
-#line 136 "/user/jensv/ginac/ginac/ginac/input_lexer.ll"
-
-
-
-/*
- *  Routines
- */
-
-// The string from which we will read
-static std::string lexer_string;
-
-// The current position within the string
-static int curr_pos = 0;
-
-// Input function that reads from string
-static int lexer_input(char *buf, int max_size)
-{
-	int actual = lexer_string.length() - curr_pos;
-	if (actual > max_size)
-		actual = max_size;
-	if (actual <= 0)
-		return YY_NULL;
-	lexer_string.copy(buf, actual, curr_pos);
-	curr_pos += actual;
-	return actual;
-}
-
-// EOF encountered, terminate the scanner
-int ginac_yywrap()
-{
-	return 1;
-}
-
-namespace GiNaC {
-
-// Set the input string
-void set_lexer_string(const std::string &s)
-{
-	lexer_string = s;
-	curr_pos = 0;
-}
-
-// Get name of symbol/index
-std::string get_symbol_name(const ex & s)
-{
-	if (is_a<symbol>(s))
-		return ex_to<symbol>(s).get_name();
-	else if (is_a<idx>(s) && is_a<symbol>(s.op(0)))
-		return ex_to<symbol>(s.op(0)).get_name();
-	else
-		throw (std::runtime_error("get_symbol_name(): unexpected expression type"));
-}
-
-// Set the list of predefined symbols/indices
-void set_lexer_symbols(ex l)
-{
-	syms.clear();
-	if (!is_exactly_a<lst>(l))
-		return;
-	for (unsigned i=0; i<l.nops(); i++) {
-		const ex &o = l.op(i);
-		if (is_a<symbol>(o) || (is_a<idx>(o) && is_a<symbol>(o.op(0))))
-			syms[get_symbol_name(o)] = sym_def(o, true);
-	}
-}
-
-// Check whether symbol/index was predefined
-bool is_lexer_symbol_predefined(const ex &s)
-{
-	sym_tab::const_iterator i = syms.find(get_symbol_name(s));
-	if (i == syms.end())
-		return false;
-	else
-		return (*i).second.predefined;
-}
-
-} // namespace GiNaC
diff --git a/ginac/input_lexer.h b/ginac/input_lexer.h
deleted file mode 100644
index 8cffe6b..0000000
--- a/ginac/input_lexer.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/** @file input_lexer.h
- *
- *  Lexical analyzer definition for reading expressions.
- *  This file must be processed with flex. */
-
-/*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __GINAC_INPUT_LEXER_H__
-#define __GINAC_INPUT_LEXER_H__
-
-extern "C" {
-#include <stdio.h>
-}
-	
-#include "config.h"
-
-// yacc stack type
-#define YYSTYPE ex
-
-// lex functions/variables
-extern int ginac_yyerror(char *s);
-extern int ginac_yylex(void);
-extern void ginac_yyrestart(FILE *f);
-extern char *ginac_yytext;
-
-namespace GiNaC {
-
-class ex;
-
-/** Set the input string to be parsed by ginac_yyparse() (used internally). */
-extern void set_lexer_string(const std::string &s);
-
-/** Get name of symbol/index (used internally). */
-extern std::string get_symbol_name(const ex & s);
-
-/** Set the list of predefined symbols for the lexer (used internally). */
-extern void set_lexer_symbols(ex l);
-
-/** Check whether lexer symbol was predefined (vs. created by the lexer, e.g. function names). */
-extern bool is_lexer_symbol_predefined(const ex &s);
-
-/** The expression parser function (used internally). */
-extern int ginac_yyparse(void);
-
-/** The expression returned by the parser (used internally). */
-extern ex parsed_ex;
-
-/** Get error message from the parser. */
-extern std::string get_parser_error(void);
-
-} // namespace GiNaC
-
-#endif // ndef __GINAC_INPUT_LEXER_H__
diff --git a/ginac/input_lexer.ll b/ginac/input_lexer.ll
deleted file mode 100644
index 0a7bbec..0000000
--- a/ginac/input_lexer.ll
+++ /dev/null
@@ -1,211 +0,0 @@
-/** @file input_lexer.ll
- *
- *  Lexical analyzer definition for reading expressions.
- *  This file must be processed with flex. */
-
-/*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-
-/*
- *  Definitions
- */
-
-%pointer
-
-%{
-#include <iostream>
-#include <string>
-#include <map>
-#include <stdexcept>
-
-#include "input_lexer.h"
-#include "ex.h"
-#include "constant.h"
-#include "fail.h"
-#include "numeric.h"
-#include "symbol.h"
-#include "lst.h"
-#include "idx.h"
-
-using namespace GiNaC;
-namespace GiNaC {
-
-#include "input_parser.h"
-
-} // namespace GiNaC
-
-// Table of all used symbols/indices
-struct sym_def {
-	sym_def() : predefined(false) {}
-	sym_def(const ex &s, bool predef) : sym(s), predefined(predef) {}
-	~sym_def() {}
-
-	sym_def(const sym_def &other) {sym = other.sym; predefined = other.predefined;}
-	const sym_def &operator=(const sym_def &other)
-	{
-		if (this != &other) {
-			sym = other.sym;
-			predefined = other.predefined;
-		}
-		return *this;
-	}
-
-	ex sym;
-	bool predefined;	// true = user supplied symbol, false = lexer generated symbol
-};
-typedef std::map<std::string, sym_def> sym_tab;
-static sym_tab syms;
-
-// lex input function
-static int lexer_input(char *buf, int max_size);
-#define YY_INPUT(buf, result, max_size) (result = lexer_input(buf, max_size))
-%}
-
-	/* Abbreviations */
-D	[0-9]
-E	[elEL][-+]?{D}+
-A	[a-zA-Z_]
-AN	[0-9a-zA-Z_]
-
-
-/*
- *  Lexical rules
- */
-
-%%
-[ \t\n]+		/* skip whitespace */
-
-			/* special values */
-Pi			ginac_yylval = Pi; return T_LITERAL;
-Euler			ginac_yylval = Euler; return T_LITERAL;
-Catalan			ginac_yylval = Catalan; return T_LITERAL;
-FAIL			ginac_yylval = *new fail(); return T_LITERAL;
-I			ginac_yylval = I; return T_NUMBER;
-Digits			ginac_yylval = (long)Digits; return T_DIGITS;
-
-			/* comparison */
-"=="			return T_EQUAL;
-"!="			return T_NOTEQ;
-"<="			return T_LESSEQ;
-">="			return T_GREATEREQ;
-
-			/* numbers */
-{D}+			|
-"#"{D}+"R"{AN}+		|
-"#b"([01])+		|
-"#o"[0-7]+		|
-"#x"[0-9a-fA-F]+	|
-{D}+"."{D}*({E})?	|
-{D}*"."{D}+({E})?	|
-{D}+{E}			ginac_yylval = numeric(yytext); return T_NUMBER;
-
-			/* symbols */
-{A}{AN}*		{
-				sym_tab::const_iterator i = syms.find(yytext);
-				if (i == syms.end()) {
-					symbol tmp(yytext);
-					ginac_yylval = tmp;
-					syms[yytext] = sym_def(tmp, false);
-				} else
-					ginac_yylval = (*i).second.sym;
-				return T_SYMBOL;
-			}
-
-			/* end of input */
-<<EOF>>			return T_EOF;
-
-			/* everything else */
-.			return *yytext;
-
-%%
-
-
-/*
- *  Routines
- */
-
-// The string from which we will read
-static std::string lexer_string;
-
-// The current position within the string
-static int curr_pos = 0;
-
-// Input function that reads from string
-static int lexer_input(char *buf, int max_size)
-{
-	int actual = lexer_string.length() - curr_pos;
-	if (actual > max_size)
-		actual = max_size;
-	if (actual <= 0)
-		return YY_NULL;
-	lexer_string.copy(buf, actual, curr_pos);
-	curr_pos += actual;
-	return actual;
-}
-
-// EOF encountered, terminate the scanner
-int ginac_yywrap()
-{
-	return 1;
-}
-
-namespace GiNaC {
-
-// Set the input string
-void set_lexer_string(const std::string &s)
-{
-	lexer_string = s;
-	curr_pos = 0;
-}
-
-// Get name of symbol/index
-std::string get_symbol_name(const ex & s)
-{
-	if (is_a<symbol>(s))
-		return ex_to<symbol>(s).get_name();
-	else if (is_a<idx>(s) && is_a<symbol>(s.op(0)))
-		return ex_to<symbol>(s.op(0)).get_name();
-	else
-		throw (std::runtime_error("get_symbol_name(): unexpected expression type"));
-}
-
-// Set the list of predefined symbols/indices
-void set_lexer_symbols(ex l)
-{
-	syms.clear();
-	if (!is_exactly_a<lst>(l))
-		return;
-	for (unsigned i=0; i<l.nops(); i++) {
-		const ex &o = l.op(i);
-		if (is_a<symbol>(o) || (is_a<idx>(o) && is_a<symbol>(o.op(0))))
-			syms[get_symbol_name(o)] = sym_def(o, true);
-	}
-}
-
-// Check whether symbol/index was predefined
-bool is_lexer_symbol_predefined(const ex &s)
-{
-	sym_tab::const_iterator i = syms.find(get_symbol_name(s));
-	if (i == syms.end())
-		return false;
-	else
-		return (*i).second.predefined;
-}
-
-} // namespace GiNaC
diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp
index a2ff373..2564fb8 100644
--- a/ginac/matrix.cpp
+++ b/ginac/matrix.cpp
@@ -238,7 +238,7 @@ ex matrix::subs(const exmap & mp, unsigned options) const
 /** Complex conjugate every matrix entry. */
 ex matrix::conjugate() const
 {
-	exvector * ev = nullptr;
+	std::unique_ptr<exvector> ev(nullptr);
 	for (auto i=m.begin(); i!=m.end(); ++i) {
 		ex x = i->conjugate();
 		if (ev) {
@@ -248,7 +248,7 @@ ex matrix::conjugate() const
 		if (are_ex_trivially_equal(x, *i)) {
 			continue;
 		}
-		ev = new exvector;
+		ev.reset(new exvector);
 		ev->reserve(m.size());
 		for (auto j=m.begin(); j!=i; ++j) {
 			ev->push_back(*j);
@@ -257,7 +257,6 @@ ex matrix::conjugate() const
 	}
 	if (ev) {
 		ex result = matrix(row, col, *ev);
-		delete ev;
 		return result;
 	}
 	return *this;
@@ -748,18 +747,16 @@ ex matrix::determinant(unsigned algo) const
 	bool numeric_flag = true;
 	bool normal_flag = false;
 	unsigned sparse_count = 0;  // counts non-zero elements
-	auto r = m.begin(), rend = m.end();
-	while (r != rend) {
-		if (!r->info(info_flags::numeric))
+        for (const auto elem : m) {
+		if (elem.info(info_flags::numeric))
 			numeric_flag = false;
 		exmap srl;  // symbol replacement list
-		ex rtest = r->to_rational(srl);
+		ex rtest = elem.to_rational(srl);
 		if (!rtest.is_zero())
 			++sparse_count;
 		if (!rtest.info(info_flags::crational_polynomial) &&
 			 rtest.info(info_flags::rational_function))
 			normal_flag = true;
-		++r;
 	}
 	
 	// Here is the heuristics in case this routine has to decide:
@@ -835,8 +832,8 @@ ex matrix::determinant(unsigned algo) const
 			std::vector<uintpair> c_zeros;  // number of zeros in column
 			for (unsigned c=0; c<col; ++c) {
 				unsigned acc = 0;
-				for (unsigned r=0; r<row; ++r)
-					if (m[r*col+c].is_zero())
+				for (unsigned rr=0; rr<row; ++rr)
+					if (m[rr*col+c].is_zero())
 						++acc;
 				c_zeros.push_back(uintpair(acc,c));
 			}
@@ -848,11 +845,10 @@ ex matrix::determinant(unsigned algo) const
 			int sign = permutation_sign(pre_sort_test.begin(), pre_sort_test.end());
 			exvector result(row*col);  // represents sorted matrix
 			unsigned c = 0;
-			for (std::vector<unsigned>::const_iterator i=pre_sort.begin();
-				 i!=pre_sort.end();
-				 ++i,++c) {
-				for (unsigned r=0; r<row; ++r)
-					result[r*col+c] = m[r*col+(*i)];
+                        for (const auto & elem : pre_sort) {
+				for (unsigned rr=0; rr<row; ++rr)
+					result[rr*col + c] = m[rr*col + elem];
+                                ++c;
 			}
 			
 			if (normal_flag)
@@ -904,12 +900,11 @@ ex matrix::charpoly(const ex & lambda) const
 		throw (std::logic_error("matrix::charpoly(): matrix not square"));
 	
 	bool numeric_flag = true;
-	auto r = m.begin(), rend = m.end();
-	while (r!=rend && numeric_flag==true) {
-		if (!r->info(info_flags::numeric))
+        for (const auto & elem : m)
+		if (!elem.info(info_flags::numeric)) {
 			numeric_flag = false;
-		++r;
-	}
+                        break;
+                }
 	
 	// The pure numeric case is traditionally rather common.  Hence, it is
 	// trapped and we use Leverrier's algorithm which goes as row^3 for
@@ -996,12 +991,12 @@ matrix matrix::solve(const matrix & vars,
                      const matrix & rhs,
                      unsigned algo) const
 {
-	const unsigned m = this->rows();
+	const unsigned mm = this->rows();
 	const unsigned n = this->cols();
 	const unsigned p = rhs.cols();
 	
 	// syntax checks    
-	if ((rhs.rows() != m) || (vars.rows() != n) || (vars.col != p))
+	if ((rhs.rows() != mm) || (vars.rows() != n) || (vars.col != p))
 		throw (std::logic_error("matrix::solve(): incompatible matrices"));
 	for (unsigned ro=0; ro<n; ++ro)
 		for (unsigned co=0; co<p; ++co)
@@ -1009,8 +1004,8 @@ matrix matrix::solve(const matrix & vars,
 				throw (std::invalid_argument("matrix::solve(): 1st argument must be matrix of symbols"));
 	
 	// build the augmented matrix of *this with rhs attached to the right
-	matrix aug(m,n+p);
-	for (unsigned r=0; r<m; ++r) {
+	matrix aug(mm,n+p);
+	for (unsigned r=0; r<mm; ++r) {
 		for (unsigned c=0; c<n; ++c)
 			aug.m[r*(n+p)+c] = this->m[r*n+c];
 		for (unsigned c=0; c<p; ++c)
@@ -1019,12 +1014,11 @@ matrix matrix::solve(const matrix & vars,
 	
 	// Gather some statistical information about the augmented matrix:
 	bool numeric_flag = true;
-	exvector::const_iterator r = aug.m.begin(), rend = aug.m.end();
-	while (r!=rend && numeric_flag==true) {
-		if (!r->info(info_flags::numeric))
+        for (const auto & elem : aug.m)
+		if (!elem.info(info_flags::numeric)) {
 			numeric_flag = false;
-		++r;
-	}
+                        break;
+                }
 	
 	// Here is the heuristics in case this routine has to decide:
 	if (algo == solve_algo::automatic) {
@@ -1032,7 +1026,7 @@ matrix matrix::solve(const matrix & vars,
 		algo = solve_algo::bareiss;
 		// For m<3, Bareiss elimination is equivalent to division free
 		// elimination but has more logistic overhead
-		if (m<3)
+		if (mm<3)
 			algo = solve_algo::divfree;
 		// This overrides any prior decisions.
 		if (numeric_flag)
@@ -1056,7 +1050,7 @@ matrix matrix::solve(const matrix & vars,
 	matrix sol(n,p);
 	for (unsigned co=0; co<p; ++co) {
 		unsigned last_assigned_sol = n+1;
-		for (int r=m-1; r>=0; --r) {
+		for (int r=mm-1; r>=0; --r) {
 			unsigned fnz = 1;    // first non-zero in row
 			while ((fnz<=n) && (aug.m[r*(n+p)+(fnz-1)].is_zero()))
 				++fnz;
@@ -1245,13 +1239,13 @@ ex matrix::determinant_minor() const
 int matrix::gauss_elimination(const bool det)
 {
 	ensure_if_modifiable();
-	const unsigned m = this->rows();
+	const unsigned mm = this->rows();
 	const unsigned n = this->cols();
-	GINAC_ASSERT(!det || n==m);
+	GINAC_ASSERT(!det || n==mm);
 	int sign = 1;
 	
 	unsigned r0 = 0;
-	for (unsigned c0=0; c0<n && r0<m-1; ++c0) {
+	for (unsigned c0=0; c0<n && r0<mm-1; ++c0) {
 		int indx = pivot(r0, c0, true);
 		if (indx == -1) {
 			sign = 0;
@@ -1261,7 +1255,7 @@ int matrix::gauss_elimination(const bool det)
 		if (indx>=0) {
 			if (indx > 0)
 				sign = -sign;
-			for (unsigned r2=r0+1; r2<m; ++r2) {
+			for (unsigned r2=r0+1; r2<mm; ++r2) {
 				if (!this->m[r2*n+c0].is_zero()) {
 					// yes, there is something to do in this row
 					ex piv = this->m[r2*n+c0] / this->m[r0*n+c0];
@@ -1284,7 +1278,7 @@ int matrix::gauss_elimination(const bool det)
 		}
 	}
 	// clear remaining rows
-	for (unsigned r=r0+1; r<m; ++r) {
+	for (unsigned r=r0+1; r<mm; ++r) {
 		for (unsigned c=0; c<n; ++c)
 			this->m[r*n+c] = _ex0;
 	}
@@ -1304,13 +1298,13 @@ int matrix::gauss_elimination(const bool det)
 int matrix::division_free_elimination(const bool det)
 {
 	ensure_if_modifiable();
-	const unsigned m = this->rows();
+	const unsigned mm = this->rows();
 	const unsigned n = this->cols();
-	GINAC_ASSERT(!det || n==m);
+	GINAC_ASSERT(!det || n==mm);
 	int sign = 1;
 	
 	unsigned r0 = 0;
-	for (unsigned c0=0; c0<n && r0<m-1; ++c0) {
+	for (unsigned c0=0; c0<n && r0<mm-1; ++c0) {
 		int indx = pivot(r0, c0, true);
 		if (indx==-1) {
 			sign = 0;
@@ -1320,7 +1314,7 @@ int matrix::division_free_elimination(const bool det)
 		if (indx>=0) {
 			if (indx>0)
 				sign = -sign;
-			for (unsigned r2=r0+1; r2<m; ++r2) {
+			for (unsigned r2=r0+1; r2<mm; ++r2) {
 				for (unsigned c=c0+1; c<n; ++c)
 					this->m[r2*n+c] = (this->m[r0*n+c0]*this->m[r2*n+c] - this->m[r2*n+c0]*this->m[r0*n+c]).expand();
 				// fill up left hand side with zeros
@@ -1336,7 +1330,7 @@ int matrix::division_free_elimination(const bool det)
 		}
 	}
 	// clear remaining rows
-	for (unsigned r=r0+1; r<m; ++r) {
+	for (unsigned r=r0+1; r<mm; ++r) {
 		for (unsigned c=0; c<n; ++c)
 			this->m[r*n+c] = _ex0;
 	}
@@ -1382,11 +1376,11 @@ int matrix::fraction_free_elimination(const bool det)
 	//     D{m[k-1](k-1,k-1)}.
 	
 	ensure_if_modifiable();
-	const unsigned m = this->rows();
+	const unsigned mm = this->rows();
 	const unsigned n = this->cols();
-	GINAC_ASSERT(!det || n==m);
+	GINAC_ASSERT(!det || n==mm);
 	int sign = 1;
-	if (m==1)
+	if (mm==1)
 		return 1;
 	ex divisor_n = 1;
 	ex divisor_d = 1;
@@ -1401,7 +1395,7 @@ int matrix::fraction_free_elimination(const bool det)
 	// need GCDs) since the elements of *this might be unnormalized, which
 	// makes things more complicated than they need to be.
 	matrix tmp_n(*this);
-	matrix tmp_d(m,n);  // for denominators, if needed
+	matrix tmp_d(mm,n);  // for denominators, if needed
 	exmap srl;  // symbol replacement list
 	exvector::const_iterator cit = this->m.begin(), citend = this->m.end();
 	auto tmp_n_it = tmp_n.m.begin(), tmp_d_it = tmp_d.m.begin();
@@ -1413,22 +1407,22 @@ int matrix::fraction_free_elimination(const bool det)
 	}
 	
 	unsigned r0 = 0;
-	for (unsigned c0=0; c0<n && r0<m-1; ++c0) {
+	for (unsigned c0=0; c0<n && r0<mm-1; ++c0) {
 		// When trying to find a pivot, we should try a bit harder than expand().
 		// Searching the first non-zero element in-place here instead of calling
 		// pivot() allows us to do no more substitutions and back-substitutions
 		// than are actually necessary.
 		int indx = r0;
-		while ((indx<m) &&
+		while ((static_cast<unsigned>(indx)<mm) &&
 		       (tmp_n[indx*n+c0].subs(srl, subs_options::no_pattern).expand().is_zero()))
 			++indx;
-		if (indx==m) {
+		if (static_cast<unsigned> (indx)==mm) {
 			// all elements in column c0 below row r0 vanish
 			sign = 0;
 			if (det)
 				return 0;
 		} else {
-			if (indx>r0) {
+			if (static_cast<unsigned>(indx)>r0) {
 				// Matrix needs pivoting, swap rows r0 and indx of tmp_n and tmp_d.
 				sign = -sign;
 				for (unsigned c=c0; c<n; ++c) {
@@ -1436,7 +1430,7 @@ int matrix::fraction_free_elimination(const bool det)
 					tmp_d.m[n*indx+c].swap(tmp_d.m[n*r0+c]);
 				}
 			}
-			for (unsigned r2=r0+1; r2<m; ++r2) {
+			for (unsigned r2=r0+1; r2<mm; ++r2) {
 				for (unsigned c=c0+1; c<n; ++c) {
 					dividend_n = (tmp_n.m[r0*n+c0]*tmp_n.m[r2*n+c]*
 					              tmp_d.m[r2*n+c0]*tmp_d.m[r0*n+c]
@@ -1454,7 +1448,7 @@ int matrix::fraction_free_elimination(const bool det)
 				for (unsigned c=r0; c<=c0; ++c)
 					tmp_n.m[r2*n+c] = _ex0;
 			}
-			if (c0<n && r0<m-1) {
+			if (c0<n && r0<mm-1) {
 				// compute next iteration's divisor
 				divisor_n = tmp_n.m[r0*n+c0].expand();
 				divisor_d = tmp_d.m[r0*n+c0].expand();
@@ -1470,7 +1464,7 @@ int matrix::fraction_free_elimination(const bool det)
 		}
 	}
 	// clear remaining rows
-	for (unsigned r=r0+1; r<m; ++r) {
+	for (unsigned r=r0+1; r<mm; ++r) {
 		for (unsigned c=0; c<n; ++c)
 			tmp_n.m[r*n+c] = _ex0;
 	}
diff --git a/ginac/mul.cpp b/ginac/mul.cpp
index 1c0d217..4641507 100644
--- a/ginac/mul.cpp
+++ b/ginac/mul.cpp
@@ -79,11 +79,11 @@ mul::mul(const ex & lh, const ex & rh)
 	GINAC_ASSERT(is_canonical());
 }
 
-mul::mul(const exvector & v, bool hold)
+mul::mul(const exvector & v, bool do_hold)
 {
 	tinfo_key = &mul::tinfo_static;
 	overall_coeff = _ex1;
-	construct_from_exvector(v, hold);
+	construct_from_exvector(v, do_hold);
 	GINAC_ASSERT(is_canonical());
 }
 
@@ -103,14 +103,14 @@ mul::mul(const epvector & v, const ex & oc, bool do_index_renaming)
 	GINAC_ASSERT(is_canonical());
 }
 
-mul::mul(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming)
-{
-	tinfo_key = &mul::tinfo_static;
-	GINAC_ASSERT(vp.get()!=0);
-	overall_coeff = oc;
-	construct_from_epvector(*vp, do_index_renaming);
-	GINAC_ASSERT(is_canonical());
-}
+//mul::mul(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming)
+//{
+//	tinfo_key = &mul::tinfo_static;
+//	GINAC_ASSERT(vp.get()!=0);
+//	overall_coeff = oc;
+//	construct_from_epvector(*vp, do_index_renaming);
+//	GINAC_ASSERT(is_canonical());
+//}
 
 mul::mul(const ex & lh, const ex & mh, const ex & rh)
 {
@@ -138,15 +138,15 @@ DEFAULT_ARCHIVING(mul)
 void mul::print_overall_coeff(const ex coeff_ex, const print_context & c,
 		const char *mul_sym, bool latex) const
 {
-	const numeric &coeff = ex_to<numeric>(coeff_ex);
+	const numeric & num_coeff = ex_to<numeric>(coeff_ex);
 	std::stringstream tstream;
-	print_context* tcontext_p;
+	std::unique_ptr<print_context> tcontext_p;
 	if (latex)
-		tcontext_p = new print_latex(tstream, c.options);
+		tcontext_p.reset(new print_latex(tstream, c.options));
 	else
-		tcontext_p = new print_dflt(tstream, c.options);
+		tcontext_p.reset(new print_dflt(tstream, c.options));
 	//print_context tcontext(tstream, c.options);
-	coeff.print(*tcontext_p, 0);
+	num_coeff.print(*tcontext_p, 0);
 	std::string coeffstr = tstream.str();
 
 	bool parenthesis =((coeffstr.find(' ') != std::string::npos && !latex)||
@@ -155,9 +155,9 @@ void mul::print_overall_coeff(const ex coeff_ex, const print_context & c,
 		//(coeffstr.find('/') != std::string::npos) ||
 		//(coeffstr.find('*') != std::string::npos) ||
 		//(coeffstr.find('^') != std::string::npos));
-	if (coeff.is_integer() &&
-                coeff.is_equal(*_num_1_p) &&
-                !coeff.is_parent_pos_char())
+	if (num_coeff.is_integer() &&
+                num_coeff.is_equal(*_num_1_p) &&
+                !num_coeff.is_parent_pos_char())
 		c.s<<"-";
 	else if (parenthesis && coeffstr[0] == '-') {
 		// We want to move the '-' out of the parenthesis if it is
@@ -170,14 +170,14 @@ void mul::print_overall_coeff(const ex coeff_ex, const print_context & c,
 		else
 			c.s<<"(";
 		tstream.str("");
-		coeff.mul(*_num_1_p).print(*tcontext_p, 0);
+		num_coeff.mul(*_num_1_p).print(*tcontext_p, 0);
 		c.s<<tstream.str();
 		if (latex)
 			c.s<<"\\right)";
 		else
 			c.s<<")";
 		c.s << mul_sym;
-	} else if (!coeff.is_integer() || !coeff.is_equal(*_num1_p)) {
+	} else if (!num_coeff.is_integer() || !num_coeff.is_equal(*_num1_p)) {
 		if (parenthesis) {
 			if (latex)
 				c.s << "\\left(";
@@ -193,7 +193,6 @@ void mul::print_overall_coeff(const ex coeff_ex, const print_context & c,
 		}
 		c.s << mul_sym;
 	}
-	delete tcontext_p;
 }
 
 /*
@@ -234,14 +233,12 @@ void mul::print_exvector(const exvector & v, const print_context & c,
 		const char* sep) const
 {
 	bool first = true;
-	auto vit = v.begin(), vitend = v.end();
-	while (vit != vitend) {
+        for (const auto & elem : v) {
 		if (!first)
 			c.s << sep;
 		else
 			first = false;
-		vit->print(c,precedence());
-		++vit;
+		elem.print(c, precedence());
 	}
 }
 
@@ -265,16 +262,14 @@ void mul::do_print_rat_func(const print_context & c, unsigned level,
 	// Separate factors into those with negative numeric exponent
 	// and all others
 	const epvector & sorted_seq = get_sorted_seq();
-	auto it = sorted_seq.begin(), itend = sorted_seq.end();
-	exvector neg_powers, others;
-	while (it != itend) {
-		GINAC_ASSERT(is_exactly_a<numeric>(it->coeff));
-		if (ex_to<numeric>(it->coeff).is_real() &&
-				ex_to<numeric>(it->coeff).is_negative())
-			neg_powers.push_back(recombine_pair_to_ex(expair(it->rest, -(it->coeff))));
+        exvector neg_powers, others;
+        for (const auto & elem : sorted_seq) {
+		GINAC_ASSERT(is_exactly_a<numeric>(elem.coeff));
+		if (ex_to<numeric>(elem.coeff).is_real() &&
+				ex_to<numeric>(elem.coeff).is_negative())
+			neg_powers.push_back(recombine_pair_to_ex(expair(elem.rest, -(elem.coeff))));
 		else
-			others.push_back(recombine_pair_to_ex(*it));
-		++it;
+			others.push_back(recombine_pair_to_ex(elem));
 	}
 
 	if (!neg_powers.empty()) {
@@ -290,11 +285,7 @@ void mul::do_print_rat_func(const print_context & c, unsigned level,
 				//print_numer = coeff_numer.mul(*_num_1_p);
 			} else {
 				std::stringstream tstream;
-				print_context* tcontext_p;
-				if (latex)
-					tcontext_p = new print_latex(tstream, c.options);
-				else
-					tcontext_p = new print_dflt(tstream, c.options);
+				std::unique_ptr<print_context> tcontext_p(new print_latex(tstream, c.options));
 				coeff_numer.print(*tcontext_p, 0);
 				if (tstream.peek() == '-') {
 					c.s<<"-";
@@ -303,7 +294,6 @@ void mul::do_print_rat_func(const print_context & c, unsigned level,
 				} /*else {
 					const numeric &print_numer = coeff_numer;
 				}*/
-				delete tcontext_p;
 			}
 
 			numeric print_numer = negate ? coeff_numer.mul(*_num_1_p) : coeff_numer;
@@ -474,23 +464,17 @@ bool mul::info(unsigned inf) const
 		case info_flags::rational_function: {
                         if (not overall_coeff.info(info_flags::real))
                                 return false;
-			auto i = seq.begin(), end = seq.end();
-			while (i != end) {
-				if (!(recombine_pair_to_ex(*i).info(inf)))
+                        for (const auto & elem : seq)
+				if (!(recombine_pair_to_ex(elem).info(inf)))
 					return false;
-				++i;
-			}
 			if (overall_coeff.is_integer_one() && inf == info_flags::even)
 				return true;
 			return overall_coeff.info(inf);
 		}
 		case info_flags::algebraic: {
-			auto i = seq.begin(), end = seq.end();
-			while (i != end) {
-				if ((recombine_pair_to_ex(*i).info(inf)))
+                        for (const auto & elem : seq)
+				if ((recombine_pair_to_ex(elem).info(inf)))
 					return true;
-				++i;
-			}
 			return false;
 		}
 		case info_flags::positive:
@@ -498,9 +482,8 @@ bool mul::info(unsigned inf) const
                         if (not overall_coeff.info(info_flags::real))
                                 return false;
 			bool pos = true;
-			auto i = seq.begin(), end = seq.end();
-			while (i != end) {
-				const ex& factor = recombine_pair_to_ex(*i++);
+                        for (const auto & elem : seq) {
+				const ex& factor = recombine_pair_to_ex(elem);
 				if (factor.info(info_flags::positive))
 					continue;
 				else if (factor.info(info_flags::negative))
@@ -516,9 +499,8 @@ bool mul::info(unsigned inf) const
                         if (not overall_coeff.info(info_flags::real))
                                 return false;
 			bool pos = true;
-			auto i = seq.begin(), end = seq.end();
-			while (i != end) {
-				const ex& factor = recombine_pair_to_ex(*i++);
+                        for (const auto & elem : seq) {
+				const ex& factor = recombine_pair_to_ex(elem);
 				if (factor.info(info_flags::nonnegative) || factor.info(info_flags::positive))
 					continue;
 				else if (factor.info(info_flags::negative))
@@ -533,9 +515,8 @@ bool mul::info(unsigned inf) const
                         if (not overall_coeff.info(info_flags::real))
                                 return false;
 			bool pos = true;
-			auto i = seq.begin(), end = seq.end();
-			while (i != end) {
-				const ex& factor = recombine_pair_to_ex(*i++);
+                        for (const auto & elem : seq) {
+				const ex& factor = recombine_pair_to_ex(elem);
 				if (factor.info(info_flags::posint))
 					continue;
 				else if (factor.info(info_flags::negint))
@@ -553,9 +534,8 @@ bool mul::info(unsigned inf) const
                         if (not overall_coeff.info(info_flags::real))
                                 return false;
 			bool pos = true;
-			auto i = seq.begin(), end = seq.end();
-			while (i != end) {
-				const ex& factor = recombine_pair_to_ex(*i++);
+                        for (const auto & elem : seq) {
+				const ex& factor = recombine_pair_to_ex(elem);
 				if (factor.info(info_flags::nonnegint) || factor.info(info_flags::posint))
 					continue;
 				else if (factor.info(info_flags::negint))
@@ -588,16 +568,13 @@ int mul::degree(const ex & s) const
 {
 	// Sum up degrees of factors
 	int deg_sum = 0;
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		if (ex_to<numeric>(i->coeff).is_integer())
-			deg_sum += recombine_pair_to_ex(*i).degree(s);
+        for (const auto & elem : seq)
+		if (ex_to<numeric>(elem.coeff).is_integer())
+			deg_sum += recombine_pair_to_ex(elem).degree(s);
 		else {
-			if (i->rest.has(s))
+			if (elem.rest.has(s))
 				throw std::runtime_error("mul::degree() undefined degree because of non-integer exponent");
 		}
-		++i;
-	}
 	return deg_sum;
 }
 
@@ -605,16 +582,13 @@ int mul::ldegree(const ex & s) const
 {
 	// Sum up degrees of factors
 	int deg_sum = 0;
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		if (ex_to<numeric>(i->coeff).is_integer())
-			deg_sum += recombine_pair_to_ex(*i).ldegree(s);
+        for (const auto & elem : seq)
+		if (ex_to<numeric>(elem.coeff).is_integer())
+			deg_sum += recombine_pair_to_ex(elem).ldegree(s);
 		else {
-			if (i->rest.has(s))
+			if (elem.rest.has(s))
 				throw std::runtime_error("mul::ldegree() undefined degree because of non-integer exponent");
 		}
-		++i;
-	}
 	return deg_sum;
 }
 
@@ -626,27 +600,22 @@ ex mul::coeff(const ex & s, int n) const
 	if (n==0) {
 		// product of individual coeffs
 		// if a non-zero power of s is found, the resulting product will be 0
-		auto i = seq.begin(), end = seq.end();
-		while (i != end) {
-			coeffseq.push_back(recombine_pair_to_ex(*i).coeff(s,n));
-			++i;
-		}
+                for (const auto & elem : seq)
+			coeffseq.push_back(recombine_pair_to_ex(elem).coeff(s,n));
 		coeffseq.push_back(overall_coeff);
 		return (new mul(coeffseq))->setflag(status_flags::dynallocated);
 	}
 	
-	auto i = seq.begin(), end = seq.end();
 	bool coeff_found = false;
-	while (i != end) {
-		ex t = recombine_pair_to_ex(*i);
-		ex c = t.coeff(s, n);
+        for (const auto & elem : seq) {
+		const ex& t = recombine_pair_to_ex(elem);
+		const ex& c = t.coeff(s, n);
 		if (!c.is_zero()) {
 			coeffseq.push_back(c);
-			coeff_found = 1;
+			coeff_found = true;
 		} else {
 			coeffseq.push_back(t);
 		}
-		++i;
 	}
 	if (coeff_found) {
 		coeffseq.push_back(overall_coeff);
@@ -670,19 +639,18 @@ ex mul::eval(int level) const
 	std::unique_ptr<epvector> evaled_seqp = evalchildren(level);
 	if (evaled_seqp.get()) {
 		// do more evaluation later
-		return (new mul(std::move(evaled_seqp), overall_coeff))->
+		return (new mul(*evaled_seqp, overall_coeff))->
 		           setflag(status_flags::dynallocated);
 	}
 	
 #ifdef DO_GINAC_ASSERT
-	epvector::const_iterator i = seq.begin(), end = seq.end();
-	while (i != end) {
-		GINAC_ASSERT((!is_exactly_a<mul>(i->rest)) ||
-		             (!(ex_to<numeric>(i->coeff).is_integer())));
-		GINAC_ASSERT(!(i->is_canonical_numeric()));
-		if (is_exactly_a<numeric>(recombine_pair_to_ex(*i)))
+        for (const auto & elem : seq) {
+		GINAC_ASSERT((!is_exactly_a<mul>(elem.rest)) ||
+		             (!(ex_to<numeric>(elem.coeff).is_integer())));
+		GINAC_ASSERT(!(elem.is_canonical_numeric()));
+		if (is_exactly_a<numeric>(recombine_pair_to_ex(elem)))
 		    print(print_tree(std::cerr));
-		GINAC_ASSERT(!is_exactly_a<numeric>(recombine_pair_to_ex(*i)));
+		GINAC_ASSERT(!is_exactly_a<numeric>(recombine_pair_to_ex(elem)));
 		/* for paranoia */
 		//   The following test will fail on sage: exp(x)*exp(x)
 		//   Thats probably not an issue, but should be investigated.
@@ -690,7 +658,6 @@ ex mul::eval(int level) const
 		// GINAC_ASSERT(p.rest.is_equal(i->rest));
 		// GINAC_ASSERT(p.coeff.is_equal(i->coeff));
 		/* end paranoia */
-		++i;
 	}
 #endif // def DO_GINAC_ASSERT
 	
@@ -703,14 +670,14 @@ ex mul::eval(int level) const
 	// handle infinity and handle exp(a)*exp(b) -> exp(a+b) and
 	unsigned exp_count = 0;
 	for (auto i = seq.begin(); i != seq.end(); i++) {
-		const numeric& coeff = ex_to<numeric>(i->coeff);
+		const numeric& num_coeff = ex_to<numeric>(i->coeff);
 		if (unlikely(is_exactly_a<infinity>(i->rest)))
 			return eval_infinity(i);
 		if (unlikely(is_ex_the_function(i->rest, exp) and
-			     coeff.is_integer())) {
+			     num_coeff.is_integer())) {
 			exp_count++;
-			if (exp_count>1 or not coeff.is_equal(*_num1_p) or
-                                not coeff.is_integer())
+			if (exp_count>1 or not num_coeff.is_equal(*_num1_p) or
+                                not num_coeff.is_integer())
 				return eval_exponentials();
 		}
 	}
@@ -734,14 +701,11 @@ ex mul::eval(int level) const
 	           ex_to<numeric>((*seq.begin()).coeff).is_equal(*_num1_p)) {
 		// *(+(x,y,...);c) -> +(*(x,c),*(y,c),...) (c numeric(), no powers of +())
 		const add & addref = ex_to<add>((*seq.begin()).rest);
-		std::unique_ptr<epvector> distrseq(new epvector);
-		distrseq->reserve(addref.seq.size());
-		auto i = addref.seq.begin(), end = addref.seq.end();
-		while (i != end) {
-			distrseq->push_back(addref.combine_pair_with_coeff_to_pair(*i, overall_coeff));
-			++i;
-		}
-		return (new add(std::move(distrseq),
+		epvector distrseq;
+		distrseq.reserve(addref.seq.size());
+                for (const auto & elem : addref.seq)
+			distrseq.push_back(addref.combine_pair_with_coeff_to_pair(elem, overall_coeff));
+		return (new add(distrseq,
 		                ex_to<numeric>(addref.overall_coeff).
 		                mul_dyn(ex_to<numeric>(overall_coeff)))
 		       )->setflag(status_flags::dynallocated | status_flags::evaluated);
@@ -752,7 +716,7 @@ ex mul::eval(int level) const
 		auto last = seq.end();
 		auto i = seq.begin();
 		auto j = seq.begin();
-		std::unique_ptr<epvector> s(new epvector);
+		epvector s;
 		numeric oc = *_num1_p;
 		bool something_changed = false;
 		while (i!=last) {
@@ -783,12 +747,12 @@ ex mul::eval(int level) const
 			}
 
 			if (! something_changed) {
-				s->reserve(seq_size);
+				s.reserve(seq_size);
 				something_changed = true;
 			}
 
 			while ((j!=i) && (j!=last)) {
-				s->push_back(*j);
+				s.push_back(*j);
 				++j;
 			}
 
@@ -804,7 +768,7 @@ ex mul::eval(int level) const
 
 			// divide add by the number in place to save at least 2 .eval() calls
 			const add& addref = ex_to<add>(i->rest);
-			auto  primitive = new add(addref);
+			auto primitive = new add(addref);
 			primitive->setflag(status_flags::dynallocated);
 			primitive->clearflag(status_flags::hash_calculated);
 			primitive->overall_coeff = ex_to<numeric>(primitive->overall_coeff).div_dyn(c);
@@ -812,20 +776,20 @@ ex mul::eval(int level) const
 			for (auto & elem : primitive->seq)
 				elem.coeff = ex_to<numeric>(elem.coeff).div_dyn(c);
 
-			s->push_back(expair(*primitive, _ex1));
+			s.push_back(expair(*primitive, _ex1));
 
 			++i;
 			++j;
 		}
 		if (something_changed) {
 			while (j!=last) {
-				s->push_back(*j);
+				s.push_back(*j);
 				++j;
 			}
-			if (s->empty()) {
+			if (s.empty()) {
 				return ex_to<numeric>(overall_coeff).mul_dyn(oc);
 			}
-			return (new mul(std::move(s), ex_to<numeric>(overall_coeff).mul_dyn(oc))
+			return (new mul(s, ex_to<numeric>(overall_coeff).mul_dyn(oc))
 			       )->setflag(status_flags::dynallocated);
 		}
 	}
@@ -839,25 +803,25 @@ ex mul::eval_exponentials() const
 {
 	ex exp_arg = _ex0;
 	numeric oc = *_num1_p;
-	std::unique_ptr<epvector> s(new epvector);
-	s->reserve(seq.size());
+	epvector s;
+	s.reserve(seq.size());
 
-	for (auto i = seq.begin(); i != seq.end(); i++) {
-		const numeric & coeff = ex_to<numeric>(i->coeff);
-		const bool simplifyable_exp = is_ex_the_function(i->rest, exp) and coeff.is_integer();
+	for (const auto & elem : seq) {
+		const numeric & num_coeff = ex_to<numeric>(elem.coeff);
+		const bool simplifyable_exp = is_ex_the_function(elem.rest, exp) and num_coeff.is_integer();
 		if (likely(not simplifyable_exp))
-			s->push_back(*i);
+			s.push_back(elem);
 		else
-			exp_arg += i->rest.op(0) * coeff;
+			exp_arg += elem.rest.op(0) * num_coeff;
 	}
 
 	ex new_exp = exp(exp_arg);
 	if (is_a<numeric>(new_exp))
 		oc = oc.mul(ex_to<numeric>(new_exp));
 	else
-		s->push_back(expair(new_exp, _ex1));
+		s.push_back(expair(new_exp, _ex1));
 
-	mul * result = new mul(std::move(s), ex_to<numeric>(overall_coeff).mul_dyn(oc));
+	mul * result = new mul(s, ex_to<numeric>(overall_coeff).mul_dyn(oc));
 	return result->setflag(status_flags::dynallocated);
 }
 
@@ -885,17 +849,14 @@ ex mul::evalf(int level, PyObject* parent) const
 	if (level==-max_recursion_level)
 		throw(std::runtime_error("max recursion level reached"));
 	
-	std::unique_ptr<epvector> s(new epvector);
-	s->reserve(seq.size());
+	epvector s;
+	s.reserve(seq.size());
 
 	--level;
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		s->push_back(combine_ex_with_coeff_to_pair(
-					i->rest.evalf(level, parent), i->coeff));
-		++i;
-	}
-	return mul(std::move(s), overall_coeff.evalf(level, parent));
+        for (const auto & elem : seq)
+		s.push_back(combine_ex_with_coeff_to_pair(
+                elem.rest.evalf(level, parent), elem.coeff));
+	return mul(s, overall_coeff.evalf(level, parent));
 }
 
 void mul::find_real_imag(ex & rp, ex & ip) const
@@ -943,21 +904,19 @@ ex mul::evalm() const
 	// Evaluate children first, look whether there are any matrices at all
 	// (there can be either no matrices or one matrix; if there were more
 	// than one matrix, it would be a non-commutative product)
-	std::unique_ptr<epvector> s(new epvector);
-	s->reserve(seq.size());
+	epvector s;
+	s.reserve(seq.size());
 
 	bool have_matrix = false;
 	epvector::iterator the_matrix;
 
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		const ex &m = recombine_pair_to_ex(*i).evalm();
-		s->push_back(split_ex_to_pair(m));
+        for (const auto & elem : seq) {
+		const ex &m = recombine_pair_to_ex(elem).evalm();
+		s.push_back(split_ex_to_pair(m));
 		if (is_a<matrix>(m)) {
 			have_matrix = true;
-			the_matrix = s->end() - 1;
+			the_matrix = s.end() - 1;
 		}
-		++i;
 	}
 
 	if (have_matrix) {
@@ -965,12 +924,12 @@ ex mul::evalm() const
 		// The product contained a matrix. We will multiply all other factors
 		// into that matrix.
 		matrix m = ex_to<matrix>(the_matrix->rest);
-		s->erase(the_matrix);
-		ex scalar = (new mul(std::move(s), overall_coeff))->setflag(status_flags::dynallocated);
+		s.erase(the_matrix);
+		ex scalar = (new mul(s, overall_coeff))->setflag(status_flags::dynallocated);
 		return m.mul_scalar(scalar);
 
 	} else
-		return (new mul(std::move(s), overall_coeff))->setflag(status_flags::dynallocated);
+		return (new mul(s, overall_coeff))->setflag(status_flags::dynallocated);
 }
 
 ex mul::eval_ncmul(const exvector & v) const
@@ -979,12 +938,9 @@ ex mul::eval_ncmul(const exvector & v) const
 		return inherited::eval_ncmul(v);
 
 	// Find first noncommutative element and call its eval_ncmul()
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		if (i->rest.return_type() == return_types::noncommutative)
-			return i->rest.eval_ncmul(v);
-		++i;
-	}
+        for (const auto & elem : seq)
+		if (elem.rest.return_type() == return_types::noncommutative)
+			return elem.rest.eval_ncmul(v);
 	return inherited::eval_ncmul(v);
 }
 
@@ -1040,7 +996,7 @@ bool tryfactsubs(const ex & origfactor, const ex & patternfactor, int & nummatch
   * is true for factors that have been matched by the current match.
   */
 bool algebraic_match_mul_with_mul(const mul &e, const ex &pat, lst &repls,
-		int factor, int &nummatches, const std::vector<bool> &subsed,
+		unsigned factor, int &nummatches, const std::vector<bool> &subsed,
 		std::vector<bool> &matched)
 {
 	GINAC_ASSERT(subsed.size() == e.nops());
@@ -1150,8 +1106,8 @@ ex mul::conjugate() const
 {
 	// The base class' method is wrong here because we have to be careful at
 	// branch cuts. power::conjugate takes care of that already, so use it.
-	epvector *newepv = nullptr;
-	for (auto i=seq.begin(); i!=seq.end(); ++i) {
+	std::unique_ptr<epvector> newepv(nullptr);
+        for (auto i=seq.begin(); i!=seq.end(); ++i) {
 		if (newepv) {
 			newepv->push_back(split_ex_to_pair(recombine_pair_to_ex(*i).conjugate()));
 			continue;
@@ -1161,7 +1117,7 @@ ex mul::conjugate() const
 		if (c.is_equal(x)) {
 			continue;
 		}
-		newepv = new epvector;
+		newepv.reset(new epvector);
 		newepv->reserve(seq.size());
 		for (auto j=seq.begin(); j!=i; ++j) {
 			newepv->push_back(*j);
@@ -1173,7 +1129,6 @@ ex mul::conjugate() const
 		return *this;
 	}
 	ex result = thisexpairseq(newepv ? *newepv : seq, x);
-	delete newepv;
 	return result;
 }
 
@@ -1233,26 +1188,26 @@ unsigned mul::return_type() const
 	}
 	
 	bool all_commutative = true;
-	epvector::const_iterator noncommutative_element; // point to first found nc element
+        expair noncommutative_element;
 	
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		unsigned rt = i->rest.return_type();
+        for (const auto & elem : seq) {
+		unsigned rt = elem.rest.return_type();
 		if (rt == return_types::noncommutative_composite)
 			return rt; // one ncc -> mul also ncc
-		if ((rt == return_types::noncommutative) && (all_commutative)) {
-			// first nc element found, remember position
-			noncommutative_element = i;
-			all_commutative = false;
-		}
-		if ((rt == return_types::noncommutative) && (!all_commutative)) {
-			// another nc element found, compare type_infos
-			if (noncommutative_element->rest.return_type_tinfo() != i->rest.return_type_tinfo()) {
-					// different types -> mul is ncc
-					return return_types::noncommutative_composite;
+		if (rt == return_types::noncommutative) {
+                        if (all_commutative) {
+                                // first nc element found, remember position
+                                noncommutative_element = elem;
+                                all_commutative = false;
 			}
-		}
-		++i;
+                        else {
+                                // another nc element found, compare type_infos
+                                if (noncommutative_element.rest.return_type_tinfo() != elem.rest.return_type_tinfo()) {
+                                                // different types -> mul is ncc
+                                        return return_types::noncommutative_composite;
+                                }
+        		}
+                }
 	}
 	// all factors checked
 	return all_commutative ? return_types::commutative : return_types::noncommutative;
@@ -1264,13 +1219,11 @@ tinfo_t mul::return_type_tinfo() const
 		return this;  // mul without factors: should not happen
 	
 	// return type_info of first noncommutative element
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		if (i->rest.return_type() == return_types::noncommutative)
-			return i->rest.return_type_tinfo();
-		++i;
-	}
-	// no noncommutative element found, should not happen
+        for (const auto & elem : seq)
+		if (elem.rest.return_type() == return_types::noncommutative)
+			return elem.rest.return_type_tinfo();
+
+        // no noncommutative element found, should not happen
 	return this;
 }
 
@@ -1281,7 +1234,7 @@ ex mul::thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming)
 
 ex mul::thisexpairseq(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming) const
 {
-	return (new mul(std::move(vp), oc, do_index_renaming))->setflag(status_flags::dynallocated);
+	return (new mul(*vp, oc, do_index_renaming))->setflag(status_flags::dynallocated);
 }
 
 expair mul::split_ex_to_pair(const ex & e) const
@@ -1396,16 +1349,18 @@ bool mul::can_be_further_expanded(const ex & e)
 
 ex mul::expand(unsigned options) const
 {
-	{
 	// trivial case: expanding the monomial (~ 30% of all calls)
-		auto i = seq.begin(), seq_end = seq.end();
-		while ((i != seq.end()) &&  is_a<symbol>(i->rest) && i->coeff.info(info_flags::integer))
-			++i;
-		if (i == seq_end) {
-			setflag(status_flags::expanded);
-			return *this;
-		}
-	}
+        bool all_intsym = true;
+        for (const auto & elem : seq) 
+                if (not is_a<symbol>(elem.rest) or not elem.coeff.info(info_flags::integer))
+                {
+                        all_intsym = false;
+                        break;
+                }
+        if (all_intsym) {
+                setflag(status_flags::expanded);
+                return *this;
+        }
 
 	// do not rename indices if the object has no indices at all
 	if ((!(options & expand_options::expand_rename_idx)) && 
@@ -1440,10 +1395,10 @@ ex mul::expand(unsigned options) const
 				// in the presence of asymptotically good sorting:
 				const add& add1 = (sizedifference<0 ? ex_to<add>(last_expanded) : ex_to<add>(elem.rest));
 				const add& add2 = (sizedifference<0 ? ex_to<add>(elem.rest) : ex_to<add>(last_expanded));
-				const epvector::const_iterator add1begin = add1.seq.begin();
-				const epvector::const_iterator add1end   = add1.seq.end();
-				const epvector::const_iterator add2begin = add2.seq.begin();
-				const epvector::const_iterator add2end   = add2.seq.end();
+				const auto& add1begin = add1.seq.begin();
+				const auto& add1end   = add1.seq.end();
+				const auto& add2begin = add2.seq.begin();
+				const auto& add2end   = add2.seq.end();
 				epvector distrseq;
 				distrseq.reserve(add1.seq.size()+add2.seq.size());
 
@@ -1452,8 +1407,9 @@ ex mul::expand(unsigned options) const
 					if (add1.overall_coeff.is_integer_one())
 						distrseq.insert(distrseq.end(),add2begin,add2end);
 					else
-						for (epvector::const_iterator i=add2begin; i!=add2end; ++i)
-							distrseq.push_back(expair(i->rest, ex_to<numeric>(i->coeff).mul_dyn(ex_to<numeric>(add1.overall_coeff))));
+                                                for (const auto & elem2 : add2.seq)
+							distrseq.push_back(expair(elem2.rest,
+                                                                ex_to<numeric>(elem2.coeff).mul_dyn(ex_to<numeric>(add1.overall_coeff))));
 				}
 
 				// Multiply add1 with the overall coefficient of add2 and append it to distrseq:
@@ -1461,8 +1417,8 @@ ex mul::expand(unsigned options) const
 					if (add2.overall_coeff.is_integer_one())
 						distrseq.insert(distrseq.end(),add1begin,add1end);
 					else
-						for (epvector::const_iterator i=add1begin; i!=add1end; ++i)
-							distrseq.push_back(expair(i->rest, ex_to<numeric>(i->coeff).mul_dyn(ex_to<numeric>(add2.overall_coeff))));
+                                                for (const auto & elem1 : add1.seq)
+							distrseq.push_back(expair(elem1.rest, ex_to<numeric>(elem1.coeff).mul_dyn(ex_to<numeric>(add2.overall_coeff))));
 				}
 
 				// Compute the new overall coefficient and put it together:
@@ -1472,12 +1428,12 @@ ex mul::expand(unsigned options) const
 				lst dummy_subs;
 
 				if (!skip_idx_rename) {
-					for (epvector::const_iterator i=add1begin; i!=add1end; ++i) {
-						add_indices = get_all_dummy_indices_safely(i->rest);
+                                        for (const auto & elem1 : add1.seq) {
+						add_indices = get_all_dummy_indices_safely(elem1.rest);
 						add1_dummy_indices.insert(add1_dummy_indices.end(), add_indices.begin(), add_indices.end());
 					}
-					for (epvector::const_iterator i=add2begin; i!=add2end; ++i) {
-						add_indices = get_all_dummy_indices_safely(i->rest);
+                                        for (const auto & elem2 : add2.seq) {
+						add_indices = get_all_dummy_indices_safely(elem2.rest);
 						add2_dummy_indices.insert(add2_dummy_indices.end(), add_indices.begin(), add_indices.end());
 					}
 
@@ -1487,24 +1443,24 @@ ex mul::expand(unsigned options) const
 				}
 
 				// Multiply explicitly all non-numeric terms of add1 and add2:
-				for (epvector::const_iterator i2=add2begin; i2!=add2end; ++i2) {
+                                for (const auto & elem2 : add2.seq) {
 					// We really have to combine terms here in order to compactify
 					// the result.  Otherwise it would become waayy tooo bigg.
 					numeric oc(*_num0_p);
 					epvector distrseq2;
 					distrseq2.reserve(add1.seq.size());
-					const ex i2_new = (skip_idx_rename || (dummy_subs.op(0).nops() == 0) ?
-							i2->rest :
-							i2->rest.subs(ex_to<lst>(dummy_subs.op(0)), 
+					const ex& i2_new = (skip_idx_rename || (dummy_subs.op(0).nops() == 0) ?
+							elem2.rest :
+							elem2.rest.subs(ex_to<lst>(dummy_subs.op(0)),
 								ex_to<lst>(dummy_subs.op(1)), subs_options::no_pattern));
-					for (epvector::const_iterator i1=add1begin; i1!=add1end; ++i1) {
+                                        for (const auto & elem1 : add1.seq) {
 						// Don't push_back expairs which might have a rest that evaluates to a numeric,
 						// since that would violate an invariant of expairseq:
-						const ex rest = (new mul(i1->rest, i2_new))->setflag(status_flags::dynallocated);
+						const ex rest = (new mul(elem1.rest, i2_new))->setflag(status_flags::dynallocated);
 						if (is_exactly_a<numeric>(rest)) {
-							oc += ex_to<numeric>(rest).mul(ex_to<numeric>(i1->coeff).mul(ex_to<numeric>(i2->coeff)));
+							oc += ex_to<numeric>(rest).mul(ex_to<numeric>(elem1.coeff).mul(ex_to<numeric>(elem2.coeff)));
 						} else {
-							distrseq2.push_back(expair(rest, ex_to<numeric>(i1->coeff).mul_dyn(ex_to<numeric>(i2->coeff))));
+							distrseq2.push_back(expair(rest, ex_to<numeric>(elem1.coeff).mul_dyn(ex_to<numeric>(elem2.coeff))));
 						}
 					}
 					tmp_accu += (new add(distrseq2, oc))->setflag(status_flags::dynallocated);
@@ -1595,7 +1551,7 @@ const epvector & mul::get_sorted_seq() const
  *  pointer, if sequence is unchanged. */
 std::unique_ptr<epvector> mul::expandchildren(unsigned options) const
 {
-	const epvector::const_iterator last = seq.end();
+	const auto& last = seq.end();
 	auto cit = seq.begin();
 	while (cit!=last) {
 		const ex & factor = recombine_pair_to_ex(*cit);
diff --git a/ginac/mul.h b/ginac/mul.h
index 962fed6..7a569bc 100644
--- a/ginac/mul.h
+++ b/ginac/mul.h
@@ -44,7 +44,7 @@ public:
 	mul(const exvector & v, bool hold=false);
 	mul(const epvector & v);
 	mul(const epvector & v, const ex & oc, bool do_index_renaming = false);
-	mul(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false);
+//	mul(std::unique_ptr<epvector> vp, const ex & oc, bool do_index_renaming = false);
 	mul(const ex & lh, const ex & mh, const ex & rh);
 	
 	// functions overriding virtual functions from base classes
diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp
index 086b554..e743471 100644
--- a/ginac/ncmul.cpp
+++ b/ginac/ncmul.cpp
@@ -124,7 +124,7 @@ bool ncmul::info(unsigned inf) const
 	return inherited::info(inf);
 }
 
-typedef std::vector<int> intvector;
+typedef std::vector<unsigned> intvector;
 
 ex ncmul::expand(unsigned options) const
 {
@@ -213,11 +213,8 @@ int ncmul::degree(const ex & s) const
 
 	// Sum up degrees of factors
 	int deg_sum = 0;
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		deg_sum += i->degree(s);
-		++i;
-	}
+        for (const auto & elem : seq)
+		deg_sum += elem.degree(s);
 	return deg_sum;
 }
 
@@ -228,11 +225,8 @@ int ncmul::ldegree(const ex & s) const
 
 	// Sum up degrees of factors
 	int deg_sum = 0;
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		deg_sum += i->degree(s);
-		++i;
-	}
+        for (const auto & elem : seq)
+		deg_sum += elem.degree(s);
 	return deg_sum;
 }
 
@@ -255,17 +249,15 @@ ex ncmul::coeff(const ex & s, int n) const
 		return (new ncmul(coeffseq,1))->setflag(status_flags::dynallocated);
 	}
 		 
-	auto i = seq.begin(), end = seq.end();
 	bool coeff_found = false;
-	while (i != end) {
-		ex c = i->coeff(s,n);
+        for (const auto & elem : seq) {
+		ex c = elem.coeff(s,n);
 		if (c.is_zero()) {
-			coeffseq.push_back(*i);
+			coeffseq.push_back(elem);
 		} else {
 			coeffseq.push_back(c);
 			coeff_found = true;
 		}
-		++i;
 	}
 
 	if (coeff_found) return (new ncmul(coeffseq,1))->setflag(status_flags::dynallocated);
@@ -381,11 +373,11 @@ ex ncmul::eval(int level) const
 		exvector noncommutativeseq;
 		noncommutativeseq.reserve(assocseq.size()-count_commutative);
 		size_t num = assocseq.size();
-		for (size_t i=0; i<num; ++i) {
-			if (rettypes[i]==return_types::commutative)
-				commutativeseq.push_back(assocseq[i]);
+		for (size_t ii=0; ii<num; ++ii) {
+			if (rettypes[ii]==return_types::commutative)
+				commutativeseq.push_back(assocseq[ii]);
 			else
-				noncommutativeseq.push_back(assocseq[i]);
+				noncommutativeseq.push_back(assocseq[ii]);
 		}
 		commutativeseq.push_back((new ncmul(noncommutativeseq,1))->setflag(status_flags::dynallocated));
 		return (new mul(commutativeseq))->setflag(status_flags::dynallocated);
@@ -554,24 +546,22 @@ unsigned ncmul::return_type() const
 		return return_types::commutative;
 
 	bool all_commutative = true;
-	exvector::const_iterator noncommutative_element; // point to first found nc element
 
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		unsigned rt = i->return_type();
+        for (const auto & elem : seq) {
+                ex noncommutative_element; // point to first found nc element
+		unsigned rt = elem.return_type();
 		if (rt == return_types::noncommutative_composite)
 			return rt; // one ncc -> mul also ncc
 		if ((rt == return_types::noncommutative) && (all_commutative)) {
 			// first nc element found, remember position
-			noncommutative_element = i;
+			noncommutative_element = elem;
 			all_commutative = false;
 		}
 		if ((rt == return_types::noncommutative) && (!all_commutative)) {
 			// another nc element found, compare type_infos
-			if(noncommutative_element->return_type_tinfo() != i->return_type_tinfo())
+			if(noncommutative_element.return_type_tinfo() != elem.return_type_tinfo())
 					return return_types::noncommutative_composite;
 		}
-		++i;
 	}
 	// all factors checked
 	GINAC_ASSERT(!all_commutative); // not all factors should commutate, because this is a ncmul();
@@ -584,12 +574,9 @@ tinfo_t ncmul::return_type_tinfo() const
 		return this;
 
 	// return type_info of first noncommutative element
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		if (i->return_type() == return_types::noncommutative)
-			return i->return_type_tinfo();
-		++i;
-	}
+        for (const auto & elem : seq)
+		if (elem.return_type() == return_types::noncommutative)
+			return elem.return_type_tinfo();
 
 	// no noncommutative element found, should not happen
 	return this;
@@ -607,8 +594,8 @@ tinfo_t ncmul::return_type_tinfo() const
 
 std::unique_ptr<exvector> ncmul::expandchildren(unsigned options) const
 {
-	auto cit = this->seq.begin(), end = this->seq.end();
-	while (cit != end) {
+	auto cit = this->seq.begin(), citend = this->seq.end();
+	while (cit != citend) {
 		const ex & expanded_ex = cit->expand(options);
 		if (!are_ex_trivially_equal(*cit, expanded_ex)) {
 
@@ -621,7 +608,7 @@ std::unique_ptr<exvector> ncmul::expandchildren(unsigned options) const
 			++cit;
 
 			// copy rest
-			while (cit != end) {
+			while (cit != citend) {
 				s->push_back(cit->expand(options));
 				++cit;
 			}
diff --git a/ginac/normal.cpp b/ginac/normal.cpp
index d195cf8..cb21fa0 100644
--- a/ginac/normal.cpp
+++ b/ginac/normal.cpp
@@ -156,12 +156,10 @@ typedef std::vector<sym_desc> sym_desc_vec;
 // Add symbol the sym_desc_vec (used internally by get_symbol_stats())
 static void add_symbol(const ex &s, sym_desc_vec &v)
 {
-	sym_desc_vec::const_iterator it = v.begin(), itend = v.end();
-	while (it != itend) {
-		if (it->sym.is_equal(s))  // If it's already in there, don't add it a second time
+	for (const auto& elem : v)
+		if (elem.sym.is_equal(s))  // If it's already in there, don't add it a second time
 			return;
-		++it;
-	}
+
 	sym_desc d;
 	d.sym = s;
 	v.push_back(d);
@@ -794,10 +792,10 @@ static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_ite
 
 	if (is_exactly_a<mul>(b)) {
 		ex qbar = a;
-		for (const_iterator itrb = b.begin(); itrb != b.end(); ++itrb) {
+		for (const auto& elem : b) {
 			sym_desc_vec sym_stats;
-			get_symbol_stats(a, *itrb, sym_stats);
-			if (!divide_in_z(qbar, *itrb, q, sym_stats.begin()))
+			get_symbol_stats(a, elem, sym_stats);
+			if (!divide_in_z(qbar, elem, q, sym_stats.begin()))
 				return false;
 
 			qbar = q;
@@ -949,14 +947,14 @@ ex ex::content(const ex &x) const
 	ex c = e.integer_content();
 	ex r = e / c;
 	int deg = r.degree(x);
-	ex lcoeff = r.coeff(x, deg);
-	if (lcoeff.info(info_flags::integer))
+	ex lcoef = r.coeff(x, deg);
+	if (lcoef.info(info_flags::integer))
 		return c;
 
 	// GCD of all coefficients
 	int ldeg = r.ldegree(x);
 	if (deg == ldeg)
-		return lcoeff * c / lcoeff.unit(x);
+		return lcoef * c / lcoef.unit(x);
 	ex cont = _ex0;
 	for (int i=ldeg; i<=deg; i++)
 		cont = gcd(r.coeff(x, i), cont, nullptr, nullptr, false);
@@ -1217,14 +1215,14 @@ ex add::smod(const numeric &xi) const
 	auto itend = seq.end();
 	while (it != itend) {
 		GINAC_ASSERT(!is_exactly_a<numeric>(it->rest));
-		numeric coeff = GiNaC::smod(ex_to<numeric>(it->coeff), xi);
-		if (!coeff.is_zero())
-			newseq.push_back(expair(it->rest, coeff));
+		numeric num_coeff = GiNaC::smod(ex_to<numeric>(it->coeff), xi);
+		if (!num_coeff.is_zero())
+			newseq.push_back(expair(it->rest, num_coeff));
 		it++;
 	}
 	GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
-	numeric coeff = GiNaC::smod(ex_to<numeric>(overall_coeff), xi);
-	return (new add(newseq,coeff))->setflag(status_flags::dynallocated);
+	numeric num_coeff = GiNaC::smod(ex_to<numeric>(overall_coeff), xi);
+	return (new add(newseq, num_coeff))->setflag(status_flags::dynallocated);
 }
 
 ex mul::smod(const numeric &xi) const
@@ -1634,7 +1632,7 @@ factored_b:
 	// to the end:
 	rotate(sym_stats.begin(), vari, sym_stats.end());
 
-	sym_desc_vec::const_iterator var = sym_stats.begin();
+	auto var = sym_stats.begin();
 	const ex &x = var->sym;
 
 	// Cancel trivial common factor
@@ -1802,11 +1800,8 @@ ex sqrfree(const ex &a, const lst &l)
 	if (l.nops()==0) {
 		sym_desc_vec sdv;
 		get_symbol_stats(a, _ex0, sdv);
-		sym_desc_vec::const_iterator it = sdv.begin(), itend = sdv.end();
-		while (it != itend) {
-			args.append(it->sym);
-			++it;
-		}
+		for (const auto& elem : sdv)
+			args.append(elem.sym);
 	} else {
 		args = l;
 	}
@@ -1838,9 +1833,11 @@ ex sqrfree(const ex &a, const lst &l)
 
 	// Done with recursion, now construct the final result
 	ex result = _ex1;
-	exvector::const_iterator it = factors.begin(), itend = factors.end();
-	for (int p = 1; it!=itend; ++it, ++p)
-		result *= power(*it, p);
+        {
+        int p = 1;
+	for (const auto& elem : factors)
+		result *= power(elem, p++);
+        }
 
 	// Yun's algorithm does not account for constant factors.  (For univariate
 	// polynomials it works only in the monic case.)  We can correct this by
@@ -1949,7 +1946,7 @@ static ex replace_with_symbol(const ex & e, exmap & repl, exmap & rev_lookup)
 	ex e_replaced = e.subs(repl, subs_options::no_pattern);
 
 	// Expression already replaced? Then return the assigned symbol
-	exmap::const_iterator it = rev_lookup.find(e_replaced);
+	auto it = rev_lookup.find(e_replaced);
 	if (it != rev_lookup.end())
 		return it->second;
 
@@ -1973,9 +1970,9 @@ static ex replace_with_symbol(const ex & e, exmap & repl)
 	ex e_replaced = e.subs(repl, subs_options::no_pattern);
 
 	// Expression already replaced? Then return the assigned symbol
-	for (exmap::const_iterator it = repl.begin(); it != repl.end(); ++it)
-		if (it->second.is_equal(e_replaced))
-			return it->first;
+	for (const auto& elem : repl)
+		if (elem.second.is_equal(e_replaced))
+			return elem.first;
 
 	// Otherwise create new symbol and add to list, taking care that the
 	// replacement expression doesn't itself contain symbols from repl,
@@ -2137,8 +2134,8 @@ ex add::normal(exmap & repl, exmap & rev_lookup, int level) const
 //std::clog << "add::normal uses " << nums.size() << " summands:\n";
 
 	// Add fractions sequentially
-	exvector::const_iterator num_it = nums.begin(), num_itend = nums.end();
-	exvector::const_iterator den_it = dens.begin(), den_itend = dens.end();
+	auto num_it = nums.begin(), num_itend = nums.end();
+	auto den_it = dens.begin(), den_itend = dens.end();
 //std::clog << " num = " << *num_it << ", den = " << *den_it << std::endl;
 	ex num = *num_it++, den = *den_it++;
 	while (num_it != num_itend) {
@@ -2388,8 +2385,8 @@ ex ex::to_rational(lst & repl_lst) const
 
 	// Convert exmap back to lst
 	repl_lst.remove_all();
-	for (exmap::const_iterator it = m.begin(); it != m.end(); ++it)
-		repl_lst.append(it->first == it->second);
+	for (const auto& elem : m)
+		repl_lst.append(elem.first == elem.second);
 
 	return ret;
 }
@@ -2411,8 +2408,8 @@ ex ex::to_polynomial(lst & repl_lst) const
 
 	// Convert exmap back to lst
 	repl_lst.remove_all();
-	for (exmap::const_iterator it = m.begin(); it != m.end(); ++it)
-		repl_lst.append(it->first == it->second);
+	for (const auto& elem : m)
+		repl_lst.append(elem.first == elem.second);
 
 	return ret;
 }
diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp
index 28f79bd..ba00995 100644
--- a/ginac/numeric.cpp
+++ b/ginac/numeric.cpp
@@ -78,7 +78,7 @@ std::cerr << "- " << long(op) << ", " << Py_REFCNT(op) << ", " << Py_TYPE(op)->t
 
 const GiNaC::numeric& to_numeric(GiNaC::ex& e)
 {
-return GiNaC::ex_to<GiNaC::numeric>(e);
+        return GiNaC::ex_to<GiNaC::numeric>(e);
 }
 
 // Call the Python function f on *this as input and return the result
@@ -218,6 +218,23 @@ void ginac_pyinit_I(PyObject* z) {
         initialized = true;
         Py_INCREF(z);
         GiNaC::I = z; // I is a global constant defined below.
+
+        PyObject* m = PyImport_ImportModule("sage.rings.real_mpfr");
+        if (!m)
+                py_error("Error importing sage.rings.real_mpfr");
+        PyObject* obj = PyObject_GetAttrString(m, "RR");
+        if (!obj)
+                py_error("Error getting RR attribute");
+        Py_INCREF(obj);
+        GiNaC::RR = obj;
+        m = PyImport_ImportModule("sage.rings.all");
+        if (!m)
+                py_error("Error importing sage.rings.real_mpfr");
+        obj = PyObject_GetAttrString(m, "CC");
+        if (!obj)
+                py_error("Error getting CC attribute");
+        Py_INCREF(obj);
+        GiNaC::CC = obj;
 }
 
 static PyObject* pyfunc_Integer = nullptr;
@@ -251,6 +268,7 @@ PyObject* Rational(const long int& n, const long int& d) {
 namespace GiNaC {
 
 numeric I;
+PyObject *RR, *CC;
 
 ///////////////////////////////////////////////////////////////////////////////
 // class numeric
@@ -404,10 +422,10 @@ numeric::numeric(unsigned long i) : basic(&numeric::tinfo_static) {
 /** Constructor for rational numerics a/b.
  *
  *  @exception overflow_error (division by zero) */
-numeric::numeric(long numer, long denom) : basic(&numeric::tinfo_static) {
-        if (!denom)
+numeric::numeric(long num, long den) : basic(&numeric::tinfo_static) {
+        if (!den)
                 throw std::overflow_error("numeric::div(): division by zero");
-        const numeric &value = numeric(numer) / numeric(denom);
+        const numeric &value = numeric(num) / numeric(den);
         v = value.v;
         t = value.t;
         if (t == PYOBJECT)
@@ -846,27 +864,27 @@ const numeric numeric::div(const numeric &other) const {
 
 /** Numerical exponentiation.  Raises *this to the power given as argument and
  *  returns result as a numeric object. */
-const numeric numeric::power(const numeric &exp) const {
+const numeric numeric::power(const numeric &exponent) const {
         verbose("pow");
-        if (t != exp.t) {
+        if (t != exponent.t) {
                 numeric a, b;
-                coerce(a, b, *this, exp);
+                coerce(a, b, *this, exponent);
                 return pow(a, b);
         }
         switch (t) {
                 case DOUBLE:
-                        return ::pow(v._double, exp.v._double);
+                        return ::pow(v._double, exponent.v._double);
                 case LONG:
                         // TODO: change to use GMP!
-                        return ::pow((double) v._long, (double) exp.v._long);
+                        return ::pow((double) v._long, (double) exponent.v._long);
                 case PYOBJECT:
                         if PyInt_Check(v._pyobject) {
                                 PyObject* o = Integer(PyInt_AsLong(v._pyobject));
-                                PyObject* r = PyNumber_Power(o, exp.v._pyobject, Py_None);
+                                PyObject* r = PyNumber_Power(o, exponent.v._pyobject, Py_None);
                                 Py_DECREF(o);
                                 return r;
                         }
-                        return PyNumber_Power(v._pyobject, exp.v._pyobject, Py_None);
+                        return PyNumber_Power(v._pyobject, exponent.v._pyobject, Py_None);
                 default:
                         stub("invalid type: pow numeric");
         }
@@ -1024,13 +1042,13 @@ int numeric::csgn() const {
                         if (is_real()) {
                                 result = Pynac_PyObj_Cmp(v._pyobject, ZERO, "csgn");
                         } else {
-                                PyObject *t = py_funcs.py_real(v._pyobject);
-                                result = Pynac_PyObj_Cmp(t, ZERO, "csgn");
-                                Py_DECREF(t);
+                                PyObject *tmp = py_funcs.py_real(v._pyobject);
+                                result = Pynac_PyObj_Cmp(tmp, ZERO, "csgn");
+                                Py_DECREF(tmp);
                                 if (result == 0) {
-                                        t = py_funcs.py_imag(v._pyobject);
-                                        result = Pynac_PyObj_Cmp(t, ZERO, "csgn");
-                                        Py_DECREF(t);
+                                        tmp = py_funcs.py_imag(v._pyobject);
+                                        result = Pynac_PyObj_Cmp(tmp, ZERO, "csgn");
+                                        Py_DECREF(tmp);
                                 }
                         }
                         return result;
@@ -2105,6 +2123,8 @@ const numeric isqrt(const numeric &x) {
 
 /** Floating point evaluation of Sage's constants. */
 ex ConstantEvalf(unsigned serial, PyObject* parent) {
+        if (parent == nullptr)
+                parent = CC;
         PyObject* x = py_funcs.py_eval_constant(serial, parent);
         if (!x) py_error("error getting digits of constant");
         return x;
diff --git a/ginac/numeric.h b/ginac/numeric.h
index c897ac6..e728821 100644
--- a/ginac/numeric.h
+++ b/ginac/numeric.h
@@ -272,6 +272,7 @@ protected:
 // global constants
 
 extern numeric I;
+extern PyObject *RR, *CC;
 
 // global functions
 
diff --git a/ginac/operators.cpp b/ginac/operators.cpp
index 916332a..bd12518 100644
--- a/ginac/operators.cpp
+++ b/ginac/operators.cpp
@@ -288,9 +288,8 @@ static int my_ios_index()
 // Stream format gets copied or destroyed
 static void my_ios_callback(std::ios_base::event ev, std::ios_base & s, int i)
 {
-	print_context *p = static_cast<print_context *>(s.pword(i));
+	std::unique_ptr<print_context> p(static_cast<print_context *>(s.pword(i)));
 	if (ev == std::ios_base::erase_event) {
-		delete p;
 		s.pword(i) = nullptr;
 	} else if (ev == std::ios_base::copyfmt_event && p != nullptr)
 		s.pword(i) = p->duplicate();
diff --git a/ginac/order.cpp b/ginac/order.cpp
index 399b767..ece313e 100644
--- a/ginac/order.cpp
+++ b/ginac/order.cpp
@@ -222,7 +222,7 @@ int print_order::compare(const basic &lh, const basic &rh) const
 	else if (typeid_rh == function_id())
 		//print functions before fderivatives, after anything else
 		return 1;
-	else if (typeid_lh == mul_id())
+	else if (typeid_lh == mul_id()) {
 		if (typeid_rh == power_id())
 			return compare_mul_power(
 					static_cast<const mul&>(lh),
@@ -236,7 +236,8 @@ int print_order::compare(const basic &lh, const basic &rh) const
 					static_cast<const add&>(rh),
 					static_cast<const mul&>(lh));
 		else return generic_compare(typeid_lh, typeid_rh);
-	else if (typeid_lh == add_id())
+                }
+        else if (typeid_lh == add_id()) {
 		if (typeid_rh == power_id())
 			return compare_add_power(
 					static_cast<const add&>(lh),
@@ -250,7 +251,8 @@ int print_order::compare(const basic &lh, const basic &rh) const
 					static_cast<const add&>(lh),
 					static_cast<const mul&>(rh));
 		else return generic_compare(typeid_lh, typeid_rh);
-	else if (typeid_lh == power_id())
+                }
+	else if (typeid_lh == power_id()) {
 		if (typeid_rh == mul_id())
 			return -compare_mul_power(
 					static_cast<const mul&>(rh),
@@ -264,7 +266,8 @@ int print_order::compare(const basic &lh, const basic &rh) const
 					static_cast<const power&>(lh),
 					static_cast<const symbol&>(rh));
 		else return generic_compare(typeid_lh, typeid_rh);
-	else if (typeid_lh == symbol_id())
+                }
+	else if (typeid_lh == symbol_id()) {
 		if (typeid_rh == mul_id())
 			return -compare_mul_symbol(
 					static_cast<const mul&>(rh),
@@ -278,6 +281,7 @@ int print_order::compare(const basic &lh, const basic &rh) const
 					static_cast<const power&>(rh),
 					static_cast<const symbol&>(lh));
 		else return generic_compare(typeid_lh, typeid_rh);
+                }
         return generic_compare(typeid_lh, typeid_rh);
 }
 
diff --git a/ginac/order.h b/ginac/order.h
index 400bcb9..c2120be 100644
--- a/ginac/order.h
+++ b/ginac/order.h
@@ -48,6 +48,7 @@ private:
 	const tinfo_t& wildcard_id() const;
 
 public:
+	virtual ~print_order() {}
 	bool operator() (const ex &lh, const ex &rh) const;
 	int compare(const ex &lh, const ex &rh) const;
 
@@ -81,7 +82,7 @@ protected:
 	// fderivative objects
 	int compare_same_type_fderivative(const fderivative &lh, const fderivative &rh) const;
 
-	int generic_compare(const tinfo_t typeid_lh, const tinfo_t typeid_rh) const
+	int generic_compare(const tinfo_t, const tinfo_t) const
 		{ return 1; }
 };
 
diff --git a/ginac/power.cpp b/ginac/power.cpp
index d13d43a..99e9e9b 100644
--- a/ginac/power.cpp
+++ b/ginac/power.cpp
@@ -465,16 +465,16 @@ ex power::eval(int level) const
 	
 	bool basis_is_numerical = false;
 	bool exponent_is_numerical = false;
-	const numeric *num_basis;
-	const numeric *num_exponent;
+	numeric num_basis;
+	numeric num_exponent;
 	
 	if (is_exactly_a<numeric>(ebasis)) {
 		basis_is_numerical = true;
-		num_basis = &ex_to<numeric>(ebasis);
+		num_basis = ex_to<numeric>(ebasis);
 	}
 	if (is_exactly_a<numeric>(eexponent)) {
 		exponent_is_numerical = true;
-		num_exponent = &ex_to<numeric>(eexponent);
+		num_exponent = ex_to<numeric>(eexponent);
 	}
 
 	// ^(\infty, x)
@@ -486,11 +486,12 @@ ex power::eval(int level) const
 			throw(std::domain_error("power::eval(): pow(Infinity, 0) is undefined."));
 		if (eexponent.info(info_flags::negative))
 			return _ex0;
-		if (eexponent.info(info_flags::positive))
+		if (eexponent.info(info_flags::positive)) {
 			if (basis_inf.is_unsigned_infinity())
 				return UnsignedInfinity;
 			else
 				return mul(pow(basis_inf.get_direction(), eexponent), Infinity);
+                }
 		throw(std::domain_error("power::eval(): pow(Infinity, c)"
 					" for constant of undetermined sign is not defined."));
 	}
@@ -504,11 +505,12 @@ ex power::eval(int level) const
 			throw(std::domain_error("power::eval(): pow(f(x), infinity) is not defined."));
 		// x^(c*oo) --> (x^c)^(+oo)
 		const ex abs_base = abs(pow(ebasis, exp_inf.get_direction()));
-		if (abs_base > _ex1) 
+		if (abs_base > _ex1) {
 			if (ebasis.info(info_flags::positive))
 				return Infinity;
 			else
 				return UnsignedInfinity;
+                        }
 		if (abs_base < _ex1) return _ex0;
 		if (abs_base == _ex1)
 			throw(std::domain_error("power::eval(): pow(1, Infinity) is not defined."));
@@ -519,7 +521,7 @@ ex power::eval(int level) const
 	// ^(x,0) -> 1  (0^0 also handled here)
 	if (eexponent.is_zero() && 
 		!(basis_is_numerical && 
-			num_basis->is_parent_pos_char())) {
+			num_basis.is_parent_pos_char())) {
 		return _ex1;
 	}
 	
@@ -529,9 +531,9 @@ ex power::eval(int level) const
 
 	// ^(0,c1) -> 0 or exception  (depending on real value of c1)
 	if (ebasis.is_zero() && exponent_is_numerical) {
-		if ((num_exponent->real()).is_zero())
+		if ((num_exponent.real()).is_zero())
 			throw (std::domain_error("power::eval(): pow(0,I) is undefined"));
-		else if ((num_exponent->real()).is_negative())
+		else if ((num_exponent.real()).is_negative())
 			throw (pole_error("power::eval(): division by zero",1));
 		else
 			return _ex0;
@@ -553,18 +555,18 @@ ex power::eval(int level) const
 		// ^(c1,c2) -> c1^c2  (c1, c2 numeric(),
 		// except if c1,c2 are rational, but c1^c2 is not)
 		if (basis_is_numerical) {
-			const bool basis_is_crational = num_basis->is_crational();
-                        const bool exponent_is_rational = num_exponent->is_rational();
-			const bool exponent_is_crational = exponent_is_rational || num_exponent->is_crational();
+			const bool basis_is_crational = num_basis.is_crational();
+                        const bool exponent_is_rational = num_exponent.is_rational();
+			const bool exponent_is_crational = exponent_is_rational || num_exponent.is_crational();
 			if (!basis_is_crational || !exponent_is_crational) {
 				// return a plain float
-				return (new numeric(num_basis->power(*num_exponent)))->setflag(status_flags::dynallocated |
+				return (new numeric(num_basis.power(num_exponent)))->setflag(status_flags::dynallocated |
 				                                                               status_flags::evaluated |
 				                                                               status_flags::expanded);
 			}
 
 			if (exponent_is_rational) {
-				const numeric res = num_basis->power(*num_exponent);
+				const numeric res = num_basis.power(num_exponent);
 				if (res.is_crational()) {
 					return res;
 				}
@@ -573,8 +575,8 @@ ex power::eval(int level) const
 
 			// ^(c1,n/m) -> *(c1^q,c1^(n/m-q)), 0<(n/m-q)<1, q integer
 			if (basis_is_crational && exponent_is_rational) {
-				const numeric n = num_exponent->numer();
-				const numeric m = num_exponent->denom();
+				const numeric n = num_exponent.numer();
+				const numeric m = num_exponent.denom();
 				numeric r;
 				numeric q = iquo(n, m, r);
 				if (r.is_negative()) {
@@ -582,12 +584,12 @@ ex power::eval(int level) const
 					--q;
 				}
 				if (q.is_zero()) {  // the exponent was in the allowed range 0<(n/m)<1
-					if (num_basis->is_rational()) {
+					if (num_basis.is_rational()) {
 						// call rational_power_parts
 						// for a^b return c,d such that a^b = c*d^b
-						PyObject* basis = num_basis->to_pyobject();
-						PyObject* exponent = num_exponent->to_pyobject();
-						PyObject* restuple = py_funcs.py_rational_power_parts(basis, exponent);
+						PyObject* basis_py = num_basis.to_pyobject();
+						PyObject* exponent_py = num_exponent.to_pyobject();
+						PyObject* restuple = py_funcs.py_rational_power_parts(basis_py, exponent_py);
 						if(!restuple) {
 							throw(std::runtime_error("power::eval, error in rational_power_parts"));
 						}
@@ -598,8 +600,8 @@ ex power::eval(int level) const
 						if (not ppower_equals_one)
 							result = (new mul(result, ppower))->setflag(status_flags::dynallocated | status_flags::evaluated);
 						Py_DECREF(restuple);
-						Py_DECREF(basis);
-						Py_DECREF(exponent);
+						Py_DECREF(basis_py);
+						Py_DECREF(exponent_py);
 						return result;
 					}
 					return this->hold();
@@ -607,14 +609,14 @@ ex power::eval(int level) const
 					// if r == 0, the following else clause causes the power
 					// constructor to be called again with the same parameter
 					// leading to an infinite loop
-					return num_basis->power(q);
+					return num_basis.power(q);
 				} else {
 					// assemble resulting product, but allowing for a re-evaluation,
 					// because otherwise we'll end up with something like
 					//    (7/8)^(4/3)  ->  7/8*(1/2*7^(1/3))
 					// instead of 7/16*7^(1/3).
-					ex prod = power(*num_basis,r.div(m));
-					return prod*power(*num_basis,q);
+					ex prod = power(num_basis, r.div(m));
+					return prod * power(num_basis, q);
 				}
 			}
 		}
@@ -629,18 +631,18 @@ ex power::eval(int level) const
 			if (is_exactly_a<numeric>(sub_exponent)) {
 				const numeric & num_sub_exponent = ex_to<numeric>(sub_exponent);
 				GINAC_ASSERT(num_sub_exponent!=numeric(1));
-				if (num_exponent->is_integer() || (abs(num_sub_exponent) - (*_num1_p)).is_negative() 
-						|| (num_sub_exponent == *_num_1_p && num_exponent->is_positive())) {
-					return power(sub_basis,num_sub_exponent.mul(*num_exponent));
+				if (num_exponent.is_integer() || (abs(num_sub_exponent) - (*_num1_p)).is_negative() 
+						|| (num_sub_exponent == *_num_1_p && num_exponent.is_positive())) {
+					return power(sub_basis,num_sub_exponent.mul(num_exponent));
 				}
 			}
 		}
 	
-		if (num_exponent->is_integer()) {
+		if (num_exponent.is_integer()) {
                         
                         // ^(*(x,y,z),c1) -> *(x^c1,y^c1,z^c1) (c1 integer)
                         if (is_exactly_a<mul>(ebasis)) {
-                                return expand_mul(ex_to<mul>(ebasis), *num_exponent, 0);
+                                return expand_mul(ex_to<mul>(ebasis), num_exponent, 0);
                         }
 
                         // (2*x + 6*y)^(-4) -> 1/16*(x + 3*y)^(-4)
@@ -665,11 +667,11 @@ ex power::eval(int level) const
                                         for (auto & elem : addp->seq)
                                                 elem.coeff = ex_to<numeric>(elem.coeff).div_dyn(icont);
 
-                                        const numeric c = icont.power(*num_exponent);
+                                        const numeric c = icont.power(num_exponent);
                                         if (likely(c != *_num1_p))
-                                                return (new mul(power(*addp, *num_exponent), c))->setflag(status_flags::dynallocated);
+                                                return (new mul(power(*addp, num_exponent), c))->setflag(status_flags::dynallocated);
                                         else
-                                                return power(*addp, *num_exponent);
+                                                return power(*addp, num_exponent);
                                 }
                         }
                 }
@@ -677,7 +679,7 @@ ex power::eval(int level) const
 		// ^(*(...,x;c1),c2) -> *(^(*(...,x;1),c2),c1^c2)  (c1, c2 numeric(), c1>0)
 		// ^(*(...,x;c1),c2) -> *(^(*(...,x;-1),c2),(-c1)^c2)  (c1, c2 numeric(), c1<0)
 		if (is_exactly_a<mul>(ebasis)) {
-			GINAC_ASSERT(!num_exponent->is_integer()); // should have been handled above
+			GINAC_ASSERT(!num_exponent.is_integer()); // should have been handled above
 			const mul & mulref = ex_to<mul>(ebasis);
 			if (!mulref.overall_coeff.is_equal(_ex1)) {
 				const numeric & num_coeff = ex_to<numeric>(mulref.overall_coeff);
@@ -690,7 +692,7 @@ ex power::eval(int level) const
 						mulp->clearflag(status_flags::hash_calculated);
 						mulp->seq_sorted.resize(0);
 						return (new mul(power(*mulp,exponent),
-						                power(num_coeff,*num_exponent)))->setflag(status_flags::dynallocated);
+						                power(num_coeff, num_exponent)))->setflag(status_flags::dynallocated);
 					} else {
 						GINAC_ASSERT(num_coeff.compare(*_num0_p)<0);
 						if (!num_coeff.is_equal(*_num_1_p)) {
@@ -700,8 +702,8 @@ ex power::eval(int level) const
 							mulp->clearflag(status_flags::evaluated);
 							mulp->clearflag(status_flags::hash_calculated);
 							mulp->seq_sorted.resize(0);
-							return (new mul(power(*mulp,exponent),
-							                power(abs(num_coeff),*num_exponent)))->setflag(status_flags::dynallocated);
+							return (new mul(power(*mulp, exponent),
+							                power(abs(num_coeff), num_exponent)))->setflag(status_flags::dynallocated);
 						}
 					}
 				}
@@ -710,9 +712,9 @@ ex power::eval(int level) const
 
 		// ^(nc,c1) -> ncmul(nc,nc,...) (c1 positive integer, unless nc is a matrix)
 		if (ebasis.return_type() != return_types::commutative &&
-                    num_exponent->is_pos_integer() &&
+                    num_exponent.is_pos_integer() &&
                     !is_a<matrix>(ebasis)) {
-			return ncmul(exvector(num_exponent->to_int(), ebasis), true);
+			return ncmul(exvector(num_exponent.to_int(), ebasis), true);
 		}
 	}
 	
@@ -796,11 +798,14 @@ ex power::subs(const exmap & m, unsigned options) const
 	if (!(options & subs_options::algebraic))
 		return subs_one_level(m, options);
 
-	for (auto it = m.begin(); it != m.end(); ++it) {
+        for (const auto & elem : m) {
 		int nummatches = std::numeric_limits<int>::max();
 		lst repls;
-		if (tryfactsubs(*this, it->first, nummatches, repls))
-			return (ex_to<basic>((*this) * power(it->second.subs(ex(repls), subs_options::no_pattern) / it->first.subs(ex(repls), subs_options::no_pattern), nummatches))).subs_one_level(m, options);
+		if (tryfactsubs(*this, elem.first, nummatches, repls))
+			return (ex_to<basic>((*this) * power(elem.second.subs(ex(repls),
+                                subs_options::no_pattern) / elem.first.subs(ex(repls),
+                                subs_options::no_pattern),
+                                nummatches))).subs_one_level(m, options);
 	}
 
 	return subs_one_level(m, options);
@@ -952,37 +957,34 @@ ex power::expand(unsigned options) const
 		epvector powseq;
 		prodseq.reserve(m.seq.size() + 1);
 		powseq.reserve(m.seq.size() + 1);
-		auto last = m.seq.end();
-		auto cit = m.seq.begin();
 		bool possign = true;
 
 		// search for positive/negative factors
-		while (cit!=last) {
-			ex e=m.recombine_pair_to_ex(*cit);
+                for (const auto & elem : m.seq) {
+			const ex& e = m.recombine_pair_to_ex(elem);
 			if (e.info(info_flags::positive))
 				prodseq.push_back(pow(e, exponent).expand(options));
 			else if (e.info(info_flags::negative)) {
 				prodseq.push_back(pow(-e, exponent).expand(options));
 				possign = !possign;
 			} else
-				powseq.push_back(*cit);
-			++cit;
+				powseq.push_back(elem);
 		}
 
 		// take care on the numeric coefficient
-		ex coeff=(possign? _ex1 : _ex_1);
+		ex coef = (possign? _ex1 : _ex_1);
 		if (m.overall_coeff.info(info_flags::positive) && m.overall_coeff != _ex1)
 			prodseq.push_back(power(m.overall_coeff, exponent));
 		else if (m.overall_coeff.info(info_flags::negative) && m.overall_coeff != _ex_1)
 			prodseq.push_back(power(-m.overall_coeff, exponent));
 		else
-			coeff *= m.overall_coeff;
+			coef *= m.overall_coeff;
 
 		// If positive/negative factors are found, then extract them.
 		// In either case we set a flag to avoid the second run on a part
 		// which does not have positive/negative terms.
 		if (prodseq.size() > 0) {
-			ex newbasis = coeff*mul(powseq);
+			ex newbasis = coef*mul(powseq);
 			ex_to<basic>(newbasis).setflag(status_flags::purely_indefinite);
 			return ((new mul(prodseq))->setflag(status_flags::dynallocated)*(new power(newbasis, exponent))->setflag(status_flags::dynallocated).expand(options)).expand(options);
 		} else
@@ -997,12 +999,8 @@ ex power::expand(unsigned options) const
 		const add &a = ex_to<add>(expanded_exponent);
 		exvector distrseq;
 		distrseq.reserve(a.seq.size() + 1);
-		auto last = a.seq.end();
-		auto cit = a.seq.begin();
-		while (cit!=last) {
-			distrseq.push_back(power(expanded_basis, a.recombine_pair_to_ex(*cit)));
-			++cit;
-		}
+                for (const auto & elem : a.seq)
+			distrseq.push_back(power(expanded_basis, a.recombine_pair_to_ex(elem)));
 		
 		// Make sure that e.g. (x+y)^(2+a) expands the (x+y)^2 factor
 		if (ex_to<numeric>(a.overall_coeff).is_integer()) {
@@ -1076,7 +1074,6 @@ ex power::expand_add(const add & a, int n, unsigned options) const
 	intvector k(m-1);
 	intvector k_cum(m-1); // k_cum[l]:=sum(i=0,l,k[l]);
 	intvector upper_limit(m-1);
-	int l;
 
 	for (size_t l=0; l<m-1; ++l) {
 		k[l] = 0;
@@ -1087,7 +1084,7 @@ ex power::expand_add(const add & a, int n, unsigned options) const
 	while (true) {
 		exvector term;
 		term.reserve(m+1);
-		for (l=0; l<m-1; ++l) {
+		for (size_t l=0; l<m-1; ++l) {
 			const ex & b = a.op(l);
 			GINAC_ASSERT(!is_exactly_a<add>(b));
 			GINAC_ASSERT(!is_exactly_a<power>(b) ||
@@ -1102,7 +1099,7 @@ ex power::expand_add(const add & a, int n, unsigned options) const
 				term.push_back(power(b,k[l]));
 		}
 
-		const ex & b = a.op(l);
+		const ex & b = a.op(m-1);
 		GINAC_ASSERT(!is_exactly_a<add>(b));
 		GINAC_ASSERT(!is_exactly_a<power>(b) ||
 		             !is_exactly_a<numeric>(ex_to<power>(b).exponent) ||
@@ -1117,7 +1114,7 @@ ex power::expand_add(const add & a, int n, unsigned options) const
 
 
 		numeric f = py_funcs.py_binomial_int(n,k[0]);
-		for (l=1; l<m-1; ++l)
+		for (size_t l=1; l<m-1; ++l)
 		  f *= py_funcs.py_binomial_int(n-k_cum[l-1], k[l]);
 
 		term.push_back(f);
@@ -1125,7 +1122,7 @@ ex power::expand_add(const add & a, int n, unsigned options) const
 		result.push_back(ex((new mul(term))->setflag(status_flags::dynallocated)).expand(options));
 
 		// increment k[]
-		l = m-2;
+		int l = m-2;
 		while ((l>=0) && ((++k[l])>upper_limit[l])) {
 			k[l] = 0;
 			--l;
@@ -1172,11 +1169,11 @@ ex power::expand_add_2(const add & a, unsigned options) const
 		
 		if (c.is_equal(_ex1)) {
 			if (is_exactly_a<mul>(r)) {
-				sum.push_back(expair(expand_mul(ex_to<mul>(r), *_num2_p, options, true),
-				                     _ex1));
+				sum.push_back(a.combine_ex_with_coeff_to_pair(expand_mul(ex_to<mul>(r), *_num2_p, options, true),
+				                                              _ex1));
 			} else {
-				sum.push_back(expair((new power(r,_ex2))->setflag(status_flags::dynallocated),
-				                     _ex1));
+				sum.push_back(a.combine_ex_with_coeff_to_pair((new power(r,_ex2))->setflag(status_flags::dynallocated),
+				                                              _ex1));
 			}
 		} else {
 			if (is_exactly_a<mul>(r)) {
@@ -1200,11 +1197,8 @@ ex power::expand_add_2(const add & a, unsigned options) const
 	
 	// second part: add terms coming from overall_factor (if != 0)
 	if (!a.overall_coeff.is_zero()) {
-		auto i = a.seq.begin(), end = a.seq.end();
-		while (i != end) {
-			sum.push_back(a.combine_pair_with_coeff_to_pair(*i, ex_to<numeric>(a.overall_coeff).mul_dyn(*_num2_p)));
-			++i;
-		}
+                for (const auto & elem : a.seq)
+			sum.push_back(a.combine_pair_with_coeff_to_pair(elem, ex_to<numeric>(a.overall_coeff).mul_dyn(*_num2_p)));
 		sum.push_back(expair(ex_to<numeric>(a.overall_coeff).power_dyn(*_num2_p),_ex1));
 	}
 	
@@ -1243,17 +1237,14 @@ ex power::expand_mul(const mul & m, const numeric & n, unsigned options, bool fr
 	distrseq.reserve(m.seq.size());
 	bool need_reexpand = false;
 
-	auto last = m.seq.end();
-	auto cit = m.seq.begin();
-	while (cit!=last) {
-		expair p = m.combine_pair_with_coeff_to_pair(*cit, n);
-		if (from_expand && is_exactly_a<add>(cit->rest) && ex_to<numeric>(p.coeff).is_pos_integer()) {
+        for (const auto & elem : m.seq) {
+		expair p = m.combine_pair_with_coeff_to_pair(elem, n);
+		if (from_expand && is_exactly_a<add>(elem.rest) && ex_to<numeric>(p.coeff).is_pos_integer()) {
 			// this happens when e.g. (a+b)^(1/2) gets squared and
 			// the resulting product needs to be reexpanded
 			need_reexpand = true;
 		}
 		distrseq.push_back(p);
-		++cit;
 	}
 
 	const mul & result = static_cast<const mul &>((new mul(distrseq, ex_to<numeric>(m.overall_coeff).power_dyn(n)))->setflag(status_flags::dynallocated));
diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp
index fec80c1..1609612 100644
--- a/ginac/pseries.cpp
+++ b/ginac/pseries.cpp
@@ -90,10 +90,10 @@ pseries::pseries(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 
 	for (auto loc = first; loc < last;) {
 		ex rest;
-		ex coeff;
+		ex coef;
 		n.find_ex_by_loc(loc++, rest, sym_lst);
-		n.find_ex_by_loc(loc++, coeff, sym_lst);
-		seq.push_back(expair(rest, coeff));
+		n.find_ex_by_loc(loc++, coef, sym_lst);
+		seq.push_back(expair(rest, coef));
 	}
 
 	n.find_ex("var", var, sym_lst);
@@ -103,11 +103,9 @@ pseries::pseries(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 void pseries::archive(archive_node &n) const
 {
 	inherited::archive(n);
-	auto i = seq.begin(), iend = seq.end();
-	while (i != iend) {
-		n.add_ex("coeff", i->rest);
-		n.add_ex("power", i->coeff);
-		++i;
+        for (const auto & elem : seq) {
+		n.add_ex("coeff", elem.rest);
+		n.add_ex("power", elem.coeff);
 	}
 	n.add_ex("var", var);
 	n.add_ex("point", point);
@@ -290,15 +288,14 @@ int pseries::degree(const ex &s) const
 		else
 			return 0;
 	} else {
-		auto it = seq.begin(), itend = seq.end();
-		if (it == itend)
+                
+		if (seq.size() == 0)
 			return 0;
 		int max_pow = std::numeric_limits<int>::min();
-		while (it != itend) {
-			int pow = it->rest.degree(s);
+                for (const auto & elem : seq) {
+			int pow = elem.rest.degree(s);
 			if (pow > max_pow)
 				max_pow = pow;
-			++it;
 		}
 		return max_pow;
 	}
@@ -318,15 +315,13 @@ int pseries::ldegree(const ex &s) const
 		else
 			return 0;
 	} else {
-		auto it = seq.begin(), itend = seq.end();
-		if (it == itend)
+		if (seq.size() == 0)
 			return 0;
 		int min_pow = std::numeric_limits<int>::max();
-		while (it != itend) {
-			int pow = it->rest.ldegree(s);
+                for (const auto & elem : seq) {
+			int pow = elem.rest.ldegree(s);
 			if (pow < min_pow)
 				min_pow = pow;
-			++it;
 		}
 		return min_pow;
 	}
@@ -388,11 +383,8 @@ ex pseries::eval(int level) const
 	// Construct a new series with evaluated coefficients
 	epvector new_seq;
 	new_seq.reserve(seq.size());
-	auto it = seq.begin(), itend = seq.end();
-	while (it != itend) {
-		new_seq.push_back(expair(it->rest.eval(level-1), it->coeff));
-		++it;
-	}
+        for (const auto & elem : seq)
+		new_seq.push_back(expair(elem.rest.eval(level-1), elem.coeff));
 	return (new pseries(relational(var,point), new_seq))->setflag(status_flags::dynallocated | status_flags::evaluated);
 }
 
@@ -408,12 +400,9 @@ ex pseries::evalf(int level, PyObject* parent) const
 	// Construct a new series with evaluated coefficients
 	epvector new_seq;
 	new_seq.reserve(seq.size());
-	auto it = seq.begin(), itend = seq.end();
-	while (it != itend) {
-		new_seq.push_back(expair(it->rest.evalf(level-1, parent),
-					it->coeff));
-		++it;
-	}
+        for (const auto & elem : seq)
+		new_seq.push_back(expair(elem.rest.evalf(level-1, parent),
+					elem.coeff));
 	return (new pseries(relational(var,point), new_seq))->setflag(status_flags::dynallocated | status_flags::evaluated);
 }
 
@@ -422,7 +411,7 @@ ex pseries::conjugate() const
 	if(!var.info(info_flags::real))
 		return conjugate_function(*this).hold();
 
-	epvector * newseq = conjugateepvector(seq);
+	std::unique_ptr<epvector> newseq(conjugateepvector(seq));
 	ex newpoint = point.conjugate();
 
 	if (!newseq && are_ex_trivially_equal(point, newpoint)) {
@@ -430,7 +419,6 @@ ex pseries::conjugate() const
 	}
 
 	ex result = (new pseries(var==newpoint, newseq ? *newseq : seq))->setflag(status_flags::dynallocated);
-	delete newseq;
 	return result;
 }
 
@@ -529,11 +517,8 @@ ex pseries::subs(const exmap & m, unsigned options) const
 	// expansion point
 	epvector newseq;
 	newseq.reserve(seq.size());
-	auto it = seq.begin(), itend = seq.end();
-	while (it != itend) {
-		newseq.push_back(expair(it->rest.subs(m, options), it->coeff));
-		++it;
-	}
+        for (const auto & elem : seq)
+		newseq.push_back(expair(elem.rest.subs(m, options), elem.coeff));
 	return (new pseries(relational(var,point.subs(m, options)), newseq))->setflag(status_flags::dynallocated);
 }
 
@@ -542,12 +527,10 @@ ex pseries::subs(const exmap & m, unsigned options) const
 ex pseries::expand(unsigned options) const
 {
 	epvector newseq;
-	auto i = seq.begin(), end = seq.end();
-	while (i != end) {
-		ex restexp = i->rest.expand();
+        for (const auto & elem : seq) {
+		ex restexp = elem.rest.expand();
 		if (!restexp.is_zero())
-			newseq.push_back(expair(restexp, i->coeff));
-		++i;
+			newseq.push_back(expair(restexp, elem.coeff));
 	}
 	return (new pseries(relational(var,point), newseq))
 	        ->setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0));
@@ -558,33 +541,30 @@ ex pseries::expand(unsigned options) const
 ex pseries::derivative(const symbol & s) const
 {
 	epvector new_seq;
-	auto it = seq.begin(), itend = seq.end();
 
 	if (s == var) {
 		
 		// FIXME: coeff might depend on var
-		while (it != itend) {
-			if (is_order_function(it->rest)) {
-				new_seq.push_back(expair(it->rest, it->coeff - 1));
+                for (const auto & elem : seq) {
+			if (is_order_function(elem.rest)) {
+				new_seq.push_back(expair(elem.rest, elem.coeff - 1));
 			} else {
-				ex c = it->rest * it->coeff;
+				const ex& c = elem.rest * elem.coeff;
 				if (!c.is_zero())
-					new_seq.push_back(expair(c, it->coeff - 1));
+					new_seq.push_back(expair(c, elem.coeff - 1));
 			}
-			++it;
 		}
 
 	} else {
 
-		while (it != itend) {
-			if (is_order_function(it->rest)) {
-				new_seq.push_back(*it);
+                for (const auto & elem : seq) {
+			if (is_order_function(elem.rest)) {
+				new_seq.push_back(elem);
 			} else {
-				ex c = it->rest.diff(s);
+				const ex& c = elem.rest.diff(s);
 				if (!c.is_zero())
-					new_seq.push_back(expair(c, it->coeff));
+					new_seq.push_back(expair(c, elem.coeff));
 			}
-			++it;
 		}
 	}
 
@@ -594,15 +574,13 @@ ex pseries::derivative(const symbol & s) const
 ex pseries::convert_to_poly(bool no_order) const
 {
 	ex e;
-	auto it = seq.begin(), itend = seq.end();
-	
-	while (it != itend) {
-		if (is_order_function(it->rest)) {
+        for (const auto & elem : seq) {
+		if (is_order_function(elem.rest)) {
 			if (!no_order)
-				e += Order(power(var - point, it->coeff));
-		} else
-			e += it->rest * power(var - point, it->coeff);
-		++it;
+				e += Order(power(var - point, elem.coeff));
+		}
+                else
+			e += elem.rest * power(var - point, elem.coeff);
 	}
 	return e;
 }
@@ -647,10 +625,9 @@ ex basic::series(const relational & r, int order, unsigned options) const
 	// do Taylor expansion
 	numeric fac = 1;
 	ex deriv = *this;
-	ex coeff = deriv.subs(r, subs_options::no_pattern);
-
-	if (!coeff.is_zero()) {
-		seq.push_back(expair(coeff, _ex0));
+	const ex co = deriv.subs(r, subs_options::no_pattern);
+	if (!co.is_zero()) {
+		seq.push_back(expair(co, _ex0));
 	}
 
 	int n;
@@ -663,9 +640,9 @@ ex basic::series(const relational & r, int order, unsigned options) const
 		if (deriv.is_zero())  // Series terminates
 			return pseries(r, seq);
 
-		coeff = deriv.subs(r, subs_options::no_pattern);
-		if (!coeff.is_zero())
-			seq.push_back(expair(fac.inverse() * coeff, n));
+		const ex coef = deriv.subs(r, subs_options::no_pattern);
+		if (!coef.is_zero())
+			seq.push_back(expair(fac.inverse() * coef, n));
 	}
 	
 	// Higher-order terms, if present
@@ -782,19 +759,17 @@ ex add::series(const relational & r, int order, unsigned options) const
 	acc = overall_coeff.series(r, order, options);
 	
 	// Add remaining terms
-	auto it = seq.begin();
-	auto itend = seq.end();
-	for (; it!=itend; ++it) {
-		ex op;
-		if (is_exactly_a<pseries>(it->rest))
-			op = it->rest;
+	for (const auto & elem : seq) {
+		ex term;
+		if (is_exactly_a<pseries>(elem.rest))
+			term = elem.rest;
 		else
-			op = it->rest.series(r, order, options);
-		if (!it->coeff.is_equal(_ex1))
-			op = ex_to<pseries>(op).mul_const(ex_to<numeric>(it->coeff));
+			term = elem.rest.series(r, order, options);
+		if (!elem.coeff.is_equal(_ex1))
+			term = ex_to<pseries>(term).mul_const(ex_to<numeric>(elem.coeff));
 		
 		// Series addition
-		acc = ex_to<pseries>(acc).add_series(ex_to<pseries>(op));
+		acc = ex_to<pseries>(acc).add_series(ex_to<pseries>(term));
 	}
 	return acc;
 }
@@ -810,13 +785,11 @@ ex pseries::mul_const(const numeric &other) const
 	epvector new_seq;
 	new_seq.reserve(seq.size());
 	
-	auto it = seq.begin(), itend = seq.end();
-	while (it != itend) {
-		if (!is_order_function(it->rest))
-			new_seq.push_back(expair(it->rest * other, it->coeff));
+        for (const auto & elem : seq) {
+		if (!is_order_function(elem.rest))
+			new_seq.push_back(expair(elem.rest * other, elem.coeff));
 		else
-			new_seq.push_back(*it);
-		++it;
+			new_seq.push_back(elem);
 	}
 	return pseries(relational(var,point), new_seq);
 }
@@ -894,20 +867,18 @@ ex mul::series(const relational & r, int order, unsigned options) const
 	std::vector<bool> ldegree_redo;
 
 	// find minimal degrees
-	const epvector::const_iterator itbeg = seq.begin();
-	const epvector::const_iterator itend = seq.end();
 	// first round: obtain a bound up to which minimal degrees have to be
 	// considered
-	for (epvector::const_iterator it=itbeg; it!=itend; ++it) {
+        for (const auto & elem : seq) {
 
-		ex expon = it->coeff;
+		ex expon = elem.coeff;
 		int factor = 1;
 		ex buf;
 		if (expon.info(info_flags::integer)) {
-			buf = it->rest;
+			buf = elem.rest;
 			factor = ex_to<numeric>(expon).to_int();
 		} else {
-			buf = recombine_pair_to_ex(*it);
+			buf = recombine_pair_to_ex(elem);
 		}
 
 		int real_ldegree = 0;
@@ -944,16 +915,16 @@ ex mul::series(const relational & r, int order, unsigned options) const
 	// method.
 	// here we can ignore ldegrees larger than degbound
 	size_t j = 0;
-	for (epvector::const_iterator it=itbeg; it!=itend; ++it) {
+        for (const auto & elem : seq) {
 		if ( ldegree_redo[j] ) {
-			ex expon = it->coeff;
+			ex expon = elem.coeff;
 			int factor = 1;
 			ex buf;
 			if (expon.info(info_flags::integer)) {
-				buf = it->rest;
+				buf = elem.rest;
 				factor = ex_to<numeric>(expon).to_int();
 			} else {
-				buf = recombine_pair_to_ex(*it);
+				buf = recombine_pair_to_ex(elem);
 			}
 			int real_ldegree = 0;
 			int orderloop = 0;
@@ -977,17 +948,17 @@ ex mul::series(const relational & r, int order, unsigned options) const
 	}
 
 	// Multiply with remaining terms
-	std::vector<int>::const_iterator itd = ldegrees.begin();
-	for (epvector::const_iterator it=itbeg; it!=itend; ++it, ++itd) {
+	auto itd = ldegrees.begin();
+	for (auto it = seq.begin(); it != seq.end(); ++it, ++itd) {
 
 		// do series expansion with adjusted order
-		ex op = recombine_pair_to_ex(*it).series(r, order-degsum+(*itd), options);
+		ex term = recombine_pair_to_ex(*it).series(r, order-degsum+(*itd), options);
 
 		// Series multiplication
-		if (it == itbeg)
-			acc = ex_to<pseries>(op);
+		if (it == seq.begin())
+			acc = ex_to<pseries>(term);
 		else
-			acc = ex_to<pseries>(acc.mul_series(ex_to<pseries>(op)));
+			acc = ex_to<pseries>(acc.mul_series(ex_to<pseries>(term)));
 	}
 
 	return acc.mul_const(ex_to<numeric>(overall_coeff));
@@ -1089,11 +1060,8 @@ ex pseries::power_const(const numeric &p, int deg) const
 pseries pseries::shift_exponents(int deg) const
 {
 	epvector newseq = seq;
-	auto i = newseq.begin(), end  = newseq.end();
-	while (i != end) {
-		i->coeff += deg;
-		++i;
-	}
+        for (auto & elem : newseq)
+		elem.coeff += deg;
 	return pseries(relational(var, point), newseq);
 }
 
@@ -1209,15 +1177,13 @@ ex pseries::series(const relational & r, int order, unsigned options) const
 			return *this;
 		else {
 			epvector new_seq;
-			auto it = seq.begin(), itend = seq.end();
-			while (it != itend) {
-				int o = ex_to<numeric>(it->coeff).to_int();
+                        for (const auto & elem : seq) {
+				int o = ex_to<numeric>(elem.coeff).to_int();
 				if (o >= order) {
 					new_seq.push_back(expair(Order(_ex1), o));
 					break;
 				}
-				new_seq.push_back(*it);
-				++it;
+				new_seq.push_back(elem);
 			}
 			return pseries(r, new_seq);
 		}
diff --git a/ginac/registrar.h b/ginac/registrar.h
index d1f4a5c..54b3486 100644
--- a/ginac/registrar.h
+++ b/ginac/registrar.h
@@ -130,12 +130,12 @@ public: \
 	classname(); \
 	virtual classname * duplicate() const { return new classname(*this); } \
 	\
-	virtual void accept(GiNaC::visitor & v) const \
+	virtual void accept(GiNaC::visitor & vis) const \
 	{ \
-		if (visitor *p = dynamic_cast<visitor *>(&v)) \
+		if (visitor *p = dynamic_cast<visitor *>(&vis)) \
 			p->visit(*this); \
 		else \
-			inherited::accept(v); \
+			inherited::accept(vis); \
 	} \
 protected: \
 	virtual int compare_same_type(const GiNaC::basic & other) const; \
diff --git a/ginac/relational.cpp b/ginac/relational.cpp
index 549d050..109723f 100644
--- a/ginac/relational.cpp
+++ b/ginac/relational.cpp
@@ -51,7 +51,7 @@ relational::relational() : basic(&relational::tinfo_static) {}
 
 // public
 
-relational::relational(ex  lhs, ex  rhs, operators oper) : basic(&relational::tinfo_static), lh(std::move(lhs)), rh(std::move(rhs)), o(oper) {}
+relational::relational(ex a_lhs, ex a_rhs, operators oper) : basic(&relational::tinfo_static), lh(std::move(a_lhs)), rh(std::move(a_rhs)), o(oper) {}
 
 //////////
 // archiving
diff --git a/ginac/structure.h b/ginac/structure.h
deleted file mode 100644
index 99ee4cc..0000000
--- a/ginac/structure.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/** @file structure.h
- *
- *  Wrapper template for making GiNaC classes out of C++ structures. */
-
-/*
- *  GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __GINAC_STRUCTURE_H__
-#define __GINAC_STRUCTURE_H__
-
-#include <functional>
-
-#include "ex.h"
-#include "ncmul.h"
-#include "numeric.h"
-#include "operators.h"
-#include "print.h"
-
-namespace GiNaC {
-
-
-/** Comparison policy: all structures of one type are equal */
-template <class T>
-class compare_all_equal {
-protected:
-	static bool struct_is_equal(const T * t1, const T * t2) { return true; }
-	static int struct_compare(const T * t1, const T * t2) { return 0; }
-
-	// disallow destruction of structure through a compare_all_equal*
-protected:
-	~compare_all_equal() {}
-};
-
-
-/** Comparison policy: use std::equal_to/std::less (defaults to operators
- *  == and <) to compare structures. */
-template <class T>
-class compare_std_less {
-protected:
-	static bool struct_is_equal(const T * t1, const T * t2)
-	{
-		return std::equal_to<T>()(*t1, *t2);
-	}
-
-	static int struct_compare(const T * t1, const T * t2)
-	{
-		if (std::less<T>()(*t1, *t2))
-			return -1;
-		else if (std::less<T>()(*t2, *t1))
-			return 1;
-		else
-			return 0;
-	}
-
-	// disallow destruction of structure through a compare_std_less*
-protected:
-	~compare_std_less() {}
-};
-
-
-/** Comparison policy: use bit-wise comparison to compare structures. */
-template <class T>
-class compare_bitwise {
-protected:
-	static bool struct_is_equal(const T * t1, const T * t2)
-	{
-		const char * cp1 = reinterpret_cast<const char *>(t1);
-		const char * cp2 = reinterpret_cast<const char *>(t2);
-
-		return std::equal(cp1, cp1 + sizeof(T), cp2);
-	}
-
-	static int struct_compare(const T * t1, const T * t2)
-	{
-		const unsigned char * cp1 = reinterpret_cast<const unsigned char *>(t1);
-		const unsigned char * cp2 = reinterpret_cast<const unsigned char *>(t2);
-		typedef std::pair<const unsigned char *, const unsigned char *> cppair;
-
-		cppair res = std::mismatch(cp1, cp1 + sizeof(T), cp2);
-
-		if (res.first == cp1 + sizeof(T))
-			return 0;
-		else if (*res.first < *res.second)
-			return -1;
-		else
-			return 1;
-	}
-
-	// disallow destruction of structure through a compare_bitwise*
-protected:
-	~compare_bitwise() {}
-};
-
-
-// Select default comparison policy
-template <class T, template <class> class ComparisonPolicy = compare_all_equal> class structure;
-
-
-/** Wrapper template for making GiNaC classes out of C++ structures. */
-template <class T, template <class> class ComparisonPolicy>
-class structure : public basic, public ComparisonPolicy<T> {
-	GINAC_DECLARE_REGISTERED_CLASS(structure, basic)
-
-	// helpers
-	static tinfo_t get_tinfo() { return reg_info.options.get_id(); }
-	static const char *get_class_name() { return "structure"; }
-	static tinfo_t next_structure_tinfo_key() { return new tinfo_static_t; }
-
-	// constructors
-public:
-	/** Construct structure as a copy of a given C++ structure. */
-	structure(const T & t) : inherited(get_tinfo()), obj(t) { }
-
-	// functions overriding virtual functions from base classes
-	// All these are just defaults that can be specialized by the user
-public:
-	// evaluation
-	ex eval(int level = 0) const { return hold(); }
-	ex evalf(int level = 0, PyObject* parent=nullptr) const {
-		return inherited::evalf(level, parent); }
-	ex evalm() const { return inherited::evalm(); }
-protected:
-	ex eval_ncmul(const exvector & v) const { return hold_ncmul(v); }
-public:
-	ex eval_indexed(const basic & i) const { return i.hold(); }
-
-	// printing
-	void print(const print_context & c, unsigned level = 0) const { inherited::print(c, level); }
-	unsigned precedence() const { return 70; }
-
-	// info
-	bool info(unsigned inf) const { return false; }
-
-	// operand access
-	size_t nops() const { return 0; }
-	ex op(size_t i) const { return inherited::op(i); }
-	ex operator[](const ex & index) const { return inherited::operator[](index); }
-	ex operator[](size_t i) const { return inherited::operator[](i); }
-	ex & let_op(size_t i) { return inherited::let_op(i); }
-	ex & operator[](const ex & index) { return inherited::operator[](index); }
-	ex & operator[](size_t i) { return inherited::operator[](i); }
-
-	// pattern matching
-	bool has(const ex & other, unsigned options = 0) const { return inherited::has(other, options); }
-	bool match(const ex & pattern, lst & repl_lst) const { return inherited::match(pattern, repl_lst); }
-protected:
-	bool match_same_type(const basic & other) const { return true; }
-public:
-
-	// substitutions
-	ex subs(const exmap & m, unsigned options = 0) const { return inherited::subs(m, options); }
-
-	// function mapping
-	ex map(map_function & f) const { return inherited::map(f); }
-
-	// degree/coeff
-	int degree(const ex & s) const { return inherited::degree(s); }
-	int ldegree(const ex & s) const { return inherited::ldegree(s); }
-	ex coeff(const ex & s, int n = 1) const { return inherited::coeff(s, n); }
-
-	// expand/collect
-	ex expand(unsigned options = 0) const { return inherited::expand(options); }
-	ex collect(const ex & s, bool distributed = false) const { return inherited::collect(s, distributed); }
-
-	// differentiation and series expansion
-protected:
-	ex derivative(const symbol & s) const { return inherited::derivative(s); }
-public:
-	ex series(const relational & r, int order, unsigned options = 0) const { return inherited::series(r, order, options); }
-
-	// rational functions
-	ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const { return inherited::normal(repl, rev_lookup, level); }
-	ex to_rational(exmap & repl) const { return inherited::to_rational(repl); }
-	ex to_polynomial(exmap & repl) const { return inherited::to_polynomial(repl); }
-
-	// polynomial algorithms
-	numeric integer_content() const { return 1; }
-	ex smod(const numeric & xi) const { return *this; }
-	numeric max_coefficient() const { return 1; }
-
-	// indexed objects
-	exvector get_free_indices() const { return exvector(); }
-	ex add_indexed(const ex & self, const ex & other) const { return self + other; }
-	ex scalar_mul_indexed(const ex & self, const numeric & other) const { return self * ex(other); }
-	bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const { return false; }
-
-	// noncommutativity
-	unsigned return_type() const { return return_types::commutative; }
-	tinfo_t return_type_tinfo() const { return this; }
-
-protected:
-	bool is_equal_same_type(const basic & other) const
-	{
-		GINAC_ASSERT(is_a<structure>(other));
-		const structure & o = static_cast<const structure &>(other);
-
-		return this->struct_is_equal(&obj, &o.obj);
-	}
-
-	unsigned calchash() const { return inherited::calchash(); }
-
-	// non-virtual functions in this class
-public:
-	// access to embedded structure
-	const T *operator->() const { return &obj; }
-	T &get_struct() { return obj; }
-	const T &get_struct() const { return obj; }
-private:
-	T obj;
-};
-
-
-/** Default constructor */
-template <class T, template <class> class CP>
-structure<T, CP>::structure() : inherited(get_tinfo()) { }
-
-/** Construct object from archive_node. */
-template <class T, template <class> class CP>
-structure<T, CP>::structure(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) {}
-
-/** Unarchive the object. */
-template <class T, template <class> class CP>
-ex structure<T, CP>::unarchive(const archive_node &n, lst &sym_lst)
-{
-	return (new structure(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
-template <class T, template <class> class CP>
-void structure<T, CP>::archive(archive_node &n) const
-{
-	inherited::archive(n);
-}
-
-/** Compare two structures of the same type. */
-template <class T, template <class> class CP>
-int structure<T, CP>::compare_same_type(const basic & other) const
-{
-	GINAC_ASSERT(is_a<structure>(other));
-	const structure & o = static_cast<const structure &>(other);
-
-	return this->struct_compare(&obj, &o.obj);
-}
-
-template <class T, template <class> class CP>
-registered_class_info structure<T, CP>::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", structure::next_structure_tinfo_key(), &structure::unarchive));
-
-
-} // namespace GiNaC
-
-#endif // ndef __GINAC_STRUCTURE_H__
diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp
index 1658aba..924eded 100644
--- a/ginac/symbol.cpp
+++ b/ginac/symbol.cpp
@@ -77,57 +77,57 @@ possymbol::possymbol()
 
 // symbol
 
-symbol::symbol(std::string  initname, unsigned domain)
- : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(default_TeX_name()), domain(domain), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static)
+symbol::symbol(std::string  initname, unsigned a_domain)
+ : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(default_TeX_name()), domain(a_domain), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static)
 {
 	setflag(status_flags::evaluated | status_flags::expanded);
 }
 
-symbol::symbol(std::string  initname, unsigned rt, tinfo_t rtt, unsigned domain)
- : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(default_TeX_name()), domain(domain), ret_type(rt), ret_type_tinfo(rtt)
+symbol::symbol(std::string  initname, unsigned rt, tinfo_t rtt, unsigned a_domain)
+ : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(default_TeX_name()), domain(a_domain), ret_type(rt), ret_type_tinfo(rtt)
 {
 	setflag(status_flags::evaluated | status_flags::expanded);
 }
 
-symbol::symbol(std::string  initname, std::string  texname, unsigned domain)
- : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(std::move(texname)), domain(domain), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static)
+symbol::symbol(std::string  initname, std::string  texname, unsigned a_domain)
+ : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(std::move(texname)), domain(a_domain), ret_type(return_types::commutative), ret_type_tinfo(&symbol::tinfo_static)
 {
 	setflag(status_flags::evaluated | status_flags::expanded);
 }
 
-symbol::symbol(std::string  initname, std::string  texname, unsigned rt, tinfo_t rtt, unsigned domain)
- : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(std::move(texname)), domain(domain), ret_type(rt), ret_type_tinfo(rtt)
+symbol::symbol(std::string  initname, std::string  texname, unsigned rt, tinfo_t rtt, unsigned a_domain)
+ : inherited(&symbol::tinfo_static), serial(next_serial++), name(std::move(initname)), TeX_name(std::move(texname)), domain(a_domain), ret_type(rt), ret_type_tinfo(rtt)
 {
 	setflag(status_flags::evaluated | status_flags::expanded);
 }
 
 // realsymbol
 	
-realsymbol::realsymbol(const std::string & initname, unsigned domain)
- : symbol(initname, domain) { }
+realsymbol::realsymbol(const std::string & initname, unsigned a_domain)
+ : symbol(initname, a_domain) { }
 
-realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned domain)
- : symbol(initname, texname, domain) { }
+realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned a_domain)
+ : symbol(initname, texname, a_domain) { }
 
-realsymbol::realsymbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain)
- : symbol(initname, rt, rtt, domain) { }
+realsymbol::realsymbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned a_domain)
+ : symbol(initname, rt, rtt, a_domain) { }
 
-realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain)
- : symbol(initname, texname, rt, rtt, domain) { }
+realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned a_domain)
+ : symbol(initname, texname, rt, rtt, a_domain) { }
 
 // possymbol
 	
-possymbol::possymbol(const std::string & initname, unsigned domain)
- : symbol(initname, domain) { }
+possymbol::possymbol(const std::string & initname, unsigned a_domain)
+ : symbol(initname, a_domain) { }
 
-possymbol::possymbol(const std::string & initname, const std::string & texname, unsigned domain)
- : symbol(initname, texname, domain) { }
+possymbol::possymbol(const std::string & initname, const std::string & texname, unsigned a_domain)
+ : symbol(initname, texname, a_domain) { }
 
-possymbol::possymbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain)
- : symbol(initname, rt, rtt, domain) { }
+possymbol::possymbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned a_domain)
+ : symbol(initname, rt, rtt, a_domain) { }
 
-possymbol::possymbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain)
- : symbol(initname, texname, rt, rtt, domain) { }
+possymbol::possymbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned a_domain)
+ : symbol(initname, texname, rt, rtt, a_domain) { }
 
 //////////
 // archiving
@@ -395,4 +395,16 @@ const symbol & get_symbol(const std::string & s)
 		return directory.insert(make_pair(s, symbol(s))).first->second;
 	}
 }
+
+bool has_symbol(const ex & x)
+{
+	if (is_exactly_a<symbol>(x))
+		return true;
+	for (size_t i=0; i<x.nops(); ++i)
+		if (has_symbol(x.op(i)))
+			return true;
+                
+	return false;
+}
+
 } // namespace GiNaC
diff --git a/ginac/symbol.h b/ginac/symbol.h
index 99dcee4..dc404a5 100644
--- a/ginac/symbol.h
+++ b/ginac/symbol.h
@@ -25,7 +25,6 @@
 
 #include "basic.h"
 #include "ex.h"
-#include "ptr.h"
 
 #include <string>
 
@@ -162,6 +161,8 @@ template<> inline bool is_exactly_a<possymbol>(const basic & obj)
 // keep symbols unique
 const symbol & get_symbol(const std::string & s);
 
+bool has_symbol(const ex & x);
+
 } // namespace GiNaC
 
 #endif // ndef __GINAC_SYMBOL_H__
diff --git a/ginac/symmetry.cpp b/ginac/symmetry.cpp
index 2160502..e4352ec 100644
--- a/ginac/symmetry.cpp
+++ b/ginac/symmetry.cpp
@@ -160,7 +160,6 @@ int symmetry::compare_same_type(const basic & other) const
 		return 1;
 	if (this_size < that_size)
 		return -1;
-	typedef std::set<unsigned>::const_iterator set_it;
 	auto end = indices.end();
 	for (auto i=indices.begin(),j=othersymm.indices.begin(); i!=end; ++i,++j) {
 		if(*i < *j)
diff --git a/ginac/tensor.cpp b/ginac/tensor.cpp
index 77241f1..c50c03e 100644
--- a/ginac/tensor.cpp
+++ b/ginac/tensor.cpp
@@ -370,11 +370,12 @@ ex tensepsilon::eval_indexed(const basic & i) const
 				const ex & x = i.op(j);
 				if (!is_a<varidx>(x))
 					throw(std::runtime_error("indices of epsilon tensor in Minkowski space must be of type varidx"));
-				if (ex_to<varidx>(x).is_covariant())
+				if (ex_to<varidx>(x).is_covariant()) {
 					if (ex_to<idx>(x).get_value().is_zero())
 						sign = (pos_sig ? -sign : sign);
 					else
 						sign = (pos_sig ? sign : -sign);
+                                        }
 			}
 		}
 
diff --git a/ginac/utils.cpp b/ginac/utils.cpp
index b55948b..8d12b76 100644
--- a/ginac/utils.cpp
+++ b/ginac/utils.cpp
@@ -35,8 +35,8 @@ const int version_micro = GINACLIB_MICRO_VERSION;
 
 
 /** ctor for pole_error exception class. */
-pole_error::pole_error(const std::string& what_arg, int degree)
-	: domain_error(what_arg), deg(degree) { }
+pole_error::pole_error(const std::string& what_arg, int a_degree)
+	: domain_error(what_arg), deg(a_degree) { }
 
 /** Return the degree of the pole_error exception class. */
 int pole_error::degree() const
diff --git a/m4/ax_cxx_compile_stdcxx_11.m4 b/m4/ax_cxx_compile_stdcxx_11.m4
new file mode 100644
index 0000000..a9a8f58
--- /dev/null
+++ b/m4/ax_cxx_compile_stdcxx_11.m4
@@ -0,0 +1,165 @@
+# ============================================================================
+#  http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+#   AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
+#
+# DESCRIPTION
+#
+#   Check for baseline language coverage in the compiler for the C++11
+#   standard; if necessary, add switches to CXXFLAGS to enable support.
+#
+#   The first argument, if specified, indicates whether you insist on an
+#   extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
+#   -std=c++11).  If neither is specified, you get whatever works, with
+#   preference for an extended mode.
+#
+#   The second argument, if specified 'mandatory' or if left unspecified,
+#   indicates that baseline C++11 support is required and that the macro
+#   should error out if no mode with that support is found.  If specified
+#   'optional', then configuration proceeds regardless, after defining
+#   HAVE_CXX11 if and only if a supporting mode is found.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Benjamin Kosnik <bkoz at redhat.com>
+#   Copyright (c) 2012 Zack Weinberg <zackw at panix.com>
+#   Copyright (c) 2013 Roy Stogner <roystgnr at ices.utexas.edu>
+#   Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov at google.com>
+#
+#   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. This file is offered as-is, without any
+#   warranty.
+
+#serial 10
+
+m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
+  template <typename T>
+    struct check
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+    struct Base {
+    virtual void f() {}
+    };
+    struct Child : public Base {
+    virtual void f() override {}
+    };
+
+    typedef check<check<bool>> right_angle_brackets;
+
+    int a;
+    decltype(a) b;
+
+    typedef check<int> check_type;
+    check_type c;
+    check_type&& cr = static_cast<check_type&&>(c);
+
+    auto d = a;
+    auto l = [](){};
+    // Prevent Clang error: unused variable 'l' [-Werror,-Wunused-variable]
+    struct use_l { use_l() { l(); } };
+
+    // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
+    // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function because of this
+    namespace test_template_alias_sfinae {
+        struct foo {};
+
+        template<typename T>
+        using member = typename T::member_type;
+
+        template<typename T>
+        void func(...) {}
+
+        template<typename T>
+        void func(member<T>*) {}
+
+        void test();
+
+        void test() {
+            func<foo>(0);
+        }
+    }
+]])
+
+AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
+  m4_if([$1], [], [],
+        [$1], [ext], [],
+        [$1], [noext], [],
+        [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
+  m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
+        [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
+        [$2], [optional], [ax_cxx_compile_cxx11_required=false],
+        [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
+  AC_LANG_PUSH([C++])dnl
+  ac_success=no
+  AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
+  ax_cv_cxx_compile_cxx11,
+  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+    [ax_cv_cxx_compile_cxx11=yes],
+    [ax_cv_cxx_compile_cxx11=no])])
+  if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+    ac_success=yes
+  fi
+
+  m4_if([$1], [noext], [], [dnl
+  if test x$ac_success = xno; then
+    for switch in -std=gnu++11 -std=gnu++0x; do
+      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+      AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+                     $cachevar,
+        [ac_save_CXXFLAGS="$CXXFLAGS"
+         CXXFLAGS="$CXXFLAGS $switch"
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+          [eval $cachevar=yes],
+          [eval $cachevar=no])
+         CXXFLAGS="$ac_save_CXXFLAGS"])
+      if eval test x\$$cachevar = xyes; then
+        CXXFLAGS="$CXXFLAGS $switch"
+        ac_success=yes
+        break
+      fi
+    done
+  fi])
+
+  m4_if([$1], [ext], [], [dnl
+  if test x$ac_success = xno; then
+    for switch in -std=c++11 -std=c++0x; do
+      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+      AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+                     $cachevar,
+        [ac_save_CXXFLAGS="$CXXFLAGS"
+         CXXFLAGS="$CXXFLAGS $switch"
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+          [eval $cachevar=yes],
+          [eval $cachevar=no])
+         CXXFLAGS="$ac_save_CXXFLAGS"])
+      if eval test x\$$cachevar = xyes; then
+        CXXFLAGS="$CXXFLAGS $switch"
+        ac_success=yes
+        break
+      fi
+    done
+  fi])
+  AC_LANG_POP([C++])
+  if test x$ax_cxx_compile_cxx11_required = xtrue; then
+    if test x$ac_success = xno; then
+      AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
+    fi
+  else
+    if test x$ac_success = xno; then
+      HAVE_CXX11=0
+      AC_MSG_NOTICE([No compiler with C++11 support was found])
+    else
+      HAVE_CXX11=1
+      AC_DEFINE(HAVE_CXX11,1,
+                [define if the compiler supports basic C++11 syntax])
+    fi
+
+    AC_SUBST(HAVE_CXX11)
+  fi
+])

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



More information about the debian-science-commits mailing list