make message code mostly json-agnostic + misc cleanup

Some cleanup work from last week that probably makes sense to merge before the holidays.