Fixed memory leak in preview