Fix some memory leaks.

Memory leaks were caused by broken parent/child relations.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>