Fixed middleware ordering