Faster log2.
In case a CPU has a very slow logrithm calculation, a lookup table + bsf
may be used for speedup.
Minor optimizations