Fixed problem with memory leak