Small refactors to reduce the amount of duplicated code, and to avoid too many... See merge request !258