Factor out add-dispatch-entries and applicable-middleware