Use CHAR_BIT instead of hard-coding 8 in several places where it