fix cases where the same config object is given multiple times to the middleware (in other words, do not modify input)