Fixed a few bugs introduced by switching to json.