fix memory leaks in SystemFunctions