Fixed math errors.
Moved the combinations logic into a helper class.