Various fixes to the ilog2 functions