Index: src/ResolvExpr/Cost.h
===================================================================
--- src/ResolvExpr/Cost.h	(revision 6d6e829fe48b32bcf207da90b00789ffbba8f74d)
+++ src/ResolvExpr/Cost.h	(revision def9d4ece42b49cbb4f90f08f458811fe82b1e3f)
@@ -21,20 +21,20 @@
 	class Cost {
 	  private:
-		Cost( int unsafeCost, int polyCost, int varCost, int specCost, int safeCost, 
-		      int referenceCost );
+		Cost( int unsafeCost, int polyCost, int safeCost, int varCost, int specCost,
+			int referenceCost );
 
 	  public:
 		Cost & incUnsafe( int inc = 1 );
 		Cost & incPoly( int inc = 1 );
+		Cost & incSafe( int inc = 1 );
 		Cost & incVar( int inc = 1 );
 		Cost & decSpec( int inc = 1 );
-		Cost & incSafe( int inc = 1 );
 		Cost & incReference( int inc = 1 );
 
 		int get_unsafeCost() const { return unsafeCost; }
 		int get_polyCost() const { return polyCost; }
+		int get_safeCost() const { return safeCost; }
 		int get_varCost() const { return varCost; }
 		int get_specCost() const { return specCost; }
-		int get_safeCost() const { return safeCost; }
 		int get_referenceCost() const { return referenceCost; }
 
@@ -54,7 +54,7 @@
 		static const Cost unsafe;
 		static const Cost poly;
+		static const Cost safe;
 		static const Cost var;
 		static const Cost spec;
-		static const Cost safe;
 		static const Cost reference;
 
@@ -62,14 +62,14 @@
 		int unsafeCost;     ///< Unsafe (narrowing) conversions
 		int polyCost;       ///< Count of parameters and return values bound to some poly type
+		int safeCost;       ///< Safe (widening) conversions
 		int varCost;        ///< Count of polymorphic type variables
 		int specCost;       ///< Polymorphic type specializations (type assertions), negative cost
-		int safeCost;       ///< Safe (widening) conversions
 		int referenceCost;  ///< reference conversions
 	};
 
-	inline Cost::Cost( int unsafeCost, int polyCost, int varCost, int specCost, int safeCost, 
+	inline Cost::Cost( int unsafeCost, int polyCost, int safeCost, int varCost, int specCost, 
 			int referenceCost ) 
-		: unsafeCost( unsafeCost ), polyCost( polyCost ), varCost( varCost ), specCost( specCost ), 
-		  safeCost( safeCost ), referenceCost( referenceCost ) {}
+		: unsafeCost( unsafeCost ), polyCost( polyCost ), safeCost( safeCost ), varCost( varCost ), 
+		  specCost( specCost ), referenceCost( referenceCost ) {}
 
 	inline Cost & Cost::incUnsafe( int inc ) {
@@ -85,4 +85,10 @@
 	}
 
+	inline Cost & Cost::incSafe( int inc ) {
+		if ( *this == infinity ) return *this;
+		safeCost += inc;
+		return *this;
+	}
+
 	inline Cost & Cost::incVar( int inc ) {
 		if ( *this == infinity ) return *this;
@@ -94,10 +100,4 @@
 		if ( *this == infinity ) return *this;
 		specCost -= dec;
-		return *this;
-	}
-
-	inline Cost & Cost::incSafe( int inc ) {
-		if ( *this == infinity ) return *this;
-		safeCost += inc;
 		return *this;
 	}
@@ -112,7 +112,7 @@
 		if ( *this == infinity || other == infinity ) return infinity;
 		return Cost{ 
-			unsafeCost + other.unsafeCost, polyCost + other.polyCost, 
+			unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost, 
 			varCost + other.varCost, specCost + other.specCost, 
-			safeCost + other.safeCost, referenceCost + other.referenceCost };
+			referenceCost + other.referenceCost };
 	}
 
@@ -120,7 +120,7 @@
 		if ( *this == infinity || other == infinity ) return infinity;
 		return Cost{ 
-			unsafeCost - other.unsafeCost, polyCost - other.polyCost, 
+			unsafeCost - other.unsafeCost, polyCost - other.polyCost, safeCost - other.safeCost, 
 			varCost - other.varCost, specCost - other.specCost, 
-			safeCost - other.safeCost, referenceCost - other.referenceCost };
+			referenceCost - other.referenceCost };
 	}
 
@@ -133,7 +133,7 @@
 		unsafeCost += other.unsafeCost;
 		polyCost += other.polyCost;
+		safeCost += other.safeCost;
 		varCost += other.varCost;
 		specCost += other.specCost;
-		safeCost += other.safeCost;
 		referenceCost += other.referenceCost;
 		return *this;
@@ -152,4 +152,8 @@
 		} else if ( polyCost < other.polyCost ) {
 			return true;
+		} else if ( safeCost > other.safeCost ) {
+			return false;
+		} else if ( safeCost < other.safeCost ) {
+			return true;
 		} else if ( varCost > other.varCost ) {
 			return false;
@@ -159,8 +163,4 @@
 			return false;
 		} else if ( specCost > other.specCost ) {
-			return true;
-		} else if ( safeCost > other.safeCost ) {
-			return false;
-		} else if ( safeCost < other.safeCost ) {
 			return true;
 		} else if ( referenceCost > other.referenceCost ) {
@@ -179,7 +179,7 @@
 		int c = unsafeCost - other.unsafeCost; if ( c ) return c;
 		c = polyCost - other.polyCost; if ( c ) return c;
+		c = safeCost - other.safeCost; if ( c ) return c;
 		c = varCost - other.varCost; if ( c ) return c;
 		c = specCost - other.specCost; if ( c ) return c;
-		c = safeCost - other.safeCost; if ( c ) return c;
 		return referenceCost - other.referenceCost;
 	}
@@ -188,7 +188,7 @@
 		return unsafeCost == other.unsafeCost
 			&& polyCost == other.polyCost
+			&& safeCost == other.safeCost
 			&& varCost == other.varCost
 			&& specCost == other.specCost
-			&& safeCost == other.safeCost
 			&& referenceCost == other.referenceCost;
 	}
@@ -200,6 +200,6 @@
 	inline std::ostream &operator<<( std::ostream &os, const Cost &cost ) {
 		return os << "( " << cost.unsafeCost << ", " << cost.polyCost << ", " 
-		          << cost.varCost << ", " << cost.specCost << ", "
-		          << cost.safeCost << ", " << cost.referenceCost << " )";
+		          << cost.safeCost << ", " << cost.varCost << ", " << cost.specCost << ", "
+		          << cost.referenceCost << " )";
 	}
 } // namespace ResolvExpr
