Hello!
After some investigation I ended up with a much simpler fix.It is self-explanatory in code and a commit message.
Best regards,Mikhail.