Added common middleware functions.