Fix not critical memory leak. Simple garbage collection mechanism was added.