add json error handling, plus a few other minor items