Made the key generation optional.