Middleware ordering

see commit message