Fix error serializing context items

Also change format of output to be grouped