Index: lemon/CMakeLists.txt
===================================================================
--- lemon/CMakeLists.txt	(revision 1264)
+++ lemon/CMakeLists.txt	(revision 1315)
@@ -56,6 +56,11 @@
 
 ADD_LIBRARY(lemon ${LEMON_SOURCES})
+
+TARGET_LINK_LIBRARIES(lemon
+  ${GLPK_LIBRARIES} ${COIN_LIBRARIES} ${ILOG_LIBRARIES} ${SOPLEX_LIBRARIES}
+  )
+
 IF(UNIX)
-  SET_TARGET_PROPERTIES(lemon PROPERTIES OUTPUT_NAME emon)
+  SET_TARGET_PROPERTIES(lemon PROPERTIES OUTPUT_NAME emon VERSION ${LEMON_VERSION} SOVERSION ${LEMON_VERSION})
 ENDIF()
 
Index: lemon/arg_parser.h
===================================================================
--- lemon/arg_parser.h	(revision 959)
+++ lemon/arg_parser.h	(revision 1327)
@@ -27,4 +27,5 @@
 #include <sstream>
 #include <algorithm>
+#include <lemon/core.h>
 #include <lemon/assert.h>
 
Index: lemon/bits/windows.cc
===================================================================
--- lemon/bits/windows.cc	(revision 1270)
+++ lemon/bits/windows.cc	(revision 1341)
@@ -22,5 +22,9 @@
 #include<lemon/bits/windows.h>
 
-#ifdef WIN32
+#if defined(LEMON_WIN32) && defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#endif
+
+#ifdef LEMON_WIN32
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
@@ -41,5 +45,5 @@
 #include <unistd.h>
 #include <ctime>
-#ifndef WIN32
+#ifndef LEMON_WIN32
 #include <sys/times.h>
 #endif
@@ -56,5 +60,5 @@
                          double &cutime, double &cstime)
     {
-#ifdef WIN32
+#ifdef LEMON_WIN32
       static const double ch = 4294967296.0e-7;
       static const double cl = 1.0e-7;
@@ -95,9 +99,9 @@
     {
       std::ostringstream os;
-#ifdef WIN32
+#ifdef LEMON_WIN32
       SYSTEMTIME time;
       GetSystemTime(&time);
       char buf1[11], buf2[9], buf3[5];
-          if (GetDateFormat(MY_LOCALE, 0, &time,
+      if (GetDateFormat(MY_LOCALE, 0, &time,
                         ("ddd MMM dd"), buf1, 11) &&
           GetTimeFormat(MY_LOCALE, 0, &time,
@@ -121,5 +125,5 @@
     int getWinRndSeed()
     {
-#ifdef WIN32
+#ifdef LEMON_WIN32
       FILETIME time;
       GetSystemTimeAsFileTime(&time);
@@ -133,5 +137,5 @@
 
     WinLock::WinLock() {
-#ifdef WIN32
+#ifdef LEMON_WIN32
       CRITICAL_SECTION *lock = new CRITICAL_SECTION;
       InitializeCriticalSection(lock);
@@ -143,5 +147,5 @@
 
     WinLock::~WinLock() {
-#ifdef WIN32
+#ifdef LEMON_WIN32
       CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
       DeleteCriticalSection(lock);
@@ -151,5 +155,5 @@
 
     void WinLock::lock() {
-#ifdef WIN32
+#ifdef LEMON_WIN32
       CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
       EnterCriticalSection(lock);
@@ -158,5 +162,5 @@
 
     void WinLock::unlock() {
-#ifdef WIN32
+#ifdef LEMON_WIN32
       CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
       LeaveCriticalSection(lock);
Index: lemon/bits/windows.h
===================================================================
--- lemon/bits/windows.h	(revision 1270)
+++ lemon/bits/windows.h	(revision 1340)
@@ -20,4 +20,5 @@
 #define LEMON_BITS_WINDOWS_H
 
+#include <lemon/config.h>
 #include <string>
 
@@ -35,5 +36,5 @@
       ~WinLock();
       void lock();
-      void unlock();
+      void unlock();\
     private:
       void *_repr;
Index: lemon/capacity_scaling.h
===================================================================
--- lemon/capacity_scaling.h	(revision 1270)
+++ lemon/capacity_scaling.h	(revision 1363)
@@ -28,4 +28,5 @@
 #include <limits>
 #include <lemon/core.h>
+#include <lemon/maps.h>
 #include <lemon/bin_heap.h>
 
@@ -164,5 +165,5 @@
 
     // Parameters of the problem
-    bool _have_lower;
+    bool _has_lower;
     Value _sum_supply;
 
@@ -357,8 +358,7 @@
     template <typename LowerMap>
     CapacityScaling& lowerMap(const LowerMap& map) {
-      _have_lower = true;
+      _has_lower = true;
       for (ArcIt a(_graph); a != INVALID; ++a) {
         _lower[_arc_idf[a]] = map[a];
-        _lower[_arc_idb[a]] = map[a];
       }
       return *this;
@@ -544,5 +544,5 @@
         _cost[j] = _forward[j] ? 1 : -1;
       }
-      _have_lower = false;
+      _has_lower = false;
       return *this;
     }
@@ -755,5 +755,5 @@
       const Value MAX = std::numeric_limits<Value>::max();
       int last_out;
-      if (_have_lower) {
+      if (_has_lower) {
         for (int i = 0; i != _root; ++i) {
           last_out = _first_out[i+1];
@@ -840,9 +840,9 @@
     }
 
-    // Check if the upper bound is greater or equal to the lower bound
-    // on each arc.
+    // Check if the upper bound is greater than or equal to the lower bound
+    // on each forward arc.
     bool checkBoundMaps() {
       for (int j = 0; j != _res_arc_num; ++j) {
-        if (_upper[j] < _lower[j]) return false;
+        if (_forward[j] && _upper[j] < _lower[j]) return false;
       }
       return true;
@@ -858,8 +858,8 @@
 
       // Handle non-zero lower bounds
-      if (_have_lower) {
+      if (_has_lower) {
         int limit = _first_out[_root];
         for (int j = 0; j != limit; ++j) {
-          if (!_forward[j]) _res_cap[j] += _lower[j];
+          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
         }
       }
Index: lemon/concepts/digraph.h
===================================================================
--- lemon/concepts/digraph.h	(revision 1270)
+++ lemon/concepts/digraph.h	(revision 1271)
@@ -313,5 +313,7 @@
         /// Sets the iterator to the first arc of the given digraph.
         ///
-        explicit ArcIt(const Digraph& g) { ::lemon::ignore_unused_variable_warning(g); }
+        explicit ArcIt(const Digraph& g) {
+          ::lemon::ignore_unused_variable_warning(g);
+        }
         /// Sets the iterator to the given arc.
 
Index: lemon/concepts/graph.h
===================================================================
--- lemon/concepts/graph.h	(revision 1270)
+++ lemon/concepts/graph.h	(revision 1271)
@@ -397,5 +397,7 @@
         /// Sets the iterator to the first arc of the given graph.
         ///
-        explicit ArcIt(const Graph &g) { ::lemon::ignore_unused_variable_warning(g); }
+        explicit ArcIt(const Graph &g) {
+          ::lemon::ignore_unused_variable_warning(g);
+        }
         /// Sets the iterator to the given arc.
 
Index: lemon/config.h.in
===================================================================
--- lemon/config.h.in	(revision 1264)
+++ lemon/config.h.in	(revision 1340)
@@ -1,4 +1,10 @@
+#ifndef LEMON_CONFIG_H
+#define LEMON_CONFIG_H
+
 #define LEMON_VERSION "@PROJECT_VERSION@"
 #cmakedefine LEMON_HAVE_LONG_LONG 1
+
+#cmakedefine LEMON_WIN32 1
+
 #cmakedefine LEMON_HAVE_LP 1
 #cmakedefine LEMON_HAVE_MIP 1
@@ -8,6 +14,16 @@
 #cmakedefine LEMON_HAVE_CLP 1
 #cmakedefine LEMON_HAVE_CBC 1
-#cmakedefine LEMON_DEFAULT_LP @LEMON_DEFAULT_LP@
-#cmakedefine LEMON_DEFAULT_MIP @LEMON_DEFAULT_MIP@
+
+#define LEMON_CPLEX_ 1
+#define LEMON_CLP_ 2
+#define LEMON_GLPK_ 3
+#define LEMON_SOPLEX_ 4
+#define LEMON_CBC_ 5
+
+#cmakedefine LEMON_DEFAULT_LP LEMON_@LEMON_DEFAULT_LP@_
+#cmakedefine LEMON_DEFAULT_MIP LEMON_@LEMON_DEFAULT_MIP@_
+
 #cmakedefine LEMON_USE_PTHREAD 1
 #cmakedefine LEMON_USE_WIN32_THREADS 1
+
+#endif
Index: lemon/core.h
===================================================================
--- lemon/core.h	(revision 1270)
+++ lemon/core.h	(revision 1341)
@@ -20,33 +20,4 @@
 #define LEMON_CORE_H
 
-#include <vector>
-#include <algorithm>
-
-#include <lemon/config.h>
-#include <lemon/bits/enable_if.h>
-#include <lemon/bits/traits.h>
-#include <lemon/assert.h>
-
-// Disable the following warnings when compiling with MSVC:
-// C4250: 'class1' : inherits 'class2::member' via dominance
-// C4355: 'this' : used in base member initializer list
-// C4503: 'function' : decorated name length exceeded, name was truncated
-// C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
-// C4996: 'function': was declared deprecated
-#ifdef _MSC_VER
-#pragma warning( disable : 4250 4355 4503 4800 4996 )
-#endif
-
-#ifdef __GNUC__
-#define GCC_VERSION (__GNUC__ * 10000                   \
-                     + __GNUC_MINOR__ * 100             \
-                     + __GNUC_PATCHLEVEL__)
-#endif
-
-#if GCC_VERSION >= 40800
-// Needed by the [DI]GRAPH_TYPEDEFS marcos for gcc 4.8
-#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
-#endif
-
 ///\file
 ///\brief LEMON core utilities.
@@ -55,4 +26,30 @@
 ///It is automatically included by all graph types, therefore it usually
 ///do not have to be included directly.
+
+// Disable the following warnings when compiling with MSVC:
+// C4250: 'class1' : inherits 'class2::member' via dominance
+// C4267: conversion from 'size_t' to 'type', possible loss of data
+// C4355: 'this' : used in base member initializer list
+// C4503: 'function' : decorated name length exceeded, name was truncated
+// C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
+// C4996: 'function': was declared deprecated
+#ifdef _MSC_VER
+#pragma warning( disable : 4250 4267 4355 4503 4800 4996 )
+#endif
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+// Needed by the [DI]GRAPH_TYPEDEFS marcos for gcc 4.8
+#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
+#endif
+
+#include <vector>
+#include <algorithm>
+
+#include <lemon/config.h>
+#include <lemon/bits/enable_if.h>
+#include <lemon/bits/traits.h>
+#include <lemon/assert.h>
+
+
 
 namespace lemon {
Index: lemon/cost_scaling.h
===================================================================
--- lemon/cost_scaling.h	(revision 1270)
+++ lemon/cost_scaling.h	(revision 1298)
@@ -92,5 +92,6 @@
   /// \ref CostScaling implements a cost scaling algorithm that performs
   /// push/augment and relabel operations for finding a \ref min_cost_flow
-  /// "minimum cost flow" \cite amo93networkflows, \cite goldberg90approximation,
+  /// "minimum cost flow" \cite amo93networkflows,
+  /// \cite goldberg90approximation,
   /// \cite goldberg97efficient, \cite bunnagel98efficient.
   /// It is a highly efficient primal-dual solution method, which
@@ -214,5 +215,6 @@
     typedef std::vector<LargeCost> LargeCostVector;
     typedef std::vector<char> BoolVector;
-    // Note: vector<char> is used instead of vector<bool> for efficiency reasons
+    // Note: vector<char> is used instead of vector<bool>
+    // for efficiency reasons
 
   private:
@@ -255,5 +257,5 @@
 
     // Parameters of the problem
-    bool _have_lower;
+    bool _has_lower;
     Value _sum_supply;
     int _sup_node_num;
@@ -371,8 +373,7 @@
     template <typename LowerMap>
     CostScaling& lowerMap(const LowerMap& map) {
-      _have_lower = true;
+      _has_lower = true;
       for (ArcIt a(_graph); a != INVALID; ++a) {
         _lower[_arc_idf[a]] = map[a];
-        _lower[_arc_idb[a]] = map[a];
       }
       return *this;
@@ -567,5 +568,5 @@
         _scost[_reverse[j]] = 0;
       }
-      _have_lower = false;
+      _has_lower = false;
       return *this;
     }
@@ -779,5 +780,5 @@
       const Value MAX = std::numeric_limits<Value>::max();
       int last_out;
-      if (_have_lower) {
+      if (_has_lower) {
         for (int i = 0; i != _root; ++i) {
           last_out = _first_out[i+1];
@@ -836,5 +837,5 @@
         sup[n] = _supply[_node_id[n]];
       }
-      if (_have_lower) {
+      if (_has_lower) {
         for (ArcIt a(_graph); a != INVALID; ++a) {
           int j = _arc_idf[a];
@@ -906,9 +907,9 @@
     }
 
-    // Check if the upper bound is greater or equal to the lower bound
-    // on each arc.
+    // Check if the upper bound is greater than or equal to the lower bound
+    // on each forward arc.
     bool checkBoundMaps() {
       for (int j = 0; j != _res_arc_num; ++j) {
-        if (_upper[j] < _lower[j]) return false;
+        if (_forward[j] && _upper[j] < _lower[j]) return false;
       }
       return true;
@@ -990,8 +991,8 @@
 
       // Handle non-zero lower bounds
-      if (_have_lower) {
+      if (_has_lower) {
         int limit = _first_out[_root];
         for (int j = 0; j != limit; ++j) {
-          if (!_forward[j]) _res_cap[j] += _lower[j];
+          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
         }
       }
Index: lemon/counter.h
===================================================================
--- lemon/counter.h	(revision 833)
+++ lemon/counter.h	(revision 1327)
@@ -22,4 +22,6 @@
 #include <string>
 #include <iostream>
+
+#include <lemon/core.h>
 
 ///\ingroup timecount
Index: lemon/cplex.cc
===================================================================
--- lemon/cplex.cc	(revision 1270)
+++ lemon/cplex.cc	(revision 1347)
@@ -38,14 +38,32 @@
   }
 
+  void CplexEnv::incCnt()
+  {
+    _cnt_lock->lock();
+    ++(*_cnt);
+    _cnt_lock->unlock();
+  }
+
+  void CplexEnv::decCnt()
+  {
+    _cnt_lock->lock();
+    --(*_cnt);
+    if (*_cnt == 0) {
+      delete _cnt;
+      _cnt_lock->unlock();
+      delete _cnt_lock;
+      CPXcloseCPLEX(&_env);
+    }
+    else _cnt_lock->unlock();
+  }
+  
   CplexEnv::CplexEnv() {
     int status;
+    _env = CPXopenCPLEX(&status);
+    if (_env == 0)
+      throw LicenseError(status);
     _cnt = new int;
     (*_cnt) = 1;
-    _env = CPXopenCPLEX(&status);
-    if (_env == 0) {
-      delete _cnt;
-      _cnt = 0;
-      throw LicenseError(status);
-    }
+    _cnt_lock = new bits::Lock;
   }
 
@@ -53,20 +71,19 @@
     _env = other._env;
     _cnt = other._cnt;
-    ++(*_cnt);
+    _cnt_lock = other._cnt_lock;
+    incCnt();
   }
 
   CplexEnv& CplexEnv::operator=(const CplexEnv& other) {
+    decCnt();
     _env = other._env;
     _cnt = other._cnt;
-    ++(*_cnt);
+    _cnt_lock = other._cnt_lock;
+    incCnt();
     return *this;
   }
 
   CplexEnv::~CplexEnv() {
-    --(*_cnt);
-    if (*_cnt == 0) {
-      delete _cnt;
-      CPXcloseCPLEX(&_env);
-    }
+    decCnt();
   }
 
Index: lemon/cplex.h
===================================================================
--- lemon/cplex.h	(revision 1270)
+++ lemon/cplex.h	(revision 1347)
@@ -24,4 +24,5 @@
 
 #include <lemon/lp_base.h>
+#include <lemon/bits/lock.h>
 
 struct cpxenv;
@@ -41,5 +42,9 @@
     cpxenv* _env;
     mutable int* _cnt;
-
+    mutable bits::Lock* _cnt_lock;
+
+    void incCnt();
+    void decCnt();
+    
   public:
 
Index: lemon/cycle_canceling.h
===================================================================
--- lemon/cycle_canceling.h	(revision 1270)
+++ lemon/cycle_canceling.h	(revision 1298)
@@ -196,5 +196,5 @@
 
     // Parameters of the problem
-    bool _have_lower;
+    bool _has_lower;
     Value _sum_supply;
 
@@ -279,8 +279,7 @@
     template <typename LowerMap>
     CycleCanceling& lowerMap(const LowerMap& map) {
-      _have_lower = true;
+      _has_lower = true;
       for (ArcIt a(_graph); a != INVALID; ++a) {
         _lower[_arc_idf[a]] = map[a];
-        _lower[_arc_idb[a]] = map[a];
       }
       return *this;
@@ -472,5 +471,5 @@
         _cost[_reverse[j]] = 0;
       }
-      _have_lower = false;
+      _has_lower = false;
       return *this;
     }
@@ -685,5 +684,5 @@
       const Value MAX = std::numeric_limits<Value>::max();
       int last_out;
-      if (_have_lower) {
+      if (_has_lower) {
         for (int i = 0; i != _root; ++i) {
           last_out = _first_out[i+1];
@@ -728,5 +727,5 @@
         sup[n] = _supply[_node_id[n]];
       }
-      if (_have_lower) {
+      if (_has_lower) {
         for (ArcIt a(_graph); a != INVALID; ++a) {
           int j = _arc_idf[a];
@@ -785,9 +784,9 @@
     }
 
-    // Check if the upper bound is greater or equal to the lower bound
-    // on each arc.
+    // Check if the upper bound is greater than or equal to the lower bound
+    // on each forward arc.
     bool checkBoundMaps() {
       for (int j = 0; j != _res_arc_num; ++j) {
-        if (_upper[j] < _lower[j]) return false;
+        if (_forward[j] && _upper[j] < _lower[j]) return false;
       }
       return true;
@@ -836,8 +835,8 @@
 
       // Handle non-zero lower bounds
-      if (_have_lower) {
+      if (_has_lower) {
         int limit = _first_out[_root];
         for (int j = 0; j != limit; ++j) {
-          if (!_forward[j]) _res_cap[j] += _lower[j];
+          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
         }
       }
Index: lemon/dim2.h
===================================================================
--- lemon/dim2.h	(revision 761)
+++ lemon/dim2.h	(revision 1311)
@@ -21,4 +21,5 @@
 
 #include <iostream>
+#include <algorithm>
 
 ///\ingroup geomdat
Index: lemon/elevator.h
===================================================================
--- lemon/elevator.h	(revision 628)
+++ lemon/elevator.h	(revision 1328)
@@ -168,5 +168,5 @@
     int onLevel(int l) const
     {
-      return _first[l+1]-_first[l];
+      return static_cast<int>(_first[l+1]-_first[l]);
     }
     ///Return true if level \c l is empty.
@@ -178,10 +178,10 @@
     int aboveLevel(int l) const
     {
-      return _first[_max_level+1]-_first[l+1];
+      return static_cast<int>(_first[_max_level+1]-_first[l+1]);
     }
     ///Return the number of active items on level \c l.
     int activesOnLevel(int l) const
     {
-      return _last_active[l]-_first[l]+1;
+      return static_cast<int>(_last_active[l]-_first[l]+1);
     }
     ///Return true if there is no active item on level \c l.
Index: lemon/graph_to_eps.h
===================================================================
--- lemon/graph_to_eps.h	(revision 1270)
+++ lemon/graph_to_eps.h	(revision 1340)
@@ -26,5 +26,5 @@
 #include<vector>
 
-#ifndef WIN32
+#ifndef LEMON_WIN32
 #include<sys/time.h>
 #include<ctime>
@@ -223,5 +223,4 @@
   using T::_copyright;
 
-  using T::NodeTextColorType;
   using T::CUST_COL;
   using T::DIST_COL;
@@ -676,5 +675,5 @@
     {
       os << "%%CreationDate: ";
-#ifndef WIN32
+#ifndef LEMON_WIN32
       timeval tv;
       gettimeofday(&tv, 0);
Index: lemon/howard_mmc.h
===================================================================
--- lemon/howard_mmc.h	(revision 1270)
+++ lemon/howard_mmc.h	(revision 1271)
@@ -362,5 +362,6 @@
     /// \return The termination cause of the search process.
     /// For more information, see \ref TerminationCause.
-    TerminationCause findCycleMean(int limit = std::numeric_limits<int>::max()) {
+    TerminationCause findCycleMean(int limit =
+                                   std::numeric_limits<int>::max()) {
       // Initialize and find strongly connected components
       init();
Index: lemon/list_graph.h
===================================================================
--- lemon/list_graph.h	(revision 1270)
+++ lemon/list_graph.h	(revision 1357)
@@ -583,5 +583,5 @@
         }
         virtual void add(const std::vector<Node>& nodes) {
-          for (int i = nodes.size() - 1; i >= 0; ++i) {
+          for (int i = nodes.size() - 1; i >= 0; --i) {
             snapshot.addNode(nodes[i]);
           }
@@ -633,5 +633,5 @@
         }
         virtual void add(const std::vector<Arc>& arcs) {
-          for (int i = arcs.size() - 1; i >= 0; ++i) {
+          for (int i = arcs.size() - 1; i >= 0; --i) {
             snapshot.addArc(arcs[i]);
           }
@@ -1395,5 +1395,5 @@
         }
         virtual void add(const std::vector<Node>& nodes) {
-          for (int i = nodes.size() - 1; i >= 0; ++i) {
+          for (int i = nodes.size() - 1; i >= 0; --i) {
             snapshot.addNode(nodes[i]);
           }
@@ -1445,5 +1445,5 @@
         }
         virtual void add(const std::vector<Edge>& edges) {
-          for (int i = edges.size() - 1; i >= 0; ++i) {
+          for (int i = edges.size() - 1; i >= 0; --i) {
             snapshot.addEdge(edges[i]);
           }
@@ -2300,5 +2300,5 @@
         }
         virtual void add(const std::vector<Node>& nodes) {
-          for (int i = nodes.size() - 1; i >= 0; ++i) {
+          for (int i = nodes.size() - 1; i >= 0; --i) {
             snapshot.addNode(nodes[i]);
           }
@@ -2350,5 +2350,5 @@
         }
         virtual void add(const std::vector<Edge>& edges) {
-          for (int i = edges.size() - 1; i >= 0; ++i) {
+          for (int i = edges.size() - 1; i >= 0; --i) {
             snapshot.addEdge(edges[i]);
           }
Index: lemon/lp.h
===================================================================
--- lemon/lp.h	(revision 1270)
+++ lemon/lp.h	(revision 1340)
@@ -23,12 +23,18 @@
 
 
-#ifdef LEMON_HAVE_GLPK
+#if LEMON_DEFAULT_LP == LEMON_GLPK_ || LEMON_DEFAULT_MIP == LEMON_GLPK_
 #include <lemon/glpk.h>
-#elif LEMON_HAVE_CPLEX
+#endif
+#if LEMON_DEFAULT_LP == LEMON_CPLEX_ || LEMON_DEFAULT_MIP == LEMON_CPLEX_
 #include <lemon/cplex.h>
-#elif LEMON_HAVE_SOPLEX
+#endif
+#if LEMON_DEFAULT_LP == LEMON_SOPLEX_
 #include <lemon/soplex.h>
-#elif LEMON_HAVE_CLP
+#endif
+#if LEMON_DEFAULT_LP == LEMON_CLP_
 #include <lemon/clp.h>
+#endif
+#if LEMON_DEFAULT_MIP == LEMON_CBC_
+#include <lemon/cbc.h>
 #endif
 
@@ -44,6 +50,6 @@
   ///\ingroup lp_group
   ///
-  ///Currently, the possible values are \c GLPK, \c CPLEX,
-  ///\c SOPLEX or \c CLP
+  ///Currently, the possible values are \c LEMON_GLPK_, \c LEMON_CPLEX_,
+  ///\c LEMON_SOPLEX_ or \c LEMON_CLP_
 #define LEMON_DEFAULT_LP SOLVER
   ///The default LP solver
@@ -60,5 +66,6 @@
   ///\ingroup lp_group
   ///
-  ///Currently, the possible values are \c GLPK, \c CPLEX or \c CBC
+  ///Currently, the possible values are \c LEMON_GLPK_, \c LEMON_CPLEX_
+  ///or \c LEMON_CBC_
 #define LEMON_DEFAULT_MIP SOLVER
   ///The default MIP solver.
@@ -70,18 +77,18 @@
   typedef GlpkMip Mip;
 #else
-#if LEMON_DEFAULT_LP == GLPK
+#if LEMON_DEFAULT_LP == LEMON_GLPK_
   typedef GlpkLp Lp;
-#elif LEMON_DEFAULT_LP == CPLEX
+#elif LEMON_DEFAULT_LP == LEMON_CPLEX_
   typedef CplexLp Lp;
-#elif LEMON_DEFAULT_LP == SOPLEX
+#elif LEMON_DEFAULT_LP == LEMON_SOPLEX_
   typedef SoplexLp Lp;
-#elif LEMON_DEFAULT_LP == CLP
+#elif LEMON_DEFAULT_LP == LEMON_CLP_
   typedef ClpLp Lp;
 #endif
-#if LEMON_DEFAULT_MIP == GLPK
-  typedef GlpkLp Mip;
-#elif LEMON_DEFAULT_MIP == CPLEX
+#if LEMON_DEFAULT_MIP == LEMON_GLPK_
+  typedef GlpkMip Mip;
+#elif LEMON_DEFAULT_MIP == LEMON_CPLEX_
   typedef CplexMip Mip;
-#elif LEMON_DEFAULT_MIP == CBC
+#elif LEMON_DEFAULT_MIP == LEMON_CBC_
   typedef CbcMip Mip;
 #endif
Index: lemon/math.h
===================================================================
--- lemon/math.h	(revision 1270)
+++ lemon/math.h	(revision 1311)
@@ -68,5 +68,5 @@
   ///Round a value to its closest integer
   inline double round(double r) {
-    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
+    return (r > 0.0) ? std::floor(r + 0.5) : std::ceil(r - 0.5);
   }
 
Index: lemon/max_cardinality_search.h
===================================================================
--- lemon/max_cardinality_search.h	(revision 1270)
+++ lemon/max_cardinality_search.h	(revision 1271)
@@ -165,6 +165,6 @@
     ///
     /// This function instantiates a \ref CardinalityMap.
-    /// \param digraph is the digraph, to which we would like to define the \ref
-    /// CardinalityMap
+    /// \param digraph is the digraph, to which we would like to
+    /// define the \ref CardinalityMap
     static CardinalityMap *createCardinalityMap(const Digraph &digraph) {
       return new CardinalityMap(digraph);
@@ -181,5 +181,6 @@
   /// Search algorithm. The maximum cardinality search first chooses any
   /// node of the digraph. Then every time it chooses one unprocessed node
-  /// with maximum cardinality, i.e the sum of capacities on out arcs to the nodes
+  /// with maximum cardinality, i.e the sum of capacities on out arcs
+  /// to the nodes
   /// which were previusly processed.
   /// If there is a cut in the digraph the algorithm should choose
Index: lemon/nearest_neighbor_tsp.h
===================================================================
--- lemon/nearest_neighbor_tsp.h	(revision 1270)
+++ lemon/nearest_neighbor_tsp.h	(revision 1294)
@@ -116,5 +116,5 @@
             for (IncEdgeIt e(_gr, n1); e != INVALID; ++e) {
               if (!used[_gr.runningNode(e)] &&
-                  (_cost[e] < _cost[min_edge1] || min_edge1 == INVALID)) {
+                  (min_edge1 == INVALID || _cost[e] < _cost[min_edge1])) {
                 min_edge1 = e;
               }
@@ -125,5 +125,5 @@
             for (IncEdgeIt e(_gr, n2); e != INVALID; ++e) {
               if (!used[_gr.runningNode(e)] &&
-                  (_cost[e] < _cost[min_edge2] || min_edge2 == INVALID)) {
+                  (min_edge2 == INVALID||_cost[e] < _cost[min_edge2])) {
                 min_edge2 = e;
               }
Index: lemon/network_simplex.h
===================================================================
--- lemon/network_simplex.h	(revision 1270)
+++ lemon/network_simplex.h	(revision 1318)
@@ -199,5 +199,5 @@
 
     // Parameters of the problem
-    bool _have_lower;
+    bool _has_lower;
     SupplyType _stype;
     Value _sum_supply;
@@ -683,5 +683,5 @@
     template <typename LowerMap>
     NetworkSimplex& lowerMap(const LowerMap& map) {
-      _have_lower = true;
+      _has_lower = true;
       for (ArcIt a(_graph); a != INVALID; ++a) {
         _lower[_arc_id[a]] = map[a];
@@ -880,5 +880,5 @@
         _cost[i] = 1;
       }
-      _have_lower = false;
+      _has_lower = false;
       _stype = GEQ;
       return *this;
@@ -937,5 +937,5 @@
         _node_id[n] = i;
       }
-      if (_arc_mixing) {
+      if (_arc_mixing && _node_num > 1) {
         // Store the arcs in a mixed order
         const int skip = std::max(_arc_num / _node_num, 3);
@@ -1073,5 +1073,5 @@
 
       // Remove non-zero lower bounds
-      if (_have_lower) {
+      if (_has_lower) {
         for (int i = 0; i != _arc_num; ++i) {
           Value c = _lower[i];
@@ -1236,5 +1236,5 @@
     }
 
-    // Check if the upper bound is greater or equal to the lower bound
+    // Check if the upper bound is greater than or equal to the lower bound
     // on each arc.
     bool checkBoundMaps() {
@@ -1613,5 +1613,5 @@
 
       // Transform the solution and the supply map to the original form
-      if (_have_lower) {
+      if (_has_lower) {
         for (int i = 0; i != _arc_num; ++i) {
           Value c = _lower[i];
Index: lemon/preflow.h
===================================================================
--- lemon/preflow.h	(revision 1385)
+++ lemon/preflow.h	(revision 1270)
@@ -477,5 +477,5 @@
     /// flow to the given \c flowMap. The \c flowMap should contain a
     /// flow or at least a preflow, i.e. at each node excluding the
-    /// source node the incoming flow should be greater or equal to the
+    /// source node the incoming flow should greater or equal to the
     /// outgoing flow.
     /// \return \c false if the given \c flowMap is not a preflow.
@@ -496,5 +496,5 @@
           excess -= (*_flow)[e];
         }
-        if (_tolerance.negative(excess) && n != _source) return false;
+        if (excess < 0 && n != _source) return false;
         (*_excess)[n] = excess;
       }
@@ -640,5 +640,5 @@
           (*_excess)[n] = excess;
 
-          if (_tolerance.nonZero(excess)) {
+          if (excess != 0) {
             if (new_level + 1 < _level->maxLevel()) {
               _level->liftHighestActive(new_level + 1);
@@ -721,5 +721,5 @@
           (*_excess)[n] = excess;
 
-          if (_tolerance.nonZero(excess)) {
+          if (excess != 0) {
             if (new_level + 1 < _level->maxLevel()) {
               _level->liftActiveOn(level, new_level + 1);
@@ -792,5 +792,5 @@
         if (!reached[n]) {
           _level->dirtyTopButOne(n);
-        } else if (_tolerance.positive((*_excess)[n]) && _target != n) {
+        } else if ((*_excess)[n] > 0 && _target != n) {
           _level->activate(n);
         }
@@ -853,5 +853,5 @@
         (*_excess)[n] = excess;
 
-        if (_tolerance.nonZero(excess)) {
+        if (excess != 0) {
           if (new_level + 1 < _level->maxLevel()) {
             _level->liftHighestActive(new_level + 1);
Index: lemon/radix_sort.h
===================================================================
--- lemon/radix_sort.h	(revision 1270)
+++ lemon/radix_sort.h	(revision 1328)
@@ -329,5 +329,5 @@
       Allocator allocator;
 
-      int length = std::distance(first, last);
+      int length = static_cast<int>(std::distance(first, last));
       Key* buffer = allocator.allocate(2 * length);
       try {
Index: lemon/random.h
===================================================================
--- lemon/random.h	(revision 631)
+++ lemon/random.h	(revision 1340)
@@ -63,4 +63,6 @@
 #define LEMON_RANDOM_H
 
+#include <lemon/config.h>
+
 #include <algorithm>
 #include <iterator>
@@ -72,5 +74,5 @@
 #include <lemon/dim2.h>
 
-#ifndef WIN32
+#ifndef LEMON_WIN32
 #include <sys/time.h>
 #include <ctime>
@@ -200,5 +202,5 @@
         initState(init);
 
-        num = length > end - begin ? length : end - begin;
+        num = static_cast<int>(length > end - begin ? length : end - begin);
         while (num--) {
           curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul1))
@@ -214,5 +216,5 @@
         }
 
-        num = length - 1; cnt = length - (curr - state) - 1;
+        num = length - 1; cnt = static_cast<int>(length - (curr - state) - 1);
         while (num--) {
           curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul2))
@@ -606,5 +608,5 @@
     /// \return Currently always \c true.
     bool seed() {
-#ifndef WIN32
+#ifndef LEMON_WIN32
       if (seedFromFile("/dev/urandom", 0)) return true;
 #endif
@@ -626,5 +628,5 @@
     /// \param offset The offset, from the file read.
     /// \return \c true when the seeding successes.
-#ifndef WIN32
+#ifndef LEMON_WIN32
     bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0)
 #else
@@ -648,5 +650,5 @@
     /// \return Currently always \c true.
     bool seedFromTime() {
-#ifndef WIN32
+#ifndef LEMON_WIN32
       timeval tv;
       gettimeofday(&tv, 0);
Index: lemon/static_graph.h
===================================================================
--- lemon/static_graph.h	(revision 956)
+++ lemon/static_graph.h	(revision 1328)
@@ -204,5 +204,5 @@
 
       node_num = n;
-      arc_num = std::distance(first, last);
+      arc_num = static_cast<int>(std::distance(first, last));
 
       node_first_out = new int[node_num + 1];
Index: lemon/time_measure.h
===================================================================
--- lemon/time_measure.h	(revision 1270)
+++ lemon/time_measure.h	(revision 1340)
@@ -24,5 +24,7 @@
 ///\brief Tools for measuring cpu usage
 
-#ifdef WIN32
+#include <lemon/config.h>
+
+#ifdef LEMON_WIN32
 #include <lemon/bits/windows.h>
 #else
@@ -103,5 +105,5 @@
     void stamp()
     {
-#ifndef WIN32
+#ifndef LEMON_WIN32
       timeval tv;
       gettimeofday(&tv, 0);
