Refactoring for memory leak of terminator.