fixed memory leak with json stuff