Added negative scan increment compatibility

And moved duplicated loopwise incrementing line

fuerte backport (cherry picked from commit 1bb7353deff061dc0e5b0b0ea477b1e5fa370668)

ps: If this isn't the way to backport I'd appreciate any hints.