Fixed memory leak with calculating value in tuple