Added a few sanity checks to mod.