Small updates based on code review.
Main change: Now using << instead of math.pow.