also fixed encoding of matahLabels. Now using json format so that it also works for empty maps.
and some cleanup