This PR rework a bit Flint to prepare the support of Lima2.
It's a cherry pick of some commits from !4767 which can be merged independently.
FYI @debionne