More keygen fixes

Fix curve key generation error and other keygen fixes.