json: Improve safety, small tweaks.