Fixed memory leak in append