Extend template's mod and modBool functions to accept any int types

Fixes #575