Changed the organization of the middleware and routes.