LPS-36620 Fix and also fix for LPS-36567. Reverting changes from commit ...

...339e445b17f9dae10c3aec3acebfd98a6f4c86fd / LPS-36171 which is cause of these regression bugs