i'm simply backporting https://github.com/cfengine/core/pull/956 with a correction, so that it works as advertised. But i'll add comments, that's indeed better