Using lambda for host memory pool was causing stack smashing
error on CI. Using plain for loop fixed the issue.
I think this patch includes the refactor so I'm going to hold off on trying to review it until it can be rebased on main after the refactor lands. It's also possible to make a diff relative to another one though I'm not sure on the proper workflow for doing so.