Implemented log2() in order to avoid GNU99 extensions. Increased portability.