These changes fixed Oscam ticket 4055, credits to kraiv and chepik from
satsupreme forum.