Fix up more bugs with json encoding