fix memory leaks in json & preprocessors