Index: lemon/bin_heap.h
===================================================================
--- lemon/bin_heap.h	(revision 2546)
+++ lemon/bin_heap.h	(revision 2547)
@@ -40,22 +40,22 @@
   ///one can change the priority of an item, add or erase an item, etc.
   ///
-  ///\param Prio Type of the priority of the items.
-  ///\param ItemIntMap A read and writable Item int map, used internally
+  ///\param _Prio Type of the priority of the items.
+  ///\param _ItemIntMap A read and writable Item int map, used internally
   ///to handle the cross references.
-  ///\param Compare A class for the ordering of the priorities. The
-  ///default is \c std::less<Prio>.
+  ///\param _Compare A class for the ordering of the priorities. The
+  ///default is \c std::less<_Prio>.
   ///
   ///\sa FibHeap
   ///\sa Dijkstra
-  template <typename Prio, typename ItemIntMap,
-	    typename Compare = std::less<Prio> >
+  template <typename _Prio, typename _ItemIntMap,
+	    typename _Compare = std::less<_Prio> >
   class BinHeap {
 
   public:
-    typedef typename ItemIntMap::Key         ItemType;
-    typedef Prio                             PrioType;
-    typedef std::pair<ItemType,PrioType>     PairType;
-    typedef ItemIntMap                       ItemIntMapType;
-    typedef Compare                          PrioCompare;
+    typedef _ItemIntMap ItemIntMap;
+    typedef _Prio Prio;
+    typedef typename ItemIntMap::Key Item;
+    typedef std::pair<Item,Prio> Pair;
+    typedef _Compare Compare;
 
     /// \brief Type to represent the items states.
@@ -67,5 +67,5 @@
     /// The ItemIntMap \e should be initialized in such way that it maps
     /// PRE_HEAP (-1) to any element to be put in the heap...
-    enum state_enum {
+    enum State {
       IN_HEAP = 0,
       PRE_HEAP = -1,
@@ -74,5 +74,5 @@
 
   private:
-    std::vector<PairType> data;
+    std::vector<Pair> data;
     Compare comp;
     ItemIntMap &iim;
@@ -123,9 +123,9 @@
 
     static int second_child(int i) { return 2*i+2; }
-    bool less(const PairType &p1, const PairType &p2) const {
+    bool less(const Pair &p1, const Pair &p2) const {
       return comp(p1.second, p2.second);
     }
 
-    int bubble_up(int hole, PairType p) {
+    int bubble_up(int hole, Pair p) {
       int par = parent(hole);
       while( hole>0 && less(p,data[par]) ) {
@@ -138,5 +138,5 @@
     }
 
-    int bubble_down(int hole, PairType p, int length) {
+    int bubble_down(int hole, Pair p, int length) {
       int child = second_child(hole);
       while(child < length) {
@@ -160,5 +160,5 @@
     }
 
-    void move(const PairType &p, int i) {
+    void move(const Pair &p, int i) {
       data[i] = p;
       iim.set(p.first, i);
@@ -170,5 +170,5 @@
     /// Adds \c p.first to the heap with priority \c p.second.
     /// \param p The pair to insert.
-    void push(const PairType &p) {
+    void push(const Pair &p) {
       int n = data.size();
       data.resize(n+1);
@@ -181,5 +181,5 @@
     /// \param i The item to insert.
     /// \param p The priority of the item.
-    void push(const ItemType &i, const Prio &p) { push(PairType(i,p)); }
+    void push(const Item &i, const Prio &p) { push(Pair(i,p)); }
 
     /// \brief Returns the item with minimum priority relative to \c Compare.
@@ -188,5 +188,5 @@
     /// Compare.  
     /// \pre The heap must be nonempty.  
-    ItemType top() const {
+    Item top() const {
       return data[0].first;
     }
@@ -219,5 +219,5 @@
     /// \param i The item to erase.
     /// \pre The item should be in the heap.
-    void erase(const ItemType &i) {
+    void erase(const Item &i) {
       int h = iim[i];
       int n = data.size()-1;
@@ -237,5 +237,5 @@
     /// \pre \c i must be in the heap.
     /// \param i The item.
-    Prio operator[](const ItemType &i) const {
+    Prio operator[](const Item &i) const {
       int idx = iim[i];
       return data[idx].second;
@@ -249,5 +249,5 @@
     /// \param i The item.
     /// \param p The priority.
-    void set(const ItemType &i, const Prio &p) {
+    void set(const Item &i, const Prio &p) {
       int idx = iim[i];
       if( idx < 0 ) {
@@ -255,8 +255,8 @@
       }
       else if( comp(p, data[idx].second) ) {
-	bubble_up(idx, PairType(i,p));
+	bubble_up(idx, Pair(i,p));
       }
       else {
-	bubble_down(idx, PairType(i,p), data.size());
+	bubble_down(idx, Pair(i,p), data.size());
       }
     }
@@ -269,7 +269,7 @@
     /// \param i The item.
     /// \param p The priority.
-    void decrease(const ItemType &i, const Prio &p) {
+    void decrease(const Item &i, const Prio &p) {
       int idx = iim[i];
-      bubble_up(idx, PairType(i,p));
+      bubble_up(idx, Pair(i,p));
     }
     
@@ -281,7 +281,7 @@
     /// \param i The item.
     /// \param p The priority.
-    void increase(const ItemType &i, const Prio &p) {
+    void increase(const Item &i, const Prio &p) {
       int idx = iim[i];
-      bubble_down(idx, PairType(i,p), data.size());
+      bubble_down(idx, Pair(i,p), data.size());
     }
 
@@ -294,9 +294,9 @@
     /// get back to the heap again.
     /// \param i The item.
-    state_enum state(const ItemType &i) const {
+    State state(const Item &i) const {
       int s = iim[i];
       if( s>=0 )
 	s=0;
-      return state_enum(s);
+      return State(s);
     }
 
@@ -308,5 +308,5 @@
     /// \param i The item.
     /// \param st The state. It should not be \c IN_HEAP. 
-    void state(const ItemType& i, state_enum st) {
+    void state(const Item& i, State st) {
       switch (st) {
       case POST_HEAP:
Index: lemon/bucket_heap.h
===================================================================
--- lemon/bucket_heap.h	(revision 2391)
+++ lemon/bucket_heap.h	(revision 2547)
@@ -50,7 +50,11 @@
 
   public:
+    /// \e
     typedef typename _ItemIntMap::Key Item;
+    /// \e
     typedef int Prio;
+    /// \e
     typedef std::pair<Item, Prio> Pair;
+    /// \e
     typedef _ItemIntMap ItemIntMap;
 
@@ -63,5 +67,5 @@
     /// The ItemIntMap \e should be initialized in such way that it maps
     /// PRE_HEAP (-1) to any element to be put in the heap...
-    enum state_enum {
+    enum State {
       IN_HEAP = 0,
       PRE_HEAP = -1,
@@ -279,8 +283,8 @@
     /// get back to the heap again.
     /// \param i The item.
-    state_enum state(const Item &i) const {
+    State state(const Item &i) const {
       int idx = index[i];
       if (idx >= 0) idx = 0;
-      return state_enum(idx);
+      return State(idx);
     }
 
@@ -292,5 +296,5 @@
     /// \param i The item.
     /// \param st The state. It should not be \c IN_HEAP. 
-    void state(const Item& i, state_enum st) {
+    void state(const Item& i, State st) {
       switch (st) {
       case POST_HEAP:
@@ -335,5 +339,5 @@
     typedef _ItemIntMap ItemIntMap;
 
-    enum state_enum {
+    enum State {
       IN_HEAP = 0,
       PRE_HEAP = -1,
@@ -473,11 +477,11 @@
     }
 
-    state_enum state(const Item &i) const {
+    State state(const Item &i) const {
       int idx = index[i];
       if (idx >= 0) idx = 0;
-      return state_enum(idx);
-    }
-
-    void state(const Item& i, state_enum st) {
+      return State(idx);
+    }
+
+    void state(const Item& i, State st) {
       switch (st) {
       case POST_HEAP:
@@ -547,5 +551,5 @@
     /// The ItemIntMap \e should be initialized in such way that it maps
     /// PRE_HEAP (-1) to any element to be put in the heap...
-    enum state_enum {
+    enum State {
       IN_HEAP = 0,
       PRE_HEAP = -1,
@@ -684,8 +688,8 @@
     /// get back to the heap again.
     /// \param i The item.
-    state_enum state(const Item &i) const {
+    State state(const Item &i) const {
       int idx = index[i];
       if (idx >= 0) idx = 0;
-      return state_enum(idx);
+      return State(idx);
     }
 
@@ -717,5 +721,5 @@
     typedef _ItemIntMap ItemIntMap;
 
-    enum state_enum {
+    enum State {
       IN_HEAP = 0,
       PRE_HEAP = -1,
@@ -799,8 +803,8 @@
     }
 
-    state_enum state(const Item &i) const {
+    State state(const Item &i) const {
       int idx = index[i];
       if (idx >= 0) idx = 0;
-      return state_enum(idx);
+      return State(idx);
     }
 
Index: lemon/concepts/heap.h
===================================================================
--- lemon/concepts/heap.h	(revision 2391)
+++ lemon/concepts/heap.h	(revision 2547)
@@ -53,5 +53,5 @@
       /// The ItemIntMap _should_ be initialized in such way, that it maps
       /// PRE_HEAP (-1) to any element to be put in the heap...
-      enum state_enum {
+      enum State {
 	IN_HEAP = 0,
 	PRE_HEAP = -1,
@@ -156,5 +156,5 @@
       /// get back to the heap again.
       /// \param i The item.
-      state_enum state(const Item &i) const {}
+      State state(const Item &i) const {}
 
       /// \brief Sets the state of the \c item in the heap.
@@ -165,5 +165,5 @@
       /// \param i The item.
       /// \param st The state. It should not be \c IN_HEAP. 
-      void state(const Item& i, state_enum st) {}
+      void state(const Item& i, State st) {}
 
 
@@ -182,6 +182,6 @@
 	  ignore_unused_variable_warning(prio);
 
-	  typedef typename _Heap::state_enum state_enum;
-	  state_enum state;
+	  typedef typename _Heap::State State;
+	  State state;
 
 	  ignore_unused_variable_warning(state);
Index: lemon/fib_heap.h
===================================================================
--- lemon/fib_heap.h	(revision 2529)
+++ lemon/fib_heap.h	(revision 2547)
@@ -42,11 +42,11 @@
   ///The methods \ref increase and \ref erase are not efficient in a Fibonacci
   ///heap. In case of many calls to these operations, it is better to use a
-  ///\e binary \e heap.
+  ///\ref BinHeap "binary heap".
   ///
-  ///\param Prio Type of the priority of the items.
-  ///\param ItemIntMap A read and writable Item int map, used internally
+  ///\param _Prio Type of the priority of the items.
+  ///\param _ItemIntMap A read and writable Item int map, used internally
   ///to handle the cross references.
-  ///\param Compare A class for the ordering of the priorities. The
-  ///default is \c std::less<Prio>.
+  ///\param _Compare A class for the ordering of the priorities. The
+  ///default is \c std::less<_Prio>.
   ///
   ///\sa BinHeap
@@ -55,16 +55,19 @@
  
 #ifdef DOXYGEN
-  template <typename Prio, 
-	    typename ItemIntMap, 
-	    typename Compare>
+  template <typename _Prio, 
+	    typename _ItemIntMap, 
+	    typename _Compare>
 #else
-  template <typename Prio, 
-	    typename ItemIntMap, 
-	    typename Compare = std::less<Prio> >
+  template <typename _Prio, 
+	    typename _ItemIntMap, 
+	    typename _Compare = std::less<_Prio> >
 #endif
   class FibHeap {
   public:
+    typedef _ItemIntMap ItemIntMap;
+    typedef _Prio Prio;
     typedef typename ItemIntMap::Key Item;
-    typedef Prio PrioType;
+    typedef std::pair<Item,Prio> Pair;
+    typedef _Compare Compare;
     
   private:
@@ -79,5 +82,5 @@
   public:
     ///Status of the nodes
-    enum state_enum {
+    enum State {
       ///The node is in the heap
       IN_HEAP = 0,
@@ -100,6 +103,6 @@
     /// internally to handle the cross references. \c _comp is an
     /// object for ordering of the priorities. 
-    FibHeap(ItemIntMap &_iimap, const Compare &_comp) : minimum(0), 
-		  iimap(_iimap), comp(_comp), num_items() {}
+    FibHeap(ItemIntMap &_iimap, const Compare &_comp) 
+      : minimum(0), iimap(_iimap), comp(_comp), num_items() {}
     
     /// \brief The number of items stored in the heap.
@@ -129,5 +132,11 @@
     /// stored in the heap and it calls \ref decrease(\c item, \c value) or
     /// \ref increase(\c item, \c value) otherwise.
-    void set (Item const item, PrioType const value); 
+    void set (const Item& item, const Prio& value) {
+      int i=iimap[item];
+      if ( i >= 0 && container[i].in ) {
+	if ( comp(value, container[i].prio) ) decrease(item, value); 
+	if ( comp(container[i].prio, value) ) increase(item, value); 
+      } else push(item, value);
+    }
     
     /// \brief Adds \c item to the heap with priority \c value. 
@@ -135,155 +144,5 @@
     /// Adds \c item to the heap with priority \c value. 
     /// \pre \c item must not be stored in the heap. 
-    void push (Item const item, PrioType const value);
-    
-    /// \brief Returns the item with minimum priority relative to \c Compare.
-    ///
-    /// This method returns the item with minimum priority relative to \c
-    /// Compare.  
-    /// \pre The heap must be nonempty.  
-    Item top() const { return container[minimum].name; }
-
-    /// \brief Returns the minimum priority relative to \c Compare.
-    ///
-    /// It returns the minimum priority relative to \c Compare.
-    /// \pre The heap must be nonempty.
-    PrioType prio() const { return container[minimum].prio; }
-    
-    /// \brief Returns the priority of \c item.
-    ///
-    /// This function returns the priority of \c item.
-    /// \pre \c item must be in the heap.
-    PrioType& operator[](const Item& item) { 
-      return container[iimap[item]].prio; 
-    }
-    
-    /// \brief Returns the priority of \c item.
-    ///
-    /// It returns the priority of \c item.
-    /// \pre \c item must be in the heap.
-    const PrioType& operator[](const Item& item) const { 
-      return container[iimap[item]].prio; 
-    }
-
-
-    /// \brief Deletes the item with minimum priority relative to \c Compare.
-    ///
-    /// This method deletes the item with minimum priority relative to \c
-    /// Compare from the heap.  
-    /// \pre The heap must be non-empty.  
-    void pop();
-
-    /// \brief Deletes \c item from the heap.
-    ///
-    /// This method deletes \c item from the heap, if \c item was already
-    /// stored in the heap. It is quite inefficient in Fibonacci heaps.
-    void erase (const Item& item); 
-
-    /// \brief Decreases the priority of \c item to \c value.
-    ///
-    /// This method decreases the priority of \c item to \c value.
-    /// \pre \c item must be stored in the heap with priority at least \c
-    ///   value relative to \c Compare.
-    void decrease (Item item, PrioType const value); 
-
-    /// \brief Increases the priority of \c item to \c value.
-    ///
-    /// This method sets the priority of \c item to \c value. Though
-    /// there is no precondition on the priority of \c item, this
-    /// method should be used only if it is indeed necessary to increase
-    /// (relative to \c Compare) the priority of \c item, because this
-    /// method is inefficient.
-    void increase (Item item, PrioType const value) {
-      erase(item);
-      push(item, value);
-    }
-
-
-    /// \brief Returns if \c item is in, has already been in, or has never 
-    /// been in the heap.
-    ///
-    /// This method returns PRE_HEAP if \c item has never been in the
-    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
-    /// otherwise. In the latter case it is possible that \c item will
-    /// get back to the heap again.
-    state_enum state(const Item &item) const {
-      int i=iimap[item];
-      if( i>=0 ) {
-	if ( container[i].in ) i=0;
-	else i=-2; 
-      }
-      return state_enum(i);
-    }    
-
-    /// \brief Sets the state of the \c item in the heap.
-    ///
-    /// Sets the state of the \c item in the heap. It can be used to
-    /// manually clear the heap when it is important to achive the
-    /// better time complexity.
-    /// \param i The item.
-    /// \param st The state. It should not be \c IN_HEAP. 
-    void state(const Item& i, state_enum st) {
-      switch (st) {
-      case POST_HEAP:
-      case PRE_HEAP:
-        if (state(i) == IN_HEAP) {
-          erase(i);
-        }
-        iimap[i] = st;
-        break;
-      case IN_HEAP:
-        break;
-      }
-    }
-    
-  private:
-    
-    void balance();
-    void makeroot(int c);
-    void cut(int a, int b);
-    void cascade(int a);
-    void fuse(int a, int b);
-    void unlace(int a);
-
-
-    class store {
-      friend class FibHeap;
-      
-      Item name;
-      int parent;
-      int left_neighbor;
-      int right_neighbor;
-      int child;
-      int degree;  
-      bool marked;
-      bool in;
-      PrioType prio;
-      
-      store() : parent(-1), child(-1), degree(), marked(false), in(true) {} 
-    };
-  };    
- 
-
-
-    // **********************************************************************
-    //  IMPLEMENTATIONS
-    // **********************************************************************
-    
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::set 
-  (Item const item, PrioType const value) 
-  {
-    int i=iimap[item];
-    if ( i >= 0 && container[i].in ) {
-      if ( comp(value, container[i].prio) ) decrease(item, value); 
-      if ( comp(container[i].prio, value) ) increase(item, value); 
-    } else push(item, value);
-  }
-    
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::push 
-  (Item const item, PrioType const value) {
+    void push (const Item& item, const Prio& value) {
       int i=iimap[item];      
       if ( i < 0 ) {
@@ -315,7 +174,31 @@
     }
     
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::pop() {
+    /// \brief Returns the item with minimum priority relative to \c Compare.
+    ///
+    /// This method returns the item with minimum priority relative to \c
+    /// Compare.  
+    /// \pre The heap must be nonempty.  
+    Item top() const { return container[minimum].name; }
+
+    /// \brief Returns the minimum priority relative to \c Compare.
+    ///
+    /// It returns the minimum priority relative to \c Compare.
+    /// \pre The heap must be nonempty.
+    const Prio& prio() const { return container[minimum].prio; }
+        
+    /// \brief Returns the priority of \c item.
+    ///
+    /// It returns the priority of \c item.
+    /// \pre \c item must be in the heap.
+    const Prio& operator[](const Item& item) const { 
+      return container[iimap[item]].prio; 
+    }
+
+    /// \brief Deletes the item with minimum priority relative to \c Compare.
+    ///
+    /// This method deletes the item with minimum priority relative to \c
+    /// Compare from the heap.  
+    /// \pre The heap must be non-empty.  
+    void pop() {
       /*The first case is that there are only one root.*/
       if ( container[minimum].left_neighbor==minimum ) {
@@ -334,5 +217,5 @@
 	  int child=container[minimum].child;
 	  int last_child=container[child].left_neighbor;
-	
+	  
 	  makeroot(child);
 	  
@@ -348,9 +231,9 @@
     }
 
-
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::erase 
-  (const Item& item) {
+    /// \brief Deletes \c item from the heap.
+    ///
+    /// This method deletes \c item from the heap, if \c item was already
+    /// stored in the heap. It is quite inefficient in Fibonacci heaps.
+    void erase (const Item& item) {
       int i=iimap[item];
       
@@ -364,10 +247,12 @@
 	pop();
       }
-  }
-    
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::decrease 
-  (Item item, PrioType const value) {
+    }
+
+    /// \brief Decreases the priority of \c item to \c value.
+    ///
+    /// This method decreases the priority of \c item to \c value.
+    /// \pre \c item must be stored in the heap with priority at least \c
+    ///   value relative to \c Compare.
+    void decrease (Item item, const Prio& value) {
       int i=iimap[item];
       container[i].prio=value;
@@ -379,24 +264,73 @@
       }      
       if ( comp(value, container[minimum].prio) ) minimum=i; 
-  }
- 
-
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::balance() {      
-
-    int maxdeg=int( std::floor( 2.08*log(double(container.size()))))+1;
+    }
+
+    /// \brief Increases the priority of \c item to \c value.
+    ///
+    /// This method sets the priority of \c item to \c value. Though
+    /// there is no precondition on the priority of \c item, this
+    /// method should be used only if it is indeed necessary to increase
+    /// (relative to \c Compare) the priority of \c item, because this
+    /// method is inefficient.
+    void increase (Item item, const Prio& value) {
+      erase(item);
+      push(item, value);
+    }
+
+
+    /// \brief Returns if \c item is in, has already been in, or has never 
+    /// been in the heap.
+    ///
+    /// This method returns PRE_HEAP if \c item has never been in the
+    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
+    /// otherwise. In the latter case it is possible that \c item will
+    /// get back to the heap again.
+    State state(const Item &item) const {
+      int i=iimap[item];
+      if( i>=0 ) {
+	if ( container[i].in ) i=0;
+	else i=-2; 
+      }
+      return State(i);
+    }    
+
+    /// \brief Sets the state of the \c item in the heap.
+    ///
+    /// Sets the state of the \c item in the heap. It can be used to
+    /// manually clear the heap when it is important to achive the
+    /// better time complexity.
+    /// \param i The item.
+    /// \param st The state. It should not be \c IN_HEAP. 
+    void state(const Item& i, State st) {
+      switch (st) {
+      case POST_HEAP:
+      case PRE_HEAP:
+        if (state(i) == IN_HEAP) {
+          erase(i);
+        }
+        iimap[i] = st;
+        break;
+      case IN_HEAP:
+        break;
+      }
+    }
+    
+  private:
+    
+    void balance() {
+
+      int maxdeg=int( std::floor( 2.08*log(double(container.size()))))+1;
   
-    std::vector<int> A(maxdeg,-1); 
-    
-    /*
-     *Recall that now minimum does not point to the minimum prio element.
-     *We set minimum to this during balance().
-     */
-    int anchor=container[minimum].left_neighbor; 
-    int next=minimum; 
-    bool end=false; 
+      std::vector<int> A(maxdeg,-1); 
+    
+      /*
+       *Recall that now minimum does not point to the minimum prio element.
+       *We set minimum to this during balance().
+       */
+      int anchor=container[minimum].left_neighbor; 
+      int next=minimum; 
+      bool end=false; 
     	
-       do {
+      do {
 	int active=next;
 	if ( anchor==active ) end=true;
@@ -415,20 +349,18 @@
 	}	
 	A[d]=active;
-       } while ( !end );
-
-
-       while ( container[minimum].parent >=0 ) minimum=container[minimum].parent;
-       int s=minimum;
-       int m=minimum;
-       do {  
-	 if ( comp(container[s].prio, container[minimum].prio) ) minimum=s;
-	 s=container[s].right_neighbor;
-       } while ( s != m );
-    }
-
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::makeroot 
-  (int c) {
+      } while ( !end );
+
+
+      while ( container[minimum].parent >=0 ) 
+	minimum=container[minimum].parent;
+      int s=minimum;
+      int m=minimum;
+      do {  
+	if ( comp(container[s].prio, container[minimum].prio) ) minimum=s;
+	s=container[s].right_neighbor;
+      } while ( s != m );
+    }
+
+    void makeroot(int c) {
       int s=c;
       do {  
@@ -437,40 +369,31 @@
       } while ( s != c );
     }
-  
-  
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::cut 
-  (int a, int b) {    
-    /*
-     *Replacing a from the children of b.
-     */
-    --container[b].degree;
-    
-    if ( container[b].degree !=0 ) {
-      int child=container[b].child;
-      if ( child==a ) 
-	container[b].child=container[child].right_neighbor;
-      unlace(a);
-    }
-    
-    
-    /*Lacing a to the roots.*/
-    int right=container[minimum].right_neighbor;
-    container[minimum].right_neighbor=a;
-    container[a].left_neighbor=minimum;
-    container[a].right_neighbor=right;
-    container[right].left_neighbor=a;
-    
-    container[a].parent=-1;
-    container[a].marked=false;
-  }
-  
-
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::cascade 
-  (int a) 
-    {
+
+    void cut(int a, int b) {
+      /*
+       *Replacing a from the children of b.
+       */
+      --container[b].degree;
+    
+      if ( container[b].degree !=0 ) {
+	int child=container[b].child;
+	if ( child==a ) 
+	  container[b].child=container[child].right_neighbor;
+	unlace(a);
+      }
+    
+    
+      /*Lacing a to the roots.*/
+      int right=container[minimum].right_neighbor;
+      container[minimum].right_neighbor=a;
+      container[a].left_neighbor=minimum;
+      container[a].right_neighbor=right;
+      container[right].left_neighbor=a;
+    
+      container[a].parent=-1;
+      container[a].marked=false;
+    }
+
+    void cascade(int a) {
       if ( container[a].parent!=-1 ) {
 	int p=container[a].parent;
@@ -484,9 +407,5 @@
     }
 
-
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::fuse 
-  (int a, int b) {
+    void fuse(int a, int b) {
       unlace(b);
       
@@ -512,18 +431,31 @@
     }
 
-  
-  /*
-   *It is invoked only if a has siblings.
-   */
-  template <typename Prio, typename ItemIntMap, 
-    typename Compare>
-  void FibHeap<Prio, ItemIntMap, Compare>::unlace 
-  (int a) {      
+    /*
+     *It is invoked only if a has siblings.
+     */
+    void unlace(int a) {
       int leftn=container[a].left_neighbor;
       int rightn=container[a].right_neighbor;
       container[leftn].right_neighbor=rightn;
       container[rightn].left_neighbor=leftn;
-  }
-  
+    }
+
+
+    class store {
+      friend class FibHeap;
+      
+      Item name;
+      int parent;
+      int left_neighbor;
+      int right_neighbor;
+      int child;
+      int degree;  
+      bool marked;
+      bool in;
+      Prio prio;
+      
+      store() : parent(-1), child(-1), degree(), marked(false), in(true) {} 
+    };
+  };    
 
 } //namespace lemon
Index: lemon/radix_heap.h
===================================================================
--- lemon/radix_heap.h	(revision 2391)
+++ lemon/radix_heap.h	(revision 2547)
@@ -29,17 +29,4 @@
 namespace lemon {
 
-  /// \brief Exception thrown by RadixHeap.
-  ///  
-  /// This Exception is thrown when a smaller priority
-  /// is inserted into the \e RadixHeap then the last time erased.
-  /// \see RadixHeap
-  /// \author Balazs Dezso
-
-  class UnderFlowPriorityError : public RuntimeError {
-  public:
-    virtual const char* what() const throw() {
-      return "lemon::UnderFlowPriorityError";
-    }  
-  };
 
   /// \ingroup auxdata
@@ -70,4 +57,18 @@
     typedef _ItemIntMap ItemIntMap;
 
+    /// \brief Exception thrown by RadixHeap.
+    ///  
+    /// This Exception is thrown when a smaller priority
+    /// is inserted into the \e RadixHeap then the last time erased.
+    /// \see RadixHeap
+    /// \author Balazs Dezso
+    
+    class UnderFlowPriorityError : public RuntimeError {
+    public:
+      virtual const char* what() const throw() {
+	return "lemon::RadixHeap::UnderFlowPriorityError";
+      }  
+    };
+
     /// \brief Type to represent the items states.
     ///
@@ -78,5 +79,5 @@
     /// The ItemIntMap \e should be initialized in such way that it maps
     /// PRE_HEAP (-1) to any element to be put in the heap...
-    enum state_enum {
+    enum State {
       IN_HEAP = 0,
       PRE_HEAP = -1,
@@ -402,8 +403,8 @@
     /// get back to the heap again.
     /// \param i The item.
-    state_enum state(const Item &i) const {
+    State state(const Item &i) const {
       int s = iim[i];
       if( s >= 0 ) s = 0;
-      return state_enum(s);
+      return State(s);
     }
 
@@ -415,5 +416,5 @@
     /// \param i The item.
     /// \param st The state. It should not be \c IN_HEAP. 
-    void state(const Item& i, state_enum st) {
+    void state(const Item& i, State st) {
       switch (st) {
       case POST_HEAP:
