Revert "Revert "memory leak fix""
Revert "Revert "memory leak fix""

This reverts commit 3a1a0cd37b390c631894db4d0d6ceb8b300a6841.

zeitcoin/zeitcoin,zeitcoin/zeitcoin,zeitcoin/zeitcoin,zeitcoin/zeitcoin,zeitcoin/zeitcoin