Small changes to the middleware