Various fixes to json generation