Remove duplicate middlewares before wrapping handler. Keeps earliest occurance.