Make conversions and doubles comparisons explicit.

This decouples logic of certain integer division steps from the actual implementation and makes code more explicit.