Fix key generation