Fix division, split shared code with mod into its own method