modify C++ singal instance implementation; modify mem leak