                                               :out-chan [:buffer 1]
                                               :in-timeout 5000}))
 
-(sub state-pub :app-state (:in-chan wc-c-comp))
-(pipe (:out-chan wc-c-comp) state-in-chan)
-
-(sub state-pub :app-state (:in-chan ts-comp))
-(pipe (:out-chan ts-comp) state-in-chan)
-
-(sub state-pub :app-state (:in-chan wc-comp))
-(pipe (:out-chan wc-comp) state-in-chan)
-
-(pipe state-in-chan (:in-chan state-comp))
-(pipe (:out-chan state-comp) qry-chan)
-(pipe (:sliding-out-chan state-comp) state-pub-chan)
+(def tweets-comp (toolbox/single-in-single-out tw/init-component))
 
 ;;; Initialization of WebSocket communication.
 (def ws-comp (toolbox-ws/component))
-(pipe (:out-chan ws-comp) state-in-chan)
-(pipe qry-chan (:in-chan ws-comp))
 
-(def tweets-comp (toolbox/single-in-single-out tw/init-component))
+(sub state-pub :app-state (:in-chan wc-c-comp))
+(sub state-pub :app-state (:in-chan ts-comp))
+(sub state-pub :app-state (:in-chan wc-comp))
 (sub state-pub :app-state (:in-chan tweets-comp))
-(pipe (:out-chan tweets-comp) state-in-chan)
 
-(toolbox-r/init-components state-pub state-in-chan
+(pipe (:out-chan wc-c-comp) (:in-chan state-comp))
+(pipe (:out-chan ts-comp) (:in-chan state-comp))
+(pipe (:out-chan wc-comp) (:in-chan state-comp))
+(pipe (:out-chan state-comp) (:in-chan ws-comp))
+(pipe (:out-chan ws-comp) (:in-chan state-comp))
+(pipe (:out-chan tweets-comp) (:in-chan state-comp))
+
+(toolbox-r/init-components state-pub (:in-chan state-comp)
                            [[cv/count-view "tweet-count"] [cv/users-count-view "users-count"]
                             [cv/total-count-view "total-tweet-count"] [sv/search-view "search"]
                             [pag/pagination-view "pagination"] [st/sort-view "sort-buttons"]])

;;;; Main file of the BirdWatch client-side application.

;;; Channels for handling information flow in the application.
(def state-in-chan (chan)) ; Data from server, e.g. new tweets and previous chunks.
(def qry-chan (chan)) ; Queries that will be forwarded to the server.
(def state-pub-chan (chan (sliding-buffer 1))) ; Publication of state changes.
(def state-pub (pub state-pub-chan first)) ; Pub for subscribing to

(def ts-comp (toolbox/single-in-single-out ts-c/init-component
                                           {:in-chan [:sliding 1]

                                            :in-timeout 1000}))

(def state-comp (toolbox/make-component c/make-state c/handle-incoming nil))
(def state-pub (pub (:sliding-out-chan state-comp) first)) ; Pub for subscribing to

(def wc-c-comp (toolbox/single-in-single-out (partial wc-c/init-component 25)
                                             {:in-chan [:sliding 1]
