Better logic for generating PGP key. Fixes #153