replaced integer * and % with shift operations, for performance
3 files changed