Refactor Lotus::Middleware