Fix keygeneration