Comment and refactor JSON serialization.