big cleanup of the middleware stack