Fixed some memory leaks

Change-Id: Ibeece104efe4fcbad24b514081134d6dc3885cdd
Signed-off-by: panacotta <alejoar@gmail.com>