Enhanced exception logging, added generateKeypair method