(refactor) Ingot to middleware.