diff --git a/include/opendht/dht.h b/include/opendht/dht.h
index 97e286988a6d77f4c09cbfe31ed94895479a813c..71d6865717c6f45e02e1f7d90f34341cc0632028 100644
--- a/include/opendht/dht.h
+++ b/include/opendht/dht.h
@@ -18,7 +18,6 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
  */
 
-
 #pragma once
 
 #include "infohash.h"
@@ -33,10 +32,7 @@
 #include <array>
 #include <vector>
 #include <map>
-#include <list>
-#include <queue>
 #include <functional>
-#include <algorithm>
 #include <memory>
 
 #ifdef _WIN32
@@ -319,70 +315,14 @@ private:
 
     static constexpr size_t TOKEN_SIZE {64};
 
+    // internal structures
     struct SearchNode;
-
-    /**
-     * A single "get" operation data
-     */
-    struct Get {
-        time_point start;
-        Value::Filter filter;
-        std::shared_ptr<Query> query;
-        std::set<std::shared_ptr<Query>> pagination_queries;
-        QueryCallback query_cb;
-        GetCallback get_cb;
-        DoneCallback done_cb;
-    };
-
-    /**
-     * A single "put" operation data
-     */
-    struct Announce {
-        bool permanent;
-        std::shared_ptr<Value> value;
-        time_point created;
-        DoneCallback callback;
-    };
-
-    /**
-     * A single "listen" operation data
-     */
-    struct LocalListener {
-        std::shared_ptr<Query> query;
-        Value::Filter filter;
-        GetCallback get_cb;
-    };
-
-    /**
-     * A search is a list of the nodes we think are responsible
-     * for storing values for a given hash.
-     */
+    struct Get;
+    struct Announce;
+    struct LocalListener;
     struct Search;
-
-    struct ValueStorage {
-        std::shared_ptr<Value> data {};
-        time_point time {};
-
-        ValueStorage() {}
-        ValueStorage(const std::shared_ptr<Value>& v, time_point t) : data(v), time(t) {}
-    };
-
-    /**
-     * Foreign nodes asking for updates about an InfoHash.
-     */
-    struct Listener {
-        size_t rid {};
-        time_point time {};
-        Query query {};
-
-        /*constexpr*/ Listener(size_t rid, time_point t, Query&& q) : rid(rid), time(t), query(q) {}
-
-        void refresh(size_t tid, time_point t) {
-            rid = tid;
-            time = t;
-        }
-    };
-
+    struct ValueStorage;
+    struct Listener;
     struct Storage;
 
     // prevent copy
diff --git a/src/dht.cpp b/src/dht.cpp
index af8325a5984ecf3cddab38583a31e62a75123112..9622837103f726caeb2d926cf8e6908dbe305c5f 100644
--- a/src/dht.cpp
+++ b/src/dht.cpp
@@ -91,6 +91,30 @@ constexpr std::chrono::seconds Dht::REANNOUNCE_MARGIN;
 
 // internal structures definition
 
+/**
+ * Foreign nodes asking for updates about an InfoHash.
+ */
+struct Dht::Listener {
+    size_t rid {};
+    time_point time {};
+    Query query {};
+
+    /*constexpr*/ Listener(size_t rid, time_point t, Query&& q) : rid(rid), time(t), query(q) {}
+
+    void refresh(size_t tid, time_point t) {
+        rid = tid;
+        time = t;
+    }
+};
+
+struct Dht::ValueStorage {
+    std::shared_ptr<Value> data {};
+    time_point time {};
+
+    ValueStorage() {}
+    ValueStorage(const std::shared_ptr<Value>& v, time_point t) : data(v), time(t) {}
+};
+
 struct Dht::Storage {
     InfoHash id;
     time_point maintenance_time {};
@@ -170,6 +194,39 @@ private:
     size_t total_size {};
 };
 
+
+/**
+ * A single "get" operation data
+ */
+struct Dht::Get {
+    time_point start;
+    Value::Filter filter;
+    std::shared_ptr<Query> query;
+    std::set<std::shared_ptr<Query>> pagination_queries;
+    QueryCallback query_cb;
+    GetCallback get_cb;
+    DoneCallback done_cb;
+};
+
+/**
+ * A single "put" operation data
+ */
+struct Dht::Announce {
+    bool permanent;
+    std::shared_ptr<Value> value;
+    time_point created;
+    DoneCallback callback;
+};
+
+/**
+ * A single "listen" operation data
+ */
+struct Dht::LocalListener {
+    std::shared_ptr<Query> query;
+    Value::Filter filter;
+    GetCallback get_cb;
+};
+
 struct Dht::SearchNode {
     using AnnounceStatus = std::map<Value::Id, std::shared_ptr<Request>>;
     using SyncStatus = std::map<std::shared_ptr<Query>, std::shared_ptr<Request>>;
@@ -377,6 +434,10 @@ struct Dht::SearchNode {
     }
 };
 
+/**
+ * A search is a list of the nodes we think are responsible
+ * for storing values for a given hash.
+ */
 struct Dht::Search {
     InfoHash id {};
     sa_family_t af;