Fix some memory leaks.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>