Added support for middleware.