Removed the memoryleak in key generator.