refactoring middlebox kernel agent