Fix modulo calculation bug.