Minor rearrangements and two kinds of JSON serialization.