gpg-protocol: cleanups and swap calloc for malloc