Added logging and recovery from JSON parsing errors.