[major] Add middleware system