Improved hexvalues2hexstring function