Index: src/Concurrency/Waitfor.cc
===================================================================
--- src/Concurrency/Waitfor.cc	(revision 1dcd955480c332b81ce157f2b7ccf8e34ad2acd3)
+++ src/Concurrency/Waitfor.cc	(revision 310e5b7a73ac432e83f04a8d32b171a31ac8c68f)
@@ -204,4 +204,19 @@
 			return new ConstantExpr( Constant::from_bool( ifnull ) );
 		}
+
+		VariableExpr * extractVariable( Expression * func ) {
+			if( VariableExpr * var = dynamic_cast< VariableExpr * >( func ) ) {
+				return var;
+			}
+
+			CastExpr * cast = strict_dynamic_cast< CastExpr * >( func );
+			return strict_dynamic_cast< VariableExpr * >( cast->arg );
+		}
+
+		Expression * betterIsDtor( Expression * func ) {
+			VariableExpr * typed_func = extractVariable( func );
+			bool is_dtor = InitTweak::isDestructor( typed_func->var );
+			return new ConstantExpr( Constant::from_bool( is_dtor ) );
+		}
 	};
 
@@ -212,5 +227,5 @@
 
 	void GenerateWaitForPass::premutate( FunctionDecl * decl) {
-		if( decl->name != "__accept_internal" ) return;
+		if( decl->name != "__waitfor_internal" ) return;
 
 		decl_waitfor = decl;
@@ -313,9 +328,10 @@
 		Type * fptr_t = new PointerType( noQualifiers, new FunctionType( noQualifiers, true ) );
 
+		Expression * is_dtor = betterIsDtor( clause.target.function );
 		CompoundStmt * compound = new CompoundStmt( noLabels );
 		compound->push_back( makeAccStatement( acceptables, index, "func"    , new CastExpr( clause.target.function, fptr_t )                            , indexer ) );
 		compound->push_back( makeAccStatement( acceptables, index, "count"   , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ), indexer ) );
 		compound->push_back( makeAccStatement( acceptables, index, "monitors", new VariableExpr( monitors )                                              , indexer ) );
-		compound->push_back( makeAccStatement( acceptables, index, "is_dtor" , new ConstantExpr( Constant::from_bool( true ) )                           , indexer ) );
+		compound->push_back( makeAccStatement( acceptables, index, "is_dtor" , is_dtor                                                                   , indexer ) );
 
 		stmt->push_back( new IfStmt(
