Fixed memory leak in function pair