fix memory leak, refine stts