Refactoring GetIndex into method.
Rewriting Mod method so that it works with small values.
Fixing misspell.