a much more thorough fix for 64 bit number encoding