Improved middleware.