Resolves some memory leak issues.