Refactor lobby middleware.