Refactored the gpg scripts