Index: lemon/CMakeLists.txt
===================================================================
--- lemon/CMakeLists.txt	(revision 904)
+++ lemon/CMakeLists.txt	(revision 679)
@@ -7,10 +7,4 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
-)
-
-CONFIGURE_FILE(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lemon.pc.cmake
-  ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc
-  @ONLY
 )
 
@@ -73,8 +67,2 @@
   COMPONENT headers
 )
-
-INSTALL(
-  FILES ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc
-  DESTINATION lib/pkgconfig
-)
-
Index: lemon/arg_parser.h
===================================================================
--- lemon/arg_parser.h	(revision 880)
+++ lemon/arg_parser.h	(revision 877)
@@ -36,17 +36,10 @@
 
   ///Exception used by ArgParser
-
-  ///Exception used by ArgParser.
-  ///
   class ArgParserException : public Exception {
   public:
-    /// Reasons for failure
-
-    /// Reasons for failure.
-    ///
     enum Reason {
-      HELP,         ///< <tt>--help</tt> option was given.
-      UNKNOWN_OPT,  ///< Unknown option was given.
-      INVALID_OPT   ///< Invalid combination of options.
+      HELP,         /// <tt>--help</tt> option was given
+      UNKNOWN_OPT,  /// Unknown option was given
+      INVALID_OPT   /// Invalid combination of options
     };
 
Index: lemon/bellman_ford.h
===================================================================
--- lemon/bellman_ford.h	(revision 881)
+++ lemon/bellman_ford.h	(revision 877)
@@ -29,4 +29,5 @@
 #include <lemon/error.h>
 #include <lemon/maps.h>
+#include <lemon/tolerance.h>
 #include <lemon/path.h>
 
@@ -35,5 +36,5 @@
 namespace lemon {
 
-  /// \brief Default OperationTraits for the BellmanFord algorithm class.
+  /// \brief Default operation traits for the BellmanFord algorithm class.
   ///
   /// This operation traits class defines all computational operations
@@ -42,9 +43,11 @@
   /// If the numeric type does not have infinity value, then the maximum
   /// value is used as extremal infinity value.
+  ///
+  /// \see BellmanFordToleranceOperationTraits
   template <
     typename V,
     bool has_inf = std::numeric_limits<V>::has_infinity>
   struct BellmanFordDefaultOperationTraits {
-    /// \e
+    /// \brief Value type for the algorithm.
     typedef V Value;
     /// \brief Gives back the zero value of the type.
@@ -82,4 +85,49 @@
     static bool less(const Value& left, const Value& right) {
       return left < right;
+    }
+  };
+
+  /// \brief Operation traits for the BellmanFord algorithm class
+  /// using tolerance.
+  ///
+  /// This operation traits class defines all computational operations
+  /// and constants that are used in the Bellman-Ford algorithm.
+  /// The only difference between this implementation and
+  /// \ref BellmanFordDefaultOperationTraits is that this class uses
+  /// the \ref Tolerance "tolerance technique" in its \ref less()
+  /// function.
+  ///
+  /// \tparam V The value type.
+  /// \tparam eps The epsilon value for the \ref less() function.
+  /// By default, it is the epsilon value used by \ref Tolerance
+  /// "Tolerance<V>".
+  ///
+  /// \see BellmanFordDefaultOperationTraits
+#ifdef DOXYGEN
+  template <typename V, V eps>
+#else
+  template <
+    typename V,
+    V eps = Tolerance<V>::def_epsilon>
+#endif
+  struct BellmanFordToleranceOperationTraits {
+    /// \brief Value type for the algorithm.
+    typedef V Value;
+    /// \brief Gives back the zero value of the type.
+    static Value zero() {
+      return static_cast<Value>(0);
+    }
+    /// \brief Gives back the positive infinity value of the type.
+    static Value infinity() {
+      return std::numeric_limits<Value>::infinity();
+    }
+    /// \brief Gives back the sum of the given two elements.
+    static Value plus(const Value& left, const Value& right) {
+      return left + right;
+    }
+    /// \brief Gives back \c true only if the first value is less than
+    /// the second.
+    static bool less(const Value& left, const Value& right) {
+      return left + eps < right;
     }
   };
@@ -108,5 +156,6 @@
     /// It defines the used operations and the infinity value for the
     /// given \c Value type.
-    /// \see BellmanFordDefaultOperationTraits
+    /// \see BellmanFordDefaultOperationTraits,
+    /// BellmanFordToleranceOperationTraits
     typedef BellmanFordDefaultOperationTraits<Value> OperationTraits;
 
@@ -838,5 +887,6 @@
     /// It defines the used operations and the infinity value for the
     /// given \c Value type.
-    /// \see BellmanFordDefaultOperationTraits
+    /// \see BellmanFordDefaultOperationTraits,
+    /// BellmanFordToleranceOperationTraits
     typedef BellmanFordDefaultOperationTraits<Value> OperationTraits;
 
Index: lemon/bits/edge_set_extender.h
===================================================================
--- lemon/bits/edge_set_extender.h	(revision 887)
+++ lemon/bits/edge_set_extender.h	(revision 877)
@@ -281,6 +281,4 @@
     typedef EdgeSetExtender Graph;
 
-    typedef True UndirectedTag;
-
     typedef typename Parent::Node Node;
     typedef typename Parent::Arc Arc;
Index: lemon/bits/graph_adaptor_extender.h
===================================================================
--- lemon/bits/graph_adaptor_extender.h	(revision 886)
+++ lemon/bits/graph_adaptor_extender.h	(revision 617)
@@ -182,6 +182,4 @@
     typedef GraphAdaptorExtender Adaptor;
 
-    typedef True UndirectedTag;
-
     typedef typename Parent::Node Node;
     typedef typename Parent::Arc Arc;
Index: lemon/bits/path_dump.h
===================================================================
--- lemon/bits/path_dump.h	(revision 890)
+++ lemon/bits/path_dump.h	(revision 529)
@@ -50,5 +50,5 @@
 
     bool empty() const {
-      return predMap[target] == INVALID;
+      return predMap[target] != INVALID;
     }
 
@@ -124,5 +124,5 @@
 
     bool empty() const {
-      return predMatrixMap(source, target) == INVALID;
+      return source != target;
     }
 
Index: lemon/bits/windows.cc
===================================================================
--- lemon/bits/windows.cc	(revision 914)
+++ lemon/bits/windows.cc	(revision 877)
@@ -41,7 +41,5 @@
 #include <unistd.h>
 #include <ctime>
-#ifndef WIN32
 #include <sys/times.h>
-#endif
 #include <sys/time.h>
 #endif
Index: lemon/core.h
===================================================================
--- lemon/core.h	(revision 896)
+++ lemon/core.h	(revision 877)
@@ -395,5 +395,4 @@
       static void copy(const From& from, Digraph &to,
                        NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
-        to.clear();
         for (typename From::NodeIt it(from); it != INVALID; ++it) {
           nodeRefMap[it] = to.addNode();
@@ -423,5 +422,4 @@
       static void copy(const From& from, Graph &to,
                        NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
-        to.clear();
         for (typename From::NodeIt it(from); it != INVALID; ++it) {
           nodeRefMap[it] = to.addNode();
Index: lemon/dfs.h
===================================================================
--- lemon/dfs.h	(revision 900)
+++ lemon/dfs.h	(revision 877)
@@ -566,5 +566,5 @@
     void start(Node t)
     {
-      while ( !emptyQueue() && !(*_reached)[t] )
+      while ( !emptyQueue() && G->target(_stack[_stack_head])!=t )
         processNextArc();
     }
@@ -1513,5 +1513,5 @@
     /// with addSource() before using this function.
     void start(Node t) {
-      while ( !emptyQueue() && !(*_reached)[t] )
+      while ( !emptyQueue() && _digraph->target(_stack[_stack_head]) != t )
         processNextArc();
     }
Index: lemon/hartmann_orlin_mmc.h
===================================================================
--- lemon/hartmann_orlin_mmc.h	(revision 880)
+++ lemon/hartmann_orlin_mmc.h	(revision 877)
@@ -39,5 +39,5 @@
   /// \tparam GR The type of the digraph.
   /// \tparam CM The type of the cost map.
-  /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
+  /// It must conform to the \ref concepts::Rea_data "Rea_data" concept.
 #ifdef DOXYGEN
   template <typename GR, typename CM>
@@ -100,5 +100,5 @@
   /// a directed cycle of minimum mean cost in a digraph
   /// \ref amo93networkflows, \ref dasdan98minmeancycle.
-  /// It is an improved version of \ref KarpMmc "Karp"'s original algorithm,
+  /// It is an improved version of \ref Karp "Karp"'s original algorithm,
   /// it applies an efficient early termination scheme.
   /// It runs in time O(ne) and uses space O(n<sup>2</sup>+e).
Index: lemon/lemon.pc.cmake
===================================================================
--- lemon/lemon.pc.cmake	(revision 904)
+++ 	(revision )
@@ -1,10 +1,0 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=@CMAKE_INSTALL_PREFIX@/bin
-libdir=@CMAKE_INSTALL_PREFIX@/lib
-includedir=@CMAKE_INSTALL_PREFIX@/include
-
-Name: @PROJECT_NAME@
-Description: Library for Efficient Modeling and Optimization in Networks
-Version: @PROJECT_VERSION@
-Libs: -L${libdir} -lemon @GLPK_LIBS@ @CPLEX_LIBS@ @SOPLEX_LIBS@ @CLP_LIBS@ @CBC_LIBS@
-Cflags: -I${includedir}
Index: lemon/maps.h
===================================================================
--- lemon/maps.h	(revision 877)
+++ lemon/maps.h	(revision 915)
@@ -3253,5 +3253,5 @@
     virtual void add(const Key& key) {
       Parent::add(key);
-      unlace(key);
+      lace(key);
     }
 
Index: lemon/network_simplex.h
===================================================================
--- lemon/network_simplex.h	(revision 892)
+++ lemon/network_simplex.h	(revision 877)
@@ -1078,5 +1078,5 @@
         ART_COST = std::numeric_limits<Cost>::max() / 2 + 1;
       } else {
-        ART_COST = 0;
+        ART_COST = std::numeric_limits<Cost>::min();
         for (int i = 0; i != _arc_num; ++i) {
           if (_cost[i] > ART_COST) ART_COST = _cost[i];
@@ -1590,5 +1590,5 @@
       if (_sum_supply == 0) {
         if (_stype == GEQ) {
-          Cost max_pot = -std::numeric_limits<Cost>::max();
+          Cost max_pot = std::numeric_limits<Cost>::min();
           for (int i = 0; i != _node_num; ++i) {
             if (_pi[i] > max_pot) max_pot = _pi[i];
Index: lemon/preflow.h
===================================================================
--- lemon/preflow.h	(revision 902)
+++ lemon/preflow.h	(revision 877)
@@ -544,4 +544,7 @@
           _flow->set(e, (*_capacity)[e]);
           (*_excess)[u] += rem;
+          if (u != _target && !_level->active(u)) {
+            _level->activate(u);
+          }
         }
       }
@@ -553,10 +556,9 @@
           _flow->set(e, 0);
           (*_excess)[v] += rem;
-        }
-      }
-      for (NodeIt n(_graph); n != INVALID; ++n) 
-        if(n!=_source && n!=_target && _tolerance.positive((*_excess)[n]))
-          _level->activate(n);
-          
+          if (v != _target && !_level->active(v)) {
+            _level->activate(v);
+          }
+        }
+      }
       return true;
     }
@@ -575,16 +577,10 @@
       _phase = true;
 
-      while (true) {
+      Node n = _level->highestActive();
+      int level = _level->highestActiveLevel();
+      while (n != INVALID) {
         int num = _node_num;
 
-        Node n = INVALID;
-        int level = -1;
-
-        while (num > 0) {
-          n = _level->highestActive();
-          if (n == INVALID) goto first_phase_done;
-          level = _level->highestActiveLevel();
-          --num;
-          
+        while (num > 0 && n != INVALID) {
           Value excess = (*_excess)[n];
           int new_level = _level->maxLevel();
@@ -652,20 +648,12 @@
             _level->deactivate(n);
           }
+
+          n = _level->highestActive();
+          level = _level->highestActiveLevel();
+          --num;
         }
 
         num = _node_num * 20;
-        while (num > 0) {
-          while (level >= 0 && _level->activeFree(level)) {
-            --level;
-          }
-          if (level == -1) {
-            n = _level->highestActive();
-            level = _level->highestActiveLevel();
-            if (n == INVALID) goto first_phase_done;
-          } else {
-            n = _level->activeOn(level);
-          }
-          --num;
-
+        while (num > 0 && n != INVALID) {
           Value excess = (*_excess)[n];
           int new_level = _level->maxLevel();
@@ -733,7 +721,17 @@
             _level->deactivate(n);
           }
-        }
-      }
-    first_phase_done:;
+
+          while (level >= 0 && _level->activeFree(level)) {
+            --level;
+          }
+          if (level == -1) {
+            n = _level->highestActive();
+            level = _level->highestActiveLevel();
+          } else {
+            n = _level->activeOn(level);
+          }
+          --num;
+        }
+      }
     }
 
