Start cleaning up: Extracted functionnalities to middlewares