I suspect there's a good reason it wasn't done that way, though, but I don't
have a chance to look in to it further right now.
yup it's ugly, but middlewares need to be loaded in a specific order. You may want one middleware to be loaded before another one.