Fixed memory leak in class