Refactored local middlewares to external packages.