Made the variable names more descriptive.
Factored out integer division, in case we ever want to use other algorithms for it.