fixed compile issues with ZTS and memory leak