Improved hexadecimal conversion routines