Fixed memory leak on OSX.