Improved serialization of graph.