diff --git a/include/caosdb/logging.h b/include/caosdb/logging.h
index d785e7a237c6c62abf5b307c2bd9b8d1242b48eb..e50c70f69bc0ed45e8f6a60f78cd11e4142b0568 100644
--- a/include/caosdb/logging.h
+++ b/include/caosdb/logging.h
@@ -64,10 +64,12 @@ class TraceEnterLeaveLogger {
 public:
   inline TraceEnterLeaveLogger(const std::string &channel, const std::string &function_name)
     : channel(channel), function_name(function_name) {
-    caosdb::logging::LoggerOutputStream::get(this->channel, CAOSDB_LOG_LEVEL_TRACE) << "Enter " << this->function_name;
+    caosdb::logging::LoggerOutputStream::get(this->channel, CAOSDB_LOG_LEVEL_TRACE)
+      << "Enter " << this->function_name;
   }
   inline ~TraceEnterLeaveLogger() {
-    caosdb::logging::LoggerOutputStream::get(this->channel, CAOSDB_LOG_LEVEL_TRACE) << "Leave " << this->function_name;
+    caosdb::logging::LoggerOutputStream::get(this->channel, CAOSDB_LOG_LEVEL_TRACE)
+      << "Leave " << this->function_name;
   }
 
 private:
diff --git a/src/caosdb/logging.cpp b/src/caosdb/logging.cpp
index cdd505877850bc0adc06b15a85f80fdc9ce3a653..7aaedee77696ada264418c104b6c8c28c4bb7b24 100644
--- a/src/caosdb/logging.cpp
+++ b/src/caosdb/logging.cpp
@@ -40,7 +40,6 @@
 #include <boost/smart_ptr/shared_ptr.hpp>
 #include <cstdint> // for uint64_t
 #include <memory>
-#include <ostream> // for ostream
 #include <sstream>
 #include <string>
 #include <utility> // for move
diff --git a/src/caosdb/transaction.cpp b/src/caosdb/transaction.cpp
index f86285bba81763a467e29966dc35703faf75c469..d30d6aa9f3fa06d8dee09bb5a3d7c35ba810fb81 100644
--- a/src/caosdb/transaction.cpp
+++ b/src/caosdb/transaction.cpp
@@ -31,19 +31,17 @@
 #include <algorithm>                                               // for max
 // IWYU pragma: no_include <bits/exception.h>
 // IWYU pragma: no_include <cxxabi.h>
-#include <exception>                                // IWYU pragma: keep
-#include <filesystem>                               // for operator<<, path
-#include <future>                                   // for async, future
-#include <google/protobuf/arena.h>                  // for Arena
-#include <google/protobuf/generated_message_util.h> // for CreateMessage...
-#include <grpc/impl/codegen/gpr_types.h>            // for gpr_timespec
-#include <grpcpp/impl/codegen/completion_queue.h>   // for CompletionQueue
-#include <iosfwd>                                   // for streamsize
-#include <map>                                      // for map, operator!=
-#include <memory>                                   // for unique_ptr
-#include <random>                                   // for mt19937, rand...
-#include <system_error>                             // for std::system_error
-#include <utility>                                  // for move, pair
+#include <exception>                              // IWYU pragma: keep
+#include <filesystem>                             // for operator<<, path
+#include <future>                                 // for async, future
+#include <google/protobuf/arena.h>                // for Arena
+#include <grpc/impl/codegen/gpr_types.h>          // for gpr_timespec
+#include <grpcpp/impl/codegen/completion_queue.h> // for CompletionQueue
+#include <map>                                    // for map, operator!=
+#include <memory>                                 // for unique_ptr
+#include <random>                                 // for mt19937, rand...
+#include <system_error>                           // for std::system_error
+#include <utility>                                // for move, pair
 
 namespace caosdb::transaction {
 using caosdb::entity::v1::EntityTransactionService;
@@ -291,6 +289,9 @@ auto Transaction::DoExecuteTransaction() noexcept -> StatusCode {
       }
     }
   }
+  if (this->status.GetCode() == StatusCode::EXECUTING) {
+    return ProcessTerminated().GetCode();
+  }
   return this->status.GetCode();
 }
 
@@ -353,6 +354,7 @@ auto Transaction::ProcessRetrieveResponse(RetrieveResponse *retrieve_response,
 }
 
 auto Transaction::ProcessTerminated() const noexcept -> TransactionStatus {
+  CAOSDB_LOG_TRACE_ENTER_AND_LEAVE(logger_name, "Transaction::ProcessTerminated()")
   bool set_error = false;
   auto *responses = this->response->mutable_responses();
   std::vector<std::unique_ptr<Entity>> entities;
@@ -418,11 +420,7 @@ auto Transaction::WaitForIt() const noexcept -> TransactionStatus {
 
   this->transaction_future.wait();
 
-  if (this->status.GetCode() != StatusCode::EXECUTING) {
-    return this->status;
-  }
-
-  return ProcessTerminated();
+  return this->status;
 }
 
 // NOLINTNEXTLINE