fix several mem leak