Fix random key generation