Kracoeus-7002

Merged from mrudulpolus/KRACOEUS-7002.  Not fully functional.  Known issues are described in KRACOEUS-7745.  
OK, I thought the problem was actually with the if else which does look a bit strange but I am OK with it for now.