Improved hex conversion