fix JSON output bug and clear GL output explicitly