Some refactoring while trying to fix OSCPA/Store-Pathfix#571.