Fixed memory leak in DPI function calls