Bugfix for random key generation