Fix more memory leak problems

Change-Id: I6d7d7026b1ca7fa2cb6529aef67449734fc9c9f1
Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>