Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc	(revision e99e43f290a67032231db42a3e1c62f8c7ba7ca7)
+++ src/ResolvExpr/AlternativeFinder.cc	(revision d97c3a4b9cfd1040061ab2ac4708294336c5404b)
@@ -1229,5 +1229,5 @@
 				Alternative newAlt{ 
 					restructureCast( alt.expr->clone(), toType, castExpr->isGenerated ), 
-					alt.env, openVars, needAssertions, alt.cost, thisCost };
+					alt.env, openVars, needAssertions, alt.cost + thisCost, thisCost };
 				inferParameters( newAlt, back_inserter( candidates ) );
 			} // if
Index: src/ResolvExpr/ConversionCost.cc
===================================================================
--- src/ResolvExpr/ConversionCost.cc	(revision e99e43f290a67032231db42a3e1c62f8c7ba7ca7)
+++ src/ResolvExpr/ConversionCost.cc	(revision d97c3a4b9cfd1040061ab2ac4708294336c5404b)
@@ -29,10 +29,10 @@
 namespace ResolvExpr {
 	const Cost Cost::zero =      Cost{  0,  0,  0,  0,  0,  0 };
-	const Cost Cost::infinity =  Cost{ -1, -1, -1,  1, -1, -1 };
+	const Cost Cost::infinity =  Cost{ -1, -1, -1, -1,  1, -1 };
 	const Cost Cost::unsafe =    Cost{  1,  0,  0,  0,  0,  0 };
 	const Cost Cost::poly =      Cost{  0,  1,  0,  0,  0,  0 };
-	const Cost Cost::var =       Cost{  0,  0,  1,  0,  0,  0 };
-	const Cost Cost::spec =      Cost{  0,  0,  0, -1,  0,  0 };
-	const Cost Cost::safe =      Cost{  0,  0,  0,  0,  1,  0 };
+	const Cost Cost::safe =      Cost{  0,  0,  1,  0,  0,  0 };
+	const Cost Cost::var =       Cost{  0,  0,  0,  1,  0,  0 };
+	const Cost Cost::spec =      Cost{  0,  0,  0,  0, -1,  0 };
 	const Cost Cost::reference = Cost{  0,  0,  0,  0,  0,  1 };
 
Index: src/ResolvExpr/Cost.h
===================================================================
--- src/ResolvExpr/Cost.h	(revision e99e43f290a67032231db42a3e1c62f8c7ba7ca7)
+++ src/ResolvExpr/Cost.h	(revision d97c3a4b9cfd1040061ab2ac4708294336c5404b)
@@ -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
Index: tests/.expect/completeTypeError.txt
===================================================================
--- tests/.expect/completeTypeError.txt	(revision e99e43f290a67032231db42a3e1c62f8c7ba7ca7)
+++ tests/.expect/completeTypeError.txt	(revision d97c3a4b9cfd1040061ab2ac4708294336c5404b)
@@ -45,5 +45,5 @@
 
 Alternatives with failing assertions are:
-Cost ( 0, 1, 1, -5, 0, 0 ): Application of
+Cost ( 0, 1, 0, 1, -5, 0 ): Application of
      Variable Expression: baz: forall
        T: sized object type
@@ -53,7 +53,7 @@
            reference to instance of type T (not function type) 
            instance of type T (not function type) 
-         ... returning 
+         ... returning
            _retval__operator_assign: instance of type T (not function type) 
-           ... with attributes: 
+           ... with attributes:
              Attribute with name: unused
 
@@ -62,5 +62,5 @@
          ... with parameters
            reference to instance of type T (not function type) 
-         ... returning nothing 
+         ... returning nothing
 
          ?{}: pointer to function
@@ -68,10 +68,10 @@
            reference to instance of type T (not function type) 
            instance of type T (not function type) 
-         ... returning nothing 
+         ... returning nothing
 
          ^?{}: pointer to function
          ... with parameters
            reference to instance of type T (not function type) 
-         ... returning nothing 
+         ... returning nothing
 
 
@@ -79,5 +79,5 @@
      ... with parameters
        pointer to instance of type T (not function type) 
-     ... returning nothing 
+     ... returning nothing
 
    ... to arguments
@@ -87,5 +87,5 @@
    void 
  )
- Environment: ( _73_0_T ) -> instance of type T (not function type)  (no widening)
+ Environment:( _73_0_T ) -> instance of type T (not function type)  (no widening)
 
 
Index: tests/.expect/nested-types-ERR2.txt
===================================================================
--- tests/.expect/nested-types-ERR2.txt	(revision e99e43f290a67032231db42a3e1c62f8c7ba7ca7)
+++ tests/.expect/nested-types-ERR2.txt	(revision d97c3a4b9cfd1040061ab2ac4708294336c5404b)
@@ -2,5 +2,5 @@
 nested-types.cfa:74:1 error: Qualified type requires an aggregate on the left, but has: signed int
 nested-types.cfa:75:1 error: Undefined type in qualified type: Qualified Type: 
-  instance of struct S with body 1 
+  instance of struct S with body 1
   instance of type Z (not function type) 
 
