Plug leaks

Valgrind is now clean except for libssl and libgcrypt.