Fixed a memory leak, reduced frame scope.