Clean up middleware.
Merge pull request #6315 from franzliedke/patch-12

[5.0] Clean Up Cookie Queue Middleware