Fix integer division problems