Fixed a bug when creating keypairs