Fixes memory leaks in some OSs