Added mod to EM
Guarded against MOD by zero error.
Merge pull request #39 from Pixate/robin-mod

Added mod to EM