Fix middlewares registration