Fixed Resource Leaks

Signed-off-by: Daan Hoogland <daan@onecht.net>