rearrange middleware

as discussed very briefly on the irc channel and the list.
I can see two things that need your consideration:
1. I might have misunderstood the terse instructions to not touch app.stack :
    that's precisely what I wanted to do, and I figured it meant the caller doesn't want to have to touch it.
2. I might be seriously overlooking some valid use case where identical middleware is duplicated in the stack - I'm relying on your expertise & foresight on that question.