Fixed 2 bugs. One was a > that should have been a >= while the other was not updating a value on one very specific code path which was solved by lifting it out of a loop and unconditionally doing the right thing, which in most cases will also be a tiny bit more efficient (where it isn't is already the fastest path so I'm not going to worry about a couple extra instructions to calculate a 0).