Revert "Move mod calculations to a separate helper"

This reverts commit e3718e5d518651ed63f4f141069dff2bada4b302.