   (let [device-key (@midi-device-key vanished)]
     (swap! midi-inputs dissoc device-key)
     (swap! synced-metronomes dissoc device-key)
+    (swap! device-mappings dissoc device-key)
     (swap! control-mappings dissoc device-key)
     (swap! note-mappings dissoc device-key)
     (swap! aftertouch-mappings dissoc device-key)

                  :device (select-keys (:device found) [:name :description]))))
       (finally (remove-global-handler! message-finder))))))

;; TODO: apply to all matching input sources? Along with remove, and note & aftertouch messages?
(defn add-control-mapping
  "Register a handler function `f` to be called whenever a MIDI
  controller change message is received from the specified device, on

              (when @running
                (run-message-handler handler msg running)))
            
            ;; Then call any registered port listeners for the port on which it arrived
            (doseq [handler (get-in @device-mappings [(@midi-device-key (:device msg))])]
              (when @running
                (run-message-handler handler msg running)))

            ;; Then call specific message handlers that match
            (when @running
