Closed some memory-leaks