JSON encoder improvements

This fixes uuid encoding in the JSON encoder, and adds the `name` property to `message.fields` to outbound messages. Also some global variable leaks.