Changing order of some operations, after careful examination this should not
have any impact on algorithm correctness.
Authored by: nerius 2023-10-04
Parent: [r1174]
Child: [r1176]