logging improvements and catch json parse errors.