KRACOEUS-7847 and KRACOEUS-7282

Please review this PR, some more work pending, don't merge it just yet.
I too :), retained from the old code, left it intact because I am not sure of the impact.