Many fixes for the JSON output -> It now produces valid JSON efficiently.