Middleware registration optimization