Fixed major memory leak in JSON code