Regrouping PRs #1227 and #1228: they should work better together

Normally the opam-rt test 'reinstall' still has a minor failure though