added a few improvements by replacing division and multiplication
operations with powers of two by bit shift operations (where possible)