Fix middleware and illustrate middleware order