Fixed memory issue in singleton