Fixes to gpg module, addition of gpg state module.

Some fixes and cleanup of the GPG module, Addition of a new gpg state module.