Cleaning up the middleware-based API implementation.