This was there even before the refactor, but the refactor exposed the bug. I hate C's useless fucking modulo operator so much. I've gotten hit by this exact bug way too many times.