Made some doccomments multiline
Removed some duplication in JSON parsing/unparsing. Softened some type checks.
Avoid storing array IDs for arrays which didn't come from references