Fix hex encoding performance