prefer newer math.fmod; set version and variant bits according to RFC4122; remove unnecessary calls to string functions